我的问题是,在onNewIntent()函数中,我启动了打开联系人应用程序的新意图,并允许用户完成创建新联系人的过程,但是当我试图退出联系人应用程序并返回到我的应用程序时,onNewIntent()似乎最有可能再次被调用,这是因为这段代码。
@Override
public void onResume() {
super.onResume();
// Check to see that the Activity started due to an Android Beam
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
processIntent(getIntent());
}
}一旦onNewIntent (由processIntent调用)被调用,是否有一种方法可以清除意图。
发布于 2015-06-15 02:18:27
看起来,您可以在setIntent()的末尾调用onNewIntent(),这是一个新的意图,它具有一个不会触发进一步处理的Action值。
下面是一个示例,其中使用“do_nothing”的操作设置了该活动的新意图:
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
//Do your current processing here:
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
//process intent
//.........
// set intent for Activity to new Intent with "do_nothing" as action
Intent i = new Intent();
i.setAction("do_nothing");
setIntent(i);
}
}https://stackoverflow.com/questions/30836121
复制相似问题