Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: stopService in another Activity

How can I stop my Service in another Activity?

I start the service in my summaryActivity

SocketServiceIntent = new Intent(this, SocketService.class);
SocketServiceIntent.putExtra("MessageParcelable", mp);
startService(SocketServiceIntent);

And start my statusActivity from my summaryActivity

Intent intent = new Intent(SummaryActivity.this,
                StatusActivity.class);
intent.putExtra("MessageParcelable", mp);
startActivity(intent);

My problem is that I don't know how I can give my Statusactivity the SocketServiceIntent.

like image 410
user1263776 Avatar asked Mar 12 '12 10:03

user1263776


1 Answers

You should call Activity(ContextWrapper)#stopService:

stopService(new Intent(SummaryActivity.this, SocketService.class));
like image 62
MByD Avatar answered Oct 06 '22 07:10

MByD