Reputation: 3771
My bundle is returning null strings for the contained extras. Not NPEs, actual "null" values. Any ideas on why this would be happening?
new bundle
String u = null;
Bundle b = new Bundle();
Intent i = new Intent(view.getContext(), ******.class);
u = api.companyData.link.get(position);
Log.d("URL++++++++++++++++++++", u);
b.putString("graphic", api.companyData.graphic);
b.putString("name", api.companyData.name);
b.putString("url", u);
i.putExtras(b);
startActivity(i);
The log statement is returning the url fine.
Receiver of bundle
Bundle extras = getIntent().getExtras();
if(extras !=null) {
Log.d("EXTRAS", extras.getString("name")+extras.getString("graphic")+extras.getString("link"));
D/EXTRAS ( 4698): nullnullnull
Upvotes: 1
Views: 2587
Reputation: 15137
put the objects in the intent directly, e.g.
Intent i = new Intent(view.getContext(), ******.class);
i.putExtra("graphic", ...);
i.putExtra("name", ...);
i.putExtra("url", ....);
Then in the receiver activity:
getIntent().getStringExtra("graphic");
getIntent().getStringExtra("name");
getIntent().getStringExtra("url");
Upvotes: 1
Reputation: 31045
I always do it this way:
Intent i = new Intent(view.getContext(), ******.class);
i.putExtra("url", u);
and then
String url = getIntent().getStringExtra("url");
I've never tried it your way, but if you look at the Android docs for putExtras(Bundle)
, it says:
Add a set of extended data to the intent. The keys must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
That you're not doing that may be the reason for the failure.
Upvotes: 1