Reputation: 13302
I am trying to send bundle data from my service to my activity, the url and id is not working only the bitmap, works. I can't figured out why ?
Service class :
String imgUrl = ".....img1.jpg";
String imageId = "111";
// Construct pending intent to serve as action for notification item
Intent intent = new Intent(this, ImagePreviewActivity.class);
intent.putExtra("url", imgUrl);
intent.putExtra("id", imageId);
intent.putExtra("bitmap", resizedBitmap);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
ImagePreviewActivity:
Bundle extras = getIntent().getExtras();
if(extras != null)
{
imgUrl = extras.getString("url");
imgId = getIntent().getStringExtra("id");
mBitmap = getIntent().getParcelableExtra("bitmap");
Log.i(TAG, "Bundle ->> imgUrl => " + imgUrl + " | imgId => " + imgId);
//setImageToCarViewFromUrl(imgUrl);
setImageToCarViewFromBitmap(mBitmap);
}
else if(getIntent().getParcelableExtra("bitmap") != null)
{
mBitmap = getIntent().getParcelableExtra("bitmap");
setImageToCarViewFromBitmap(mBitmap);
}
else
{
//Image not Ready
dialogImagesNotReady(false);
}
Result : Bundle ->> imgUrl => null | imgId => null
Only mBitmap is working !
Upvotes: 1
Views: 636
Reputation: 387
I think you did put String not a Bundle. You should call
getIntent().getStringExtra("your key");
if you want bundle (value on getIntent().getExtras()), you should put it in a Bundle class
Bundle bundle = new Bundle();
bundle.putString("key","value");
intent.putExtra("key",bundle)
Upvotes: 1