Exemplo de código: Recuperando a localização do usuário
O exemplo de código a seguir supõe que a classe que exibiu o MyUserProfileBoxScreen forneceu uma referência ao objeto BBMPlatformContext associado do aplicativo no construtor MyUserProfileBoxScreen.
import net.rim.blackberry.api.bbm.platform.*;
import net.rim.blackberry.api.bbm.platform.profile.*;
import net.rim.device.api.system.*;
import java.util.*;
public class MyUserProfileBoxScreen extends MainScreen
{
public MyUserProfileBoxScreen(BBMPlatformContext platformContext)
{
UserProfile userProfile = platformContext.getUserProfile();
UserProfileLocation userProfileLocation = userProfile.getUserProfileLocation();
if(userProfileLocation != null) {
String countryCode = userProfileLocation.getCountryCode();
Bitmap countryIcon = userProfileLocation.getCountryIcon();
TimeZone timeZone = userProfileLocation.getTimeZone();
} else {
// User has not enabled location in profile
}
}
}
Próximo tópico: Definindo ouvintes de serviço
Tópico anterior: Recuperar a localização do usuário
Estas informações foram úteis? Gostaríamos de receber seus comentários.