I've just read a ton of similar questions, but nothing helped at all.
In the code below I'm trying to perform a starting an app right after unlock of my granny's old phone and show her the only button to enter Viber.
OnBoot Activity
class OnBoot : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { if (Intent.ACTION_BOOT_COMPLETED == intent.action) { val i = Intent(context, MainActivity::class.java) i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) context.startActivity(i) } } Manifest
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <receiver android:name=".OnBoot"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.QUICKBOOT_POWERON" /> </intent-filter> </receiver> </application> MainActivity
fun openApp(view: View) { val launchIntent = packageManager.getLaunchIntentForPackage(".com.viber") if(launchIntent != null){ startActivity(launchIntent) } else { Toast.makeText(this , "No package", Toast.LENGTH_LONG).show() } So, app doesn't start even on Emulator. Seen comments like "Check weird permission on Xiomi emulator", mine is Pixel 2. Also, I know that Viber package name is wrong and I know where it should be, but cannot find it in emulator, would appreciate the hint in comments.
Maybe any ideas with the task?
https://stackoverflow.com/questions/65621317/how-to-solve-the-problem-with-starting-an-android-app-on-boot January 08, 2021 at 07:19AM
没有评论:
发表评论