2012-05-09 9 views
5

...Bu bir stok Android Bildirimi (RemoteView) düzeni var mı? Benim HTC telefonu bildirimleri için RemoteView'in aşağıdaki resim gibi görünüyorsa On

enter image description here

ben yer aldığı bildirimi aynı düzeni (resim, kalın metin ve küçük metin) kullanmak istiyorum benim app ama stok Android düzeni olup olmadığını çalışamıyorum. Kendi mizamı oluşturdum ama tamamen aynı değil ve mümkünse 'standart' a bağlı kalmak istiyorum.

Tutulmayı kullanma Önerilerinizin ne olduğunu görmek için android.R.layout. numaralı telefon numarasını yazmayı denedim, ancak herhangi bir bildirim düzenini öneren adla hiçbir göremiyorum.

Bu bir stok Android düzeni mi? Öyleyse, nasıl erişirim?

cevap

5

Standart Android bildirim düzenidir ve kendi özel düzeninizi oluşturmanız gerekmez. Çizilebilir, başlık ve metin ayarlamak için sadece mevcut bildirim API'sini kullanın.

Notification notification = new Notification(R.drawable.notification_icon, getText(R.string.notification_ticker), System.currentTimeMillis()); 

Intent notificationIntent = new Intent(this, ActivityHome.class); 
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); 

notification.setLatestEventInfo(this, getString(R.string.notification_title), getText(R.string.notification_text), pendingIntent); 

mNotificationManager.notify(NOTIFICATION_ID, builder.getNotification()); 
: Notification sınıfı kullanılarak

Intent notificationIntent = new Intent(this, ActivityHome.class); 
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); 

NotificationCompat.Builder builder = new NotificationCompat.Builder(this); 
builder.setContentIntent(pendingIntent) 
     .setWhen(System.currentTimeMillis()) 
     .setTicker(getText(R.string.notification_ticker)) 
     .setSmallIcon(R.drawable.notification_icon) 
     .setContentTitle(getText(R.string.notification_title)) 
     .setContentText(getText(R.string.notification_text)); 

mNotificationManager.notify(NOTIFICATION_ID, builder.getNotification()); 

Aynı Aşağıda uyumluluk kitaplığından NotificationCompat.Builder kullanılarak, bir örnektir

İlgili konular