benbahrenburg / benCoding.AlarmManager

Titanium Module for working with the Android AlarmManager
Other
98 stars 85 forks source link

crashed no valid root or current activity #55

Closed sschua74 closed 9 years ago

sschua74 commented 9 years ago

Is there any way to require and create alarm manager directly in service. It used to work on ver 0.5 but not on 0.11. It will crash. Thanks

adampax commented 9 years ago

Having this issue as well. Using v0.11, when the the app is no longer in background, and the service creates a new alarmmanager, this error is thown when TiApplication.getAppRootOrCurrentActivity() returns null.

[ERROR] : TiApplication: (KrollRuntimeThread) [182,61570] No valid root or current activity found for application instance
[ERROR] : KrollProxy: (KrollRuntimeThread) [3,61573] Error creating proxy
[ERROR] : KrollProxy: java.lang.NullPointerException
[ERROR] : KrollProxy: at bencoding.alarmmanager.AlarmManagerProxy.(AlarmManagerProxy.java:35)

As a workaround, you can revert to v0.10, and then use setRootActivityClassName() mentioned here.

benbahrenburg commented 9 years ago

@adampax try v0.12. If setting from the background please remember to call setRootActivityClassName to provide your root activity name.

adampax commented 9 years ago

@benbahrenburg Thanks Ben. I installed 0.123 and everything looks good. I do still get the No valid root or current activity error even while using setRootActivityClassName, but its not an issue since you are catching it.

I was in the process of putting together a PR that would move the setting of rootActivityClassName to onStart so we would:

  1. No longer get a null value from getAppRootOrCurretnActivity() when running from background or
  2. No longer need to set setRootActivityClassName()

If that would be useful, I'll update the code with your latest changes and submit. The only issue I can think of is if there could be a case where someone would need to use a different root activity class name than what is coming from TiApplication?