Notification.Builder nb = new Notification.Builder(MyService.this);
nb.setSmallIcon(R.drawable.qq);
nb.setContentInfo("ContentInfo");
nb.setContentTitle("ContentTitle");
nb.setContentText("ContentText");
Intent intent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,intent, PendingIntent.FLAG_UPDATE_CURRENT);
nb.setContentIntent(contentIntent);

Notification notification = nb.build();

NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify(1,  notification);上面是我的代码,但是 一运行程序就奔溃,初学android 不知道 为啥?求给个能运行的Notification.Builder 产生 Notification 的例子?AndroidNotification.BuilderNotification 

解决方案 »

  1.   


    我的手机是4.04 我看的 API 是17  .......... ,我的错 换个问题:
    BitmapFactory.decodeFile("android.resource://com.octopus.paopao/raw/m1")但是得到 是空 Bitemap  ? 为什么 ?  使用项目里面的 资源 decodeFile(UriString) 里面的URiString该怎么写?
      

  2.   

    获取资源中的图片直接BitmapFactory.decodeResource(getResources(), R.drawable.XXX);就行了啊