android:使用Intent.ACTION_BOOT_COMPLETED还是...? [英] android: use Intent.ACTION_BOOT_COMPLETED or ...?
问题描述
在AndroidManifest文件中,我想在用户重新启动设备时捕获BOOT_COMPLETED事件.我要添加此权限:
In the AndroidManifest file, I want to capture the BOOT_COMPLETED event when the user re-boots their device. I am adding this permission:
"uses-permission android:name =" android.permission.RECEIVE_BOOT_COMPLETED"
"uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"
我在Stackoverflow上看到了其他人使用的两个意图过滤器":
I have seen two "intent-filters" used by others on Stackoverflow:
"Intent.ACTION_BOOT_COMPLETED"和
"Intent.ACTION_BOOT_COMPLETED" and
"android.intent.action.BOOT_COMPLETED"
"android.intent.action.BOOT_COMPLETED"
此处首选的操作字符串是什么?请提出建议并解释.
What is the preferred action string here? Please advise and explain.
推荐答案
Intent.ACTION_BOOT_COMPLETED == android.intent.action.BOOT_COMPLETED
它们都是相同的,因为如果您查看 Intent.ACTION_BOOT_COMPLETED
的值是什么,您会看到它是 android.intent.action.BOOT_COMPLETED
.
They're both the same, because if you look into what the value of Intent.ACTION_BOOT_COMPLETED
is, you'll see that it's android.intent.action.BOOT_COMPLETED
.
通常在清单中,由于 Intent.ACTION_BOOT_COMPLETED
是Java代码而不是xml,因此您将使用 android.intent.action.BOOT_COMPLETED
.
Typically in the Manifest, you'll use android.intent.action.BOOT_COMPLETED
due to Intent.ACTION_BOOT_COMPLETED
being Java code rather than xml.
但是在您的代码中,您可以使用 Intent.ACTION_BOOT_COMPLETED
作为替代,因为它更容易记住.
But in your code, you can use Intent.ACTION_BOOT_COMPLETED
as an alternative due to it being much easier to remember.
这篇关于android:使用Intent.ACTION_BOOT_COMPLETED还是...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!