0

I'm creating a HOME (android.intent.category.HOME) typed application which launchs another app as soon as the first one is launched. Up until now I've been using onResume() on the activity fragment, which was working great (meaning on other tablets with other Android version) until I tried it on an SM-T230 (Galaxy Tab 4 7" Wifi) which has Kitkat 4.4.2.

I don't know why but with that tablet the "BOOT_COMPLETED" intent is never fired. I've tried launching many different apps and with every single one of them happens the same thing. The aforementioned intent is never launched. Only after pressing back repeatedly and getting back to the HOME typed app it is launched (it must be done repeatedly since the app launches every time in onResume() the second app). If it is never launched by the system, the wifi service, tethering and many more will not function.

Interestingly if I omit the launch of the second app, the intent is fired.

I'm thinking on trying to launch the app as soon as the HOME app fragment becomes visible but I have no idea as of how to do it. Does someone has any idea on how to do that?

Also if you have encountered the same problem I would like to read your comments.

Storo
  • 988
  • 1
  • 7
  • 31
  • Is it a single broadcast type app or it has any activitiy too ??? – Lucifer Nov 27 '14 at 12:58
  • @Kedarnath it is an Activity with the `android.intent.category.HOME` filter. – Storo Nov 27 '14 at 13:02
  • Read this : http://stackoverflow.com/a/12617065/3330969 – Lucifer Nov 27 '14 at 13:07
  • Read this answer as well : http://stackoverflow.com/a/14110475/3330969 – Lucifer Nov 27 '14 at 13:11
  • @Kedarnath Thanks for the links. My app is a system app so it does not need to have any components activated manually. I edited the post and added **Interestingly if I omit the launch of a second app, the intent is fired**. – Storo Nov 27 '14 at 13:15
  • I suggest you to try the launch of second app after some time like 2-5 second's delay. This may solve your problem. Use [CountdownTimer](http://developer.android.com/reference/android/os/CountDownTimer.html) Class. – Lucifer Nov 27 '14 at 13:17
  • @Kedarnath I also though that solution but it doesn't seem to be such a good practice, that's why I wanted to detect or override a method that let me launch the app as soon as the fragment is visible. – Storo Nov 27 '14 at 13:29
  • @Storo, Were you able to find why this issue has happened . Can you please let me know if you have the solution other than adding delay in onresume – user2702700 Jan 04 '16 at 10:12
  • @user2702700 I posted the solution I used. – Storo Jan 05 '16 at 11:11

2 Answers2

1

The problem was that the second app was launched before the first android fragment is visible. To solve this problem I added a very small timer that launches the second app after it times out.

@Override
public void onResume() {
    super.onResume();
    ...
    getView().postDelayed(scheduleLaunch, 2000);
}

private Runnable scheduleLaunch = new Runnable() {
    @Override
    public void run() {
        if (isAdded()) {
            launchMainApp();
        }
    }
};
Storo
  • 988
  • 1
  • 7
  • 31
  • http://stackoverflow.com/questions/25887630/android-custom-launcher-startactivity-blocks-boot-completed-intent – JohnyTex Aug 22 '16 at 13:59
0

Did you add permission?

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Dominik Suszczewicz
  • 1,469
  • 2
  • 16
  • 23
  • 1
    **which was working great until I tried it on an SM-T230** that means he has given the permission. – Lucifer Nov 27 '14 at 13:00
  • 2
    Of course. Otherwise the statement **which was working great** would not make any sence. – Storo Nov 27 '14 at 13:01