Contoh kode: Mengambil lokasi pengguna
Contoh kode berikut mengasumsikan bahwa kelas yang menampilkan MyUserProfileBoxScreen telah memberikan referensi untuk objek BBMPlatformContext yang terkait dengan aplikasi ini ke konstruktor 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
}
}
}
Topik berikutnya: Menentukan pendengar layanan
Topik sebelumnya: Mengambil lokasi pengguna
Apakah informasi ini berguna? Kirimkan komentar Anda kepada kami.