This is my code.Don't understand how to solve it.Saw many codes but failed. So posting it here.
storageReference = FirebaseStorage.getInstance().getReference();
progressDialog = new ProgressDialog(this);
select.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent,CAMERA_REQUEST_CODE);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == CAMERA_REQUEST_CODE && resultCode == RESULT_OK)
{
progressDialog.setMessage("Uploading picture");
progressDialog.show();
Uri uri = data.getData();
StorageReference filePath = storageReference.child("Photos").child(uri.getLastPathSegment());
//StorageReference filepath = storageReference.child("CapturedPhotos").child(uri.getLastPathSegment());
filePath.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
progressDialog.dismiss();
// Uri downloadUri = taskSnapshot.getDownloadUrl();
// Picasso.with(Storage_Capture_Picture.this).load(downloadUri).fit().centerCrop().into(imageView);
Toast.makeText(Storage_Capture_Picture.this,"Uploaded",Toast.LENGTH_SHORT).show();
}
});
}
LogCat
11-26 14:57:07.953 2912-2912/com.a.firebaseapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.a.firebaseapp, PID: 2912 java.lang.RuntimeException: Unable to resume activity {com.a.firebaseapp/com.a.firebaseapp.Storage_Capture_Picture}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { act=inline-data (has extras) }} to activity {com.a.firebaseapp/com.a.firebaseapp.Storage_Capture_Picture}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2786) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2815) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2248) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3736) at android.app.ActivityThread.access$900(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5019) 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.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { act=inline-data (has extras) }} to activity {com.a.firebaseapp/com.a.firebaseapp.Storage_Capture_Picture}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:3363) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2773) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2815) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2248) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3736) at android.app.ActivityThread.access$900(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5019) 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 com.a.firebaseapp.Storage_Capture_Picture.onActivityResult(Storage_Capture_Picture.java:64) at android.app.Activity.dispatchActivityResult(Activity.java:5423) at android.app.ActivityThread.deliverResults(ActivityThread.java:3359)
I am trying to make an app using fire-base storage that will capture image and store it to my fire-base storage.
When I run my app,it runs fine.I move to camera to capture image and I select okay button and it shows me unfortunately stopped.
I added all the permissions and gradle file to build.Shows me this two errors
java.lang.NullPointerException
java.lang.RuntimeException: Unable to resume activity