java - 关于安卓 onNewIntent() 触发的问题
阿神
阿神 2017-04-17 12:00:21
0
2
565

我有一个activity,是用来识别一个NFC标签的。这个activity如果没有搜寻到NFC标签的话就不做任何事情。因为我们知道设备在搜索到NFC标签的时候会发出一个新的intent,并且通过intent-filter选择能处理的activity来运行。

现在我的问题是,假设设备搜索到了NFC标签,并且发出一个Intent(),我的activity这个时候正好在堆栈顶部,它的onNewIntent()是否会被触发?

阿神
阿神

闭关修行中......

reply all(2)
小葫芦

I think this has nothing to do with NFC. It depends on how you set the Activity launch mode. If you set the Activity launchMode to SingleTask or SingleTop, then in the above situation, a new Activity instance will not be created, but Call onNewIntent()

阿神

NFC has a foreground scheduling system, which means that if the current foreground Activity can handle the NFC Intent and has foreground scheduling turned on. The NFC scheduling system will give priority to the current NFC Intent to the current Activity. If you set the startup mode to singleTop, onNewIntent() will be triggered directly. If you do not enable foreground scheduling, an application selection list will pop up at the bottom of the screen. When you select the current Activity, onNewIntent() will be triggered.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!