2017-10-07 85 views
-3

我想在我的開發應用程序的通知中放大圖標。我已經完成了通知RemortView崩潰,並擴大布局幫助this site。低頭投手是我目前的通知狀態。如何在android中的通知中放置擴展圖標

enter image description here

我的代碼如下:

NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext); 
     builder.setContentIntent(intent); 
     builder.setTicker(mContext.getResources().getString(R.string.custom_notification)); 
     builder.setSmallIcon(R.drawable.ic_notification_small_basket); 
     builder.setAutoCancel(true); 
     builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); 
     builder.setCustomBigContentView(expandedView); 
     builder.setCustomContentView(contentView); 

     NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(NOTIFICATION_SERVICE); 
     notificationManager.notify(0, builder.build()); 

實際我需要的是如何將展開圖標,以及如何獲取使用展開和摺疊通知一下,從通知RemortView事件。

看起來像下面的投手。 這個投手只是一個擴展圖標的例子。

enter image description here 請幫助我。現在

+1

一些調整,我會從這裏開始https://developer.android.com /training/monitoring-device-state/battery-monitoring.html然後學習如何請求一個視圖對象,當你點擊一個按鈕時搜索「android onClick get view」它可能會開啓一個新的世界 – Grendel

+0

嗨@Grendel,請看我的更新的問題。 –

+0

這裏是一個鏈接,可能會幫助http://programmerguru.com/android-tutorial/android-broadcast-receiver-example/ – Grendel

回答

0

OK,我們有代碼,我想這和它的工作對我來說,你需要做在哪裏,什麼是存儲

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) 
      .setSmallIcon(R.mipmap.ic_launcher) 
      .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), 
        R.mipmap.ic_launcher)) 
      .setContentTitle(title) 
      .setContentText(message) 
      .setAutoCancel(true) 
      .setSound(defaultSoundUri) 
      .setContentIntent(pendingIntent); 

    android.app.NotificationManager notificationManager = 
      (android.app.NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); 
+0

我對你的謙卑請求,請完整閱讀這個問題,然後把你的答案。我已經完成了你給定的解決方案,在我的問題中也提到了。我知道它工作正常。我的需要是**如何在通知**中放置圖標。它也被標記在第二投手。 –

+0

@GowsikRaja什麼或哪個是擴展圖標?你是否用我的代碼替換你的代碼? RED是擴展圖標還是黑色部分?我們無法理解你想要的東西!兩個圖標還要注意我的代碼與你的不同 – Grendel

+0

是的,在你的代碼中** setLargeIcon **是一個額外的東西。這也是我通過使用RemortView完成的。你有沒有在我的問題中看到第二投球手的** Android系統**文本附近的展開圖標。我在問這個圖標。 –

相關問題