I am passing value through Bundle as you can see in my code.
Now, I want its value in another activity onCreate()
. I tried it to get its value but it is showing nullpointerexception.
Please help me solve the problem.
Bundle bundle = new Bundle();
String url = "http://www.google.com";
bundle.putString("url", url);
Intent myIntent = new Intent(context, NotificationService.class);
myIntent.putExtras(bundle);
context.startService(myIntent);
Get Value code :
if (!getIntent().getExtras().getString("url").contains(null)) {
// Do something
}
you have to check against null values
This should be the procedure.
Create a new Intent with bundle and start the activity.
Take the bundle like this in new Activity inside onCreate
Hi i hope this code helps you.
In MyActivity.class
Try adding this inside
NotificationService.class
: