public void uploadpicture(View view)
{
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), SELECT_PICTURE);
}
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode == RESULT_OK)
{
if (requestCode == SELECT_PICTURE)
{
Uri selectedImageUri = data.getData();
selectedImagePath = getPath(selectedImageUri);
Toast.makeText(this,selectedImagePath,Toast.LENGTH_SHORT).show();
Log.i("selectedImagePath",selectedImagePath.trim());
}
}
}
I got the this from Log-cat:
05-24 15:57:51.054: E/AndroidRuntime(18016): FATAL EXCEPTION: main
05-24 15:57:51.054: E/AndroidRuntime(18016): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://com.android.sec.gallery3d.provider/picasa/item/5147009501910019474 }} to activity {ncpl.talentapp/ncpl.talentapp.SignUp}: java.lang.NullPointerException
05-24 15:57:51.054: E/AndroidRuntime(18016): at android.app.ActivityThread.deliverResults(ActivityThread.java:2821)
05-24 15:57:51.054: E/AndroidRuntime(18016): at android.app.ActivityThread.handleSendResult(ActivityThread.java:2864)
05-24 15:57:51.054: E/AndroidRuntime(18016): at android.app.ActivityThread.access$1000(ActivityThread.java:122)
05-24 15:57:51.054: E/AndroidRuntime(18016): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1057)
05-24 15:57:51.054: E/AndroidRuntime(18016): at android.os.Handler.dispatchMessage(Handler.java:99)
05-24 15:57:51.054: E/AndroidRuntime(18016): at android.os.Looper.loop(Looper.java:132)
05-24 15:57:51.054: E/AndroidRuntime(18016): at android.app.ActivityThread.main(ActivityThread.java:4126)
05-24 15:57:51.054: E/AndroidRuntime(18016): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 15:57:51.054: E/AndroidRuntime(18016): at java.lang.reflect.Method.invoke(Method.java:491)
05-24 15:57:51.054: E/AndroidRuntime(18016): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
05-24 15:57:51.054: E/AndroidRuntime(18016): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
05-24 15:57:51.054: E/AndroidRuntime(18016): at dalvik.system.NativeStart.main(Native Method)
05-24 15:57:51.054: E/AndroidRuntime(18016): Caused by: java.lang.NullPointerException
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…