2013-12-15 65 views
0
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」如何在Android的通知

THX。

回答

0

嘗試使用Notification.Builder建立您的通知,因爲它使事情變得更加方便,另外還有一個setLargeIcon()方法,您可以使用它來傳遞您想要的任何位圖(包括您從SD卡加載的位圖)。還有NotificationCompat.Builder的支持庫,如果你需要的目標預蜂窩

0

1)從SD卡獲取圖標位圖:

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());