0

So I have an app and I want it to run immediately whenever device got rebooted. To achieve this I added home category to MainActivity.

<category android:name="android.intent.category.HOME" />

After I reboot the device app will run directly. But when I first time click home button to go back to default home screen, nothing happens. Need to click home button again and device will act normally . Then from now on home button works fine until I reboot the device again.

I've checked the log and found out that on first time click home button nothing is triggered. And from second time click ActivityManager will start to work and call com.android.launcher3

Does anyone have any ideas why this weird situation happens?

Note:

  1. When I checked the log I found out one line might be useful so I'll post it here. Not sure what is this mean though:I/PowerHAL: Don't support interaction_button in normal mode

  2. I know there is another work around for RECEIVE_BOOT_COMPLETED. But then device will wait a few seconds on home screen to trigger broadcast receiver. Based on my requirement I can not use this solution. Thanks in advance if you suggest me this solution but please help for my current question.

Ran Zhang
  • 11
  • 3
  • You can try another approach to open your app after boot, please check [this question](https://stackoverflow.com/q/6391902/7948109), you can use `BroadcastReceiver` instead – Rahul Gaur Dec 11 '21 at 10:56
  • RECEIVE_BOOT_COMPLETED will need to wait a few seconds on home screen. My requirement is to start app as soon as possible so I can't use this. – Ran Zhang Dec 11 '21 at 11:00
  • "To achieve this I added home category to MainActivity" -- then you should be implementing a complete launcher (a.k.a., home screen). "Does anyone have any ideas why this weird situation happens?" -- it happens because you are interfering with the other launcher, because you declared that your app is a launcher. – CommonsWare Dec 11 '21 at 12:05
  • @CommonsWare What you answered does not seems to solve the problem. I know I declared that my app is a launcher. But still I don't know what happens behind the screen. Would you mind to explain why only first time click have this problem and then everything works as expect? – Ran Zhang Dec 11 '21 at 12:16
  • "What you answered does not seems to solve the problem" -- if you remove that `` element from your manifest, your problem will go away. "Would you mind to explain why only first time click have this problem and then everything works as expect?" -- I can't explain that. More importantly, though, you have no way of knowing what to expect across tens of thousands of Android device models. – CommonsWare Dec 11 '21 at 13:23
  • So base on what you mean there is no way I could achieve what I want right? – Ran Zhang Dec 11 '21 at 13:47

0 Answers0