Menghapus item dari kotak profil 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.*;
net.rim.device.api.ui.component.*;
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 ini adalah profil pengguna sekarang.
UserProfile userProfile = platformContext.getUserProfile();
- Aktifkan UserProfile.getProfileBox() untuk mengambil referensi ke objek UserProfileBox yang terkait dengan UserProfile ini.
UserProfileBox profileBox = userProfile.getProfileBox();
if (profileBox.isAccessible())
{
}
- Aktifkan pengiriman UserProfileBox.removeItem() dalam ID item yang akan dihapus dari kotak profil. Contoh ini menghapus item pertama yang terkandung dalam UserProfileBoxItem[] yang dikembalikan oleh UserProfileBox.getItems().
UserProfileBox profileBox = userProfile.getProfileBox();
if (profileBox.isAccessible())
{
int[] itemIds = profileBox.getItemIds();
if(itemIds.length >= 1) {
profileBox.removeItem(itemIds[0]);
}
}
Apakah informasi ini berguna? Kirimkan komentar Anda kepada kami.