0

나는에 Notification을 만드는 오전 나는 TimerTask을 가지고 있고 내가 필요 Activity 때 활성 그와 나는 Click on it, 그것은이 페이지에서 해당 페이지 (text.class)에서 저를 반환 (예를 text.class 용) 때 Click on that Notification Reset page 또는 Finish() the TimerTask.알림을 클릭 한 다음 TimerTask를 끝내시겠습니까?

어떻게 할 수 있습니까?

내가 생각할 때 나는 click on notificationreset pagefinish TimerTask입니다.

이것은 내 Notification :

NotificationManager nman; 
nman=(NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
Long when=System.currentTimeMillis(); 
Notification n; 
n=new Notification(R.drawable.chat_logo,"",when); 
Context context=getApplicationContext(); 
String Title=G.context.getResources().getString(R.string.StatusM); 
String Text=G.context.getResources().getString(R.string.Statusms); 
Intent notifintent=new Intent(context,ConversationPage.class); 
PendingIntent pending; 
pending=PendingIntent.getActivity(context,0,notifintent,android.content.Intent.FLAG_ACTIVITY_NEW_TASK); 
n.setLatestEventInfo(context, Title, Text, pending); 
n.flags = Notification.FLAG_AUTO_CANCEL; 
nman.notify(0,n); 

답변

1

Notification에서 의도 표시 여분의 키와 활동을 실행하는 의도를 전송하는 notifintentFLAG_ACTIVITY_SINGLE_TOP 플래그를 추가 하시겠습니까? 예인 경우 이미 실행 중임 TimerTask : onNewIntent :

@Override 
public void onNewIntent(Intent intent){ 
    Bundle extras = intent.getExtras(); 
    if(extras != null) 
     if(extras.containsKey("isfromnotification")) 
     { 
      //cancel TimerTask here 
     } 
    } 
관련 문제