Reputation: 148
hello guys can any one tell me how to send data from broad cast to service and how to receive this data inside the service class because it dose not work with me shuld i receive it inside ((onStartCommand)) or ((onStart)) or inside ((onReceive)) and what i should do in the Maninafest
String data="hello";
Intent intent1=new Intent(context,Myservice.class);
intent1.putExtra("Data",data);
context.startService(intent1);
//when i receive data from broad cast
public int onStartCommand(Intent intent, int flags, int startId) {
String data="";
data=intent.getStringExtra("Phone");
Toast.makeText(this,"here is your data"+data, Toast.LENGTH_LONG).show();
}
Upvotes: 0
Views: 1350
Reputation: 3454
replace
data=intent.getStringExtra("Phone");
to data=intent.getStringExtra("Data");
Upvotes: 1