android通知栏响应事件

BroadcastReceiver onClickReceiver =  new  BroadcastReceiver() {
 
             @Override
             public  void  onReceive(Context context, Intent intent) {
                 if  (intent.getAction().equals(STATUS_BAR_COVER_CLICK_ACTION)) {
                                     //在这里处理点击事件
             }
         };
         IntentFilter filter =  new  IntentFilter();
         filter.addAction(STATUS_BAR_COVER_CLICK_ACTION);
         registerReceiver(onClickReceiver, filter);
 
         Intent buttonIntent =  new  Intent(STATUS_BAR_COVER_CLICK_ACTION);
         PendingIntent pendButtonIntent = PendingIntent.getBroadcast( this 0 , buttonIntent,  0 );
         mRemoteViews.setOnClickPendingIntent(R.id.music_status_bar_icon, pendButtonIntent);
                  //R.id.trackname为你要监听按钮的id
         mRemoteViews.setOnClickPendingIntent(R.id.trackname, pendButtonIntent);

你可能感兴趣的:(android,Notification,java)