Codevoorbeeld: de gebruikerslocatie ophalen
In het volgende codevoorbeeld wordt aangenomen dat de klasse die MyUserProfileBoxScreen heeft weergegeven, een verwijzing naar het bijbehorende BBMPlatformContext-object van de toepassing in de constructor MyUserProfileBoxScreen heeft doorgegeven.
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
}
}
}
Volgend onderwerp: Servicelisteners definiëren
Vorig onderwerp: De locatie van een gebruiker ophalen