0

I have found this post how to make an application to start after Android OS boot is completed. I have done it good - I am catching the broadcast android.intent.action.BOOT_COMPLETED, but unfortunately my app crashes and I cannot observe it with logcat because I have to reboot the device in order to see if my feature is working.

Does anybody know how can I catch an exception so I can see why my app is crashing OR does anybody know what could be the problem (if you have experienced the same problem)?

Community
  • 1
  • 1
svarog
  • 688
  • 1
  • 12
  • 29
  • Wrap whatever you think might be crashing in a try catch; capture your own logs. – Matt Clark Jan 27 '17 at 19:43
  • hey, I am relatively new with android, I have surrounded with try-catch... but don't know where to store the exception. Only what I know is to print it as Toast... can you explain me this a little bit please? – svarog Jan 27 '17 at 19:49
  • You can write to Logcat, check this link to [documentation](https://developer.android.com/reference/android/util/Log.html) – Bö macht Blau Jan 27 '17 at 21:03

1 Answers1

1

I have solved the problem... The initial intent was:

Intent i = new Intent();
i.setClassName("com.example.app", "MainActivity");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

I made a toast with exception in it and made printscreen on emulator.

The exception said this:

android.content.ActivityNotFoundException: Unable to find explicit activity class{com.example.app/com.example.app.MainActivity}; have you declared this activity in your AndroidManifest.xml?

After checking, my activity was in the file. So I googled this and made correction in my intent to:

Intent i = new Intent();
i.setClassName(context.getPackageName(), "com.example.app.sunshine.MainActivity");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

and context.startActivity(i); started the app after reboot.

Community
  • 1
  • 1
svarog
  • 688
  • 1
  • 12
  • 29