我可以在安装后立即以某种方式启动隐藏的(LEANBACK_LAUNCHER)android应用程序,而无需打开吗? SECRET_CODE接收者已在AndroidManifest.xml中注册。
<receiver
android:name=".MyReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data
android:host="****"
android:scheme="android_secret_code" />
</intent-filter>
</receiver>
MyReceiver:
class MyReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent?) {
if (intent != null && intent.action != null) {
if (intent.action == "android.provider.Telephony.SECRET_CODE") {
val launchIntent = Intent(context, MyActivity::class.java)
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(launchIntent)
}
}
}
}
问题是安装apk后,我无法通过拨号程序中的指定代码启动它,当我拨打它时,它只会被擦除,并且没有执行任何启动操作。但是,当我从ADB启动活动时(顺便说一句,这是我可以启动活动的唯一方法),活动就会出现,然后可以由拨号程序根据我指定的秘密代码来启动活动。>