Reputation: 4115
I have two applications. One is a receiver and its starting my application. It works fine. Now i want destroy my application from the receiver itself. Is that possible ? Please note that these are my own application
Upvotes: 1
Views: 74
Reputation: 7892
It is possible but the activity has to finish itself using the finish()
-method.
You can register an activity to a receiver using registerReceiver(..)
and handle your logic in your activity. Don't forget to unregisterReceiver(...)
inside the OnDestroy.
Example:
BroadcastReceiver mReceiver;
@Overrride
public void onCreate(Bundle savedInstanceState){
IntentFilter filter = new IntentFilter();
filter.addAction(...);
mReceiver= new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// implement logic
finish();
}
}
registerReceiver(mReceiver, filter);
}
Upvotes: 2
Reputation: 10190
you cant directly control the lifecycle of one activity from another actvity alternates to this could be :
finish()' in
run()`finish()
the new activity on some events with EventListeners Upvotes: 0