I have a bottom bar. And It has a camera icon. When I click the icon. It shows me a dialog. This dialog has 3 buttons. These are camera request, gallery request and cancel. I take a photo with camera request to doing that I used to intent. And I press commit button ( in emulator default button). But It gives me an exception. My purpose is: I want to send that taken photo to other activity. Then set it to my image view. How can I do that?
Here is my commit button : enter image description here
my Logcat :
05-20 15:25:01.635 2653-2653/something.about.berkay.isim E/AndroidRuntime: FATAL EXCEPTION: main
Process: something.about.berkay.isim, PID: 2653
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1888, result=-1, data=Intent { act=inline-data (has extras) }} to activity {something.about.berkay.isim/something.about.berkay.isim.bottom_bar}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:3365)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3408)
at android.app.ActivityThread.access$1300(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at something.about.berkay.isim.bottom_bar.onActivityResult(bottom_bar.java:186)
at android.app.Activity.dispatchActivityResult(Activity.java:5423)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3361)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3408)
at android.app.ActivityThread.access$1300(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Here is my code :
private static final int CAMERA_REQUEST = 1888;
private void openCamera() {
Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePicture, CAMERA_REQUEST);
try {
/* camera.takePicture();*/
dialog.dismiss();
}catch (Exception e){
e.printStackTrace();
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode){
case GALLERY_REQUEST : if(resultCode == RESULT_OK){ //gallery için 1
Uri selectedImage = data.getData();
// deneme.setImageURI(selectedImage);
}break;
case CAMERA_REQUEST : if (resultCode == RESULT_OK){
Uri selectedImage = data.getData();
Intent i = new Intent(bottom_bar.this , fotograf_cekildikten_sonra_kaydet_iptal_yeri.class);
i.putExtra("dene " ,selectedImage);
startActivity(i);
}
}
Other my activity :
setContentView(R.layout.fotograf_cekildikten_sonra_kaydet_iptal_yeri);
Bundle extras = getIntent().getExtras();
Uri uri = extras.getParcelableExtra("dene");
ımageView = (ImageView)findViewById(R.id.telefon_arama_ImageView);
ımageView.setImageResource(uri);