如何在通知android中添加路由图标

时间:2013-12-15 18:22:09

标签: android icons push-notification routes

private void showNotification() {

    NotificationManager mNotificationManager = (NotificationManager)getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
  Notification notifyDetails = new Notification(R.drawable.alert_light_frame,"Alarma!",System.currentTimeMillis());
  PendingIntent myIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(Intent.ACTION_VIEW, People.CONTENT_URI), 0);
  notifyDetails.setLatestEventInfo(getApplicationContext(), "Alarma!", nombre, myIntent);
  notifyDetails.flags |= Notification.FLAG_AUTO_CANCEL;
  notifyDetails.icon |= HEREEEEEEEEEEE
  mNotificationManager.notify(SIMPLE_NOTFICATION_ID++, notifyDetails);
        Log.i(getClass().getSimpleName(),"Sucessfully Changed Time");

  }

在“HEReeeeeeeeeeeee”中我需要放一条路线,例如“/mnt/sdcard/Pou/4_1362782019815.png”

THX。

2 个答案:

答案 0 :(得分:0)

尝试使用Notification.Builder来构建通知,因为它使事情变得更方便,另外还有一个setLargeIcon()方法可用于传入您想要的任何位图(包括从SD卡加载的位图) )。如果你需要定位pre-Honeycomb

,支持库中还有NotificationCompat.Builder

答案 1 :(得分:0)

1)从sdcard获取图标位图:

File f = new File("/mnt/sdcard/photo.jpg");
Bitmap notificationIconBmp = BitmapFactory.decodeFile(f.getAbsolutePath());

2)设置通知的位图

NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
        builder.setLargeIcon(notificationIconBmp);       
        NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        nm.notify("direct_tag", NOTIF_ALERTA_ID, builder.build());