In Activity i have passed a value paramVal like this
Intent srv = new Intent(this, TestService.class);
startService(srv);
//Intent intent =new Intent("com.example.firstapplication.STARTACTIVITY");
//intent.putExtra("myFirstKey", paramVal);
//intent.putExtra("myFirstKey", paramVal);
Bundle bundle = new Bundle();
bundle.putCharSequence("myFirstKey", paramVal);
intent.putExtras(bundle);
and in service I am retrieving a value like this
@Override
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
Bundle bundle = intent.getExtras();
data = (String) bundle.getCharSequence("myFirstKey");
System.out.println("data checking"+data);
}
but i am getting null pointer exception for the line
data = (String) bundle.getCharSequence("myFirstKey");
in service
should i have to call onstart method in service somewhere. Please let me know where is the problem??
In your Activity:
In your Service:
As a sidenote: