2

Trying to start activity from service started at BOOT, but log shows how application dies (don't know why exactly) and restarts and tries again and again..

I've tried differents ways of starting activity, like

Intent newUserForm = new Intent(_context, NewUserForm.class);
newUserForm.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
_context.startActivity(newUserForm);

Why is my app dying (and restarting) and I'm not able to start activity from service? Thank you!!!!!!

Andro Selva
  • 53,910
  • 52
  • 193
  • 240
Mutenroshi
  • 21
  • 2
  • Perhaps you could post the log showing how your application dies? – Bjarke Freund-Hansen Jul 07 '11 at 09:44
  • ..: INFO/ActivityManager(72): Start proc Test_1.Android for service Test_1.Android/.BOOTService: pid=526 uid=10032 gids={3003} ..: WARN/ActivityManager(72): Timeout executing service: ServiceRecord{43a51c08 Test_1.Android/. BOOTService } ..: INFO/Process(72): Sending signal. PID: 526 SIG: 9 ..: INFO/ActivityManager(72): Process Test_1.Android (pid 526) has died. ..: WARN/ActivityManager(72): Scheduling restart of crashed service Test_1.Android/. BOOTService in 20000ms – Mutenroshi Jul 07 '11 at 10:40
  • service itself: new Intent(this, NewUserForm.class); || getApplicationContext() – Mutenroshi Jul 07 '11 at 10:41
  • 1
    solved, not really understanded :), probably a context theme... To solve problem, I started activity from BroadcastReceiver launched on BOOT ... `public void onReceive(Context context, Intent intent) { Intent newUserForm = new Intent(context, NewUserForm.class); newUserForm.setFlags(Intent.FLAG_FROM_BACKGROUND | Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(newUserForm); }` – Mutenroshi Jul 07 '11 at 10:56
  • possible duplicate of [android start activity from service](http://stackoverflow.com/questions/3606596/android-start-activity-from-service) – ForceMagic Jan 16 '15 at 14:49

2 Answers2

1

Broadcast one Intent from service and make sure you'll receive that Intent from your application side (broadcast receiver).

Reddy
  • 79
  • 1
  • 8
0

Set up a broadcast receiver, and start the service from there.

Hades
  • 3,916
  • 3
  • 34
  • 74