2017-10-07 84 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系统**文本附近的展开图标。我在问这个图标。 –

相关问题