Click here to Skip to main content
15,670,081 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hey ,
I am currently working on an android application that involves closing an activity from a service. Any help on this matter is appreciated. Thanks.
Updated 20-Mar-16 21:07pm
Sandeep Mewara 24-Oct-12 10:58am    
What kind of help you are expecting of?
You went through this:
KASI KARUPPIAH 24-Oct-12 13:36pm    
Thanks man i already surfed through the page

what i really want to accomplish is

say i have a background service X and an activity A . I'd like to kill activity A from service X. How to accomplish this ....

1 solution

Add a broadcast receiver inside the activity.
public class AnActivity extends Activity {
	protected void onCreate(Bundle savedInstanceState) {
       registerReceiver(mMessageReceiver, new IntentFilter("fgsdgdfgg"));

   private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {

		public void onReceive(Context context, Intent intent) {


	public void onDestroy() {

Send broadcast from service and in
method call

inside service handleintent method do as follows-
Intent intent1 = new Intent("fgsdgdfgg");
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900