1

I am creating one app with two activities, an image will load and shows in another activity,

this is my LogCat error, http://pastebin.com/BvLtcdz0

This is MainActivity.java code http://pastebin.com/9F1sNr8B

2 Answers2

1

getAssets() needs a context which you don't have until you call onCreate() move

 AssetManager assetManager = getAssets();

into onCreate()

Images can be sent through Intents but it is better to save a file path and send the path then open from file with a String path sent through the Intent

codeMagic
  • 44,549
  • 13
  • 77
  • 93
  • 1
    Okay Uncle I will try it :) – Yhal Htet Aung May 03 '13 at 01:03
  • 1
    Ok, but I have to ask...why do you keep calling me uncle? – codeMagic May 03 '13 at 01:04
  • 1
    Hi uncle, can go to other activity but it is not loading :) Aww because you are older than me uncle that is why I keep calling you uncle, not only to you, people who are older than me are aunties and uncles :) – Yhal Htet Aung May 03 '13 at 01:07
  • 1
    Ok, just had to ask because I was curious. Read my edit. There are posts from Google developers as to why this is best and I can try and post a link when I have time but you should try and do it that way. Otherwise, post on here or new post what the error you get now. Or check the link that @HalIR posted...it seems to have the answer to your problem now after fixing your original problem – codeMagic May 03 '13 at 01:10
  • Ok Uncle I will do it, I am searching and coding the whole day and haven't slept yet, btw thank you so much :) – Yhal Htet Aung May 03 '13 at 01:12
  • 1
    You are welcome. Also, I know its hard to quit thinking about your problem (I still dream about programming) but no matter what deadlines are, usually it is good to walk away for awhile. You will be amazed at the problems you can solve when you take a little break. – codeMagic May 03 '13 at 01:14
1

You can't do it directly, you need to convert it to a bitmap first

yourImageView.buildDrawingCache();
Bitmap passedBitmap = imageView.getDrawingCache();

Intent intent = new Intent(this, YourOtherActivity.class;
Intent.putExtra("passedBitmap", passedBitmap);

startActivity(intent);

then load it back up in your other activity

Bitmap bitmap = (Bitmap) intent.getParcelableExtra("passedBitmap");

Found a similar question (maybe dupe)

Community
  • 1
  • 1
HalR
  • 11,411
  • 5
  • 48
  • 80