3 Replies - 494 Views - Last Post: 03 June 2014 - 02:45 PM

#1 sami1818   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 02-June 14

I want to load image from sd card and show it to another activity

Posted 02 June 2014 - 03:11 PM

@Override
	    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	    	super.onActivityResult(requestCode, resultCode, data);
	    	
			if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
				Uri selectedImage = data.getData();
				String[] filePathColumn = { MediaStore.Images.Media.DATA };

				Cursor cursor = getContentResolver().query(selectedImage,
						filePathColumn, null, null, null);
				cursor.moveToFirst();

				int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
				String picturePath = cursor.getString(columnIndex);
				cursor.close();
				
				ImageView imageView10 = (ImageView) findViewById(R.id.imageView10);
				imageView10.setImageBitmap(BitmapFactory.decodeFile(picturePath));



i used this code but it show me force close error.

This post has been edited by macosxnerd101: 02 June 2014 - 06:02 PM
Reason for edit:: Please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: I want to load image from sd card and show it to another activity

#2 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12305
  • View blog
  • Posts: 45,400
  • Joined: 27-December 08

Re: I want to load image from sd card and show it to another activity

Posted 02 June 2014 - 06:05 PM

Moved to Android.

If the app is force closing, there is an error on your LogCat which will tell you more. Please post it.
Was This Post Helpful? 0
  • +
  • -

#3 sami1818   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 02-June 14

Re: I want to load image from sd card and show it to another activity

Posted 03 June 2014 - 01:24 AM

06-03 14:22:24.738: E/AndroidRuntime(294): FATAL EXCEPTION: main
06-03 14:22:24.738: E/AndroidRuntime(294): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2, result=-1, data=Intent { dat=content://media/external/images/media/1 }} to activity {com.example.fatwallet/com.example.fatwallet.Create_adds_Activity}: java.lang.NullPointerException
06-03 14:22:24.738: E/AndroidRuntime(294): at android.app.ActivityThread.deliverResults(ActivityThread.java:3515)
06-03 14:22:24.738: E/AndroidRuntime(294): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3557)
06-03 14:22:24.738: E/AndroidRuntime(294): at android.app.ActivityThread.access$2800(ActivityThread.java:125)
06-03 14:22:24.738: E/AndroidRuntime(294): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2063)
06-03 14:22:24.738: E/AndroidRuntime(294): at android.os.Handler.dispatchMessage(Handler.java:99)
06-03 14:22:24.738: E/AndroidRuntime(294): at android.os.Looper.loop(Looper.java:123)
06-03 14:22:24.738: E/AndroidRuntime(294): at android.app.ActivityThread.main(ActivityThread.java:4627)
06-03 14:22:24.738: E/AndroidRuntime(294): at java.lang.reflect.Method.invokeNative(Native Method)
06-03 14:22:24.738: E/AndroidRuntime(294): at java.lang.reflect.Method.invoke(Method.java:521)
06-03 14:22:24.738: E/AndroidRuntime(294): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-03 14:22:24.738: E/AndroidRuntime(294): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-03 14:22:24.738: E/AndroidRuntime(294): at dalvik.system.NativeStart.main(Native Method)
06-03 14:22:24.738: E/AndroidRuntime(294): Caused by: java.lang.NullPointerException
06-03 14:22:24.738: E/AndroidRuntime(294): at com.example.fatwallet.Create_adds_Activity.onActivityResult(Create_adds_Activity.java:109)
06-03 14:22:24.738: E/AndroidRuntime(294): at android.app.Activity.dispatchActivityResult(Activity.java:3890)
06-03 14:22:24.738: E/AndroidRuntime(294): at android.app.ActivityThread.deliverResults(ActivityThread.java:3511)
06-03 14:22:24.738: E/AndroidRuntime(294): ... 11 more

this is my log cat
Was This Post Helpful? 0
  • +
  • -

#4 sami1818   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 02-June 14

Re: I want to load image from sd card and show it to another activity

Posted 03 June 2014 - 02:45 PM

please any one solve my problem. I want to submit my code on comming friday and i face this problem for last few days:-(
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1