0

Activity 1:

ImageView image=(ImageView)findViewById(R.id.imageicon);

in.putExtra("image",R.id.imageicon);

Activity 2 :

int RecipeImage = in.getIntExtra("image",0);

ImageView imageview=(ImageView)findViewById(R.id.imageView1);

imageview.setImageResource(RecipeImage);

Issues :

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.wireframe/com.example.wireframe.singlemenuitem}: java.lang.NullPointerException

jimpanzer
  • 3,470
  • 4
  • 44
  • 84
  • possible duplicate of [Passing image from one activity another activity](http://stackoverflow.com/questions/11519691/passing-image-from-one-activity-another-activity) – Raghunandan May 03 '13 at 13:23
  • It seems that something has not been initialized correctly in activity 2. Please provide the full stack trace and more code – Alexis C. May 03 '13 at 13:24
  • your `in` is null in the secondActivity...Post your complete stack trace and also check whether intent extra is null or not before accessing it. – Pragnani May 03 '13 at 13:26
  • Also: image resources are `R.drawable`s, not `R.id` identifiers. – laalto May 03 '13 at 14:00
  • post more code, the complete stacktrace, and indicate at which line the issue occurs – njzk2 May 03 '13 at 14:56
  • check this out http://stackoverflow.com/questions/2459524/how-can-i-pass-a-bitmap-object-from-one-activity-to-another – Qadir Hussain May 03 '13 at 15:35

1 Answers1

0

If you want the same image in two different activities, why not load the image for each activity? BTW you get the drawable in this way:

Drawable drawable =  this.getResources().getDrawable(R.drawable.yourImage);
n3k0
  • 577
  • 14
  • 40