FAQ Database Discussion Community


Android Alarm not triggered after finishing

android,alarm,ondestroy
My alarm doesn't trigger when I finish the activity before. When I just stay in the activity, the alarm works fine. Here's the code: AlarmManager alarms = (AlarmManager)getApplicationContext().getSystemService(Context.ALARM_SERVICE); final BroadcastReceiver receiver_daily = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "DAILY BONUS"); String title = getResources().getString(R.string.playreminder_daily_title);...

Registering “onDestroy event handler” with Android Activity

android,android-activity,ondestroy,eventhandler
Let's say I have a library object which needs to be notified of an Activity.onDestroy() event if it happens. Is there a way that I can register some sort of handler with the Activity from inside the library or will I need to require anyone using the library to override...

Scope not being removed

angularjs,controller,angularjs-scope,ondestroy
Using angular 1.2.9 Explanation of what is working: I have a list on the left of the webpage where a user can press + button to append a view to the .viewSpace. When the user presses + angular.element(document.getElementById('viewSpace')).append($compile("<div my-graph></div>")(scope)); is called. my-graph is a directive that uses a template which...

Android - destroying service on calling stopService

android,service,ondestroy
I have a background service that I start and stop using startService() and stopService() when the respective buttons are pressed on the UI ("connect" and "disconnect" respectively). I perform a lot of clean up operations when the service is stopped, and I put those in the service's onDestroy() assuming that...

How to set speaker phone off when the app is killed by the “Recent App drawer”

android,android-audiomanager,ondestroy
I implemented an app which has a button speaker, which is manually set "on" by myAudioManager.setSpeakerphoneOn(true) and "off" vice-versa. But the bug is when you close the application while the speaker is on, it forgets the speaker was on. The next time, the speaker remains on and the call is...

Android Fragment onCreateView after onDestroy not called again

android,fragment,lifecycle,ondestroy
According to the Android fragment lifecycle i would expect that after onDestroy the fragment will be recreated, or at least onCreateView is called again. I have an Activity A starting another Activity B for result and Activity B creating a fragment F. public class A extends FragmentActivity { ... public...