Android 单击通知,然后完成时间任务?

Android 单击通知,然后完成时间任务?,android,timer,android-notifications,android-pendingintent,Android,Timer,Android Notifications,Android Pendingintent,我正在一个活动中创建通知(例如text.class),当激活该活动时,我单击它,它会在该页面中返回我(text.class)在该页面中,我有一个TimerTask,当单击该通知重置页面时,我需要它计时器任务 我怎么能做到 我想当我点击通知时,重置页面和完成时间任务 这是我的通知: NotificationManager nman; nman=(NotificationManager) getSystemService(NOTIFICATION_SERVICE); Long when=System

我正在一个
活动中创建
通知
(例如
text.class
),当激活该活动时,我
单击它
,它会在该页面中返回我(
text.class
)在该页面中,我有一个
TimerTask
,当
单击该通知重置页面时,我需要它计时器任务

我怎么能做到

我想当我点击通知
时,
重置页面
完成时间任务

这是我的
通知

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);

FLAG\u ACTIVITY\u SINGLE\u TOP
标志添加到
notificontent
中,并使用额外的键向正在运行的活动传递意图,该键指示来自
通知的意图?如果是,则取消已在
onNewIntent
中运行的
TimerTask

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