android - Start and Close single Activity from BroadcastReceiver -


in application have 1 broadcast receiver of power cable plug , unplug.

while power cable plug service start , service start activity , when power cable unplug service stop , opened activity should closed.

i have start activity can't close.

if have solution please help

you try directly kill activity calling static method in activity:

activity should have variable  static activitya activitya; 

in oncreate state:

activitya = this; 

and add method:

public static activitya getinstance(){     return   activitya;  } 

in activity b, call fuction getinstance()

activitya.getinstance().finish();