android中如果当前收到新的email会在status bar中显示一个表示新mail的图标,然后发出提示声音.我现在要单独做一个应用程序实现这个功能,请问我要怎么要才能获取到notification发出来的消息以及内容?

解决方案 »

  1.   

    通知不就是用到了pendingIntent吗?可以在里面的intent里存数据,当点击通知跳转到activity时就把值取出来咯
      

  2.   

    pendingIntent,请问有具体的code参考一下吗?
      

  3.   


    NotificationManager notificationManager = (NotificationManager)
                context.getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(R.drawable.mz,"通知",
                        System.currentTimeMillis());            Intent newintent = new Intent(context,DownLoad.class);
                newintent.putExtra("height", 123);//存入数据
                newintent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                newintent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity( 
    context, 
    0, 
    newintent,
    0
    ); notification.setLatestEventInfo(context,
    "资源下载", 
    "资源下载中...", 
    pendingIntent);
    notification.flags|=Notification.FLAG_ONGOING_EVENT; //一直存在
    notification.defaults |= Notification.DEFAULT_SOUND; //默认声音
    notificationManager.notify(0, notification);//发起通知
    这样存进去,然后,接收就可以。intent.getIntExtra("height");
      

  4.   

    getIntent()获取一个Intent对象,通过Intent对象可以获取各值了
      

  5.   

    我现在新做一个a.apk的c.activity中如何去获取这个intent对象呢?