-1

I have a little problem in service (android). In my code what i am doing exactly...first i send data through intent to service.

Intent i = new Intent(getApplicationContext(), External.class);
i.putExtra("data",data);
i.setAction(External.ACTION_PLAY);
getApplicationContext().startService(i);

Then in method onStartCommand() i receive that data.

Bundle b=i.getExtras();
data=i.getStringExtra("data");

So in notificationbar with action_play by onPlay() method we get actual data.

Toast.makeText(getApplicationContext(),"I get your message"+ data,Toast.LENGTH_LONG).show();

Then, when i again try to receive that data by with acton_pause by onPause() method i get null, i mean" I get your message null." every time i get that, i initialize every thing make them all static one by one and together but i got null.i am putting my initialization code here ,check that and help me to solve it......

In activity

private static  String data="music is mine";

In External service

private static String data="";

Thanks in advance.

Allan Pereira
  • 2,572
  • 4
  • 21
  • 28
BK MEN
  • 1
  • 1

1 Answers1

0

From information you attached to the problem I could not reproduce an issue. Maybe you are using wrong intent or have more "data" variables?

rafaltra
  • 36
  • 5