2011-10-07 4 views
0

사용자가 다른 알림을 누를 때 자동으로 지워지는 알림을 만들고 싶습니다. 아래의 알림은 정상적으로 작동하지만 언론에 보도 할 때 "MyActivity"액티비티로 이동합니다. 사용하지 않으려 고 할 때 의도를 정의하지 않아도됩니다.사용자가 알림을 클릭하면 알림을 취소 할 수 있습니까?

FLAG_AUTO_CANCEL 사용 전혀 효과가없는 것 같습니다.

는 업데이트 : FLAG_AUTO이 취소 미안 해요, 내가 찾은 그 통지가 상태 표시 줄에서 삭제된다, 작업을 수행합니다. 나는 아무것도하지 않는 (또는 완전히 의도를 삭제하는) 의도를 쓰려고 정말로 노력하고 있다고 생각한다.

코드 ...

   Notification notification = new Notification(R.drawable.success, res.getString(R.string.messages_sent), System.currentTimeMillis()); 

      //Define the expanded message and intent 
      Context context = getApplicationContext(); 
      CharSequence contentTitle = res.getString("My content title"); 


      Intent notificationIntent = new Intent(this, MyActivity.class); 
      PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); 
      notification.setLatestEventInfo(context, contentTitle, mStrSuccessMessage, contentIntent); 
      notification.flags |= Notification.FLAG_AUTO_CANCEL; 
      //Pass the notification to the notification manager 
      mNotificationManager.notify(1, notification); 

답변

0

실제 의도없이 빈 의도를 사용하십시오.

PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(), 0); 
0

나는 당신이 할 수 있다고 생각하지 않습니다. 즉시 MyActivity을 종료 할 수 있습니다 : (onCreate())으로 전화하십시오.

관련 문제