Mengambil lokasi pengguna
Sebelum Anda mulai: Pastikan bahwa Anda telah menyelesaikan tugas,
Mendaftarkan aplikasi Anda ke platform BlackBerry Messenger, dan bahwa kelas yang menampilkan layar
MyUserProfileBoxScreen mengirimkan referensi ke objek
BBMPlatformContext yang terkait dengan aplikasi tersebut.
- Impor kelas dan antarmuka yang diperlukan.
import net.rim.blackberry.api.bbm.platform.*;
import net.rim.blackberry.api.bbm.platform.profile.*;
import net.rim.device.api.system.*;
import java.util.*;
- Buat kelas yang memperluas MainScreen. Dalam konstruktor untuk kelas layar ini, kirimkan objek BBMPlatformContext yang terkait dengan aplikasi.
public class MyUserProfileBoxScreen extends MainScreen
{
public MyUserProfileBoxScreen(BBMPlatformContext platformContext)
{
}
}
- Dalam konstruktor, aktifkan BBMPlatformContext.getUserProfile() untuk mengambil referensi ke objek UserProfile yang terkait dengan BBMPlatformContext ini. Instance yang dikembalikan adalah profil pengguna sekarang.
UserProfile userProfile = platformContext.getUserProfile();
- Dalam konstruktor, aktifkan UserProfile.getUserProfileLocation() untuk mengambil referensi ke objek UserProfileLocation yang terkait dengan UserProfile ini.
UserProfileLocation userProfileLocation = userProfile.getUserProfileLocation();
- Dalam konstruktor, ambil kode negara pengguna, ikon bendera negara, dan zona waktu. Perhatikan bahwa bidang-bidang ini adalah hanya-baca.
String countryCode = userProfileLocation.getCountryCode();
Bitmap countryIcon = userProfileLocation.getCountryIcon();
TimeZone timeZone = userProfileLocation.getTimeZone();
Apakah informasi ini berguna? Kirimkan komentar Anda kepada kami.