Firebase Storage OnSuccessListener is not working












0















I want to uploading image to the Firebase. For that I am using Firebase Storage OnSuccessListener. But OnSuccessListener is not working. It shows:




Cannot resolve symbol 'OnSuccessListener'




 private void startPosting(){

mProgess.setMessage("Uploading Quotes");
mProgess.show();

final String Quote_val = mPostQuote.getText().toString().trim();

final String Author_val = mPostAuthor.getText().toString().trim();

if (!TextUtils.isEmpty(Quote_val) && !TextUtils.isEmpty(Author_val) && mImageUri != null){

StorageReference filepath = mStorage.child("Quote_Image").child(mImageUri.getLastPathSegment());

filepath.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {

@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

Uri downloadUrl = taskSnapshot.getDownloadUrl();
DatabaseReference newPost = mDatbase.push();
newPost.child("Quotes").setValue(Quote_val);

newPost.child("Quote_Author").setValue(Author_val);
newPost.child("Images").setValue(downloadUrl);
mProgess.dismiss();

startActivity(new Intent(adminUpdateQuotesSend.this, QuoteList.class));
}
});
}
}


I am using:



implementation 'com.google.firebase:firebase-storage:9.2.0'









share|improve this question

























  • Add FailureListener also to check if there error.

    – Dhaval Patel
    Nov 15 '18 at 9:45











  • update your implementation 'com.google.firebase:firebase-storage:9.2.0' version to implementation 'com.google.firebase:firebase-storage:16.0.4' try with this one

    – Ali Ahmed
    Nov 15 '18 at 9:48













  • Please share the content of your both` build.gradle` files. Please also responde with @AlexMamo

    – Alex Mamo
    Nov 15 '18 at 9:59











  • You're using an old version of com.google.firebase:firebase-storage (released in 2017). You really should follow Get Started with Cloud Storage on Android and use the dependency version listed there (currently implementation 'com.google.firebase:firebase-storage:16.0.4').

    – Grimthorr
    Nov 15 '18 at 10:04













  • I am using 'com.google.firebase:firebase-storage:9.2.0' @AlexMamo

    – itz Prateek
    Nov 15 '18 at 10:13


















0















I want to uploading image to the Firebase. For that I am using Firebase Storage OnSuccessListener. But OnSuccessListener is not working. It shows:




Cannot resolve symbol 'OnSuccessListener'




 private void startPosting(){

mProgess.setMessage("Uploading Quotes");
mProgess.show();

final String Quote_val = mPostQuote.getText().toString().trim();

final String Author_val = mPostAuthor.getText().toString().trim();

if (!TextUtils.isEmpty(Quote_val) && !TextUtils.isEmpty(Author_val) && mImageUri != null){

StorageReference filepath = mStorage.child("Quote_Image").child(mImageUri.getLastPathSegment());

filepath.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {

@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

Uri downloadUrl = taskSnapshot.getDownloadUrl();
DatabaseReference newPost = mDatbase.push();
newPost.child("Quotes").setValue(Quote_val);

newPost.child("Quote_Author").setValue(Author_val);
newPost.child("Images").setValue(downloadUrl);
mProgess.dismiss();

startActivity(new Intent(adminUpdateQuotesSend.this, QuoteList.class));
}
});
}
}


I am using:



implementation 'com.google.firebase:firebase-storage:9.2.0'









share|improve this question

























  • Add FailureListener also to check if there error.

    – Dhaval Patel
    Nov 15 '18 at 9:45











  • update your implementation 'com.google.firebase:firebase-storage:9.2.0' version to implementation 'com.google.firebase:firebase-storage:16.0.4' try with this one

    – Ali Ahmed
    Nov 15 '18 at 9:48













  • Please share the content of your both` build.gradle` files. Please also responde with @AlexMamo

    – Alex Mamo
    Nov 15 '18 at 9:59











  • You're using an old version of com.google.firebase:firebase-storage (released in 2017). You really should follow Get Started with Cloud Storage on Android and use the dependency version listed there (currently implementation 'com.google.firebase:firebase-storage:16.0.4').

    – Grimthorr
    Nov 15 '18 at 10:04













  • I am using 'com.google.firebase:firebase-storage:9.2.0' @AlexMamo

    – itz Prateek
    Nov 15 '18 at 10:13
















0












0








0








I want to uploading image to the Firebase. For that I am using Firebase Storage OnSuccessListener. But OnSuccessListener is not working. It shows:




Cannot resolve symbol 'OnSuccessListener'




 private void startPosting(){

mProgess.setMessage("Uploading Quotes");
mProgess.show();

final String Quote_val = mPostQuote.getText().toString().trim();

final String Author_val = mPostAuthor.getText().toString().trim();

if (!TextUtils.isEmpty(Quote_val) && !TextUtils.isEmpty(Author_val) && mImageUri != null){

StorageReference filepath = mStorage.child("Quote_Image").child(mImageUri.getLastPathSegment());

filepath.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {

@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

Uri downloadUrl = taskSnapshot.getDownloadUrl();
DatabaseReference newPost = mDatbase.push();
newPost.child("Quotes").setValue(Quote_val);

newPost.child("Quote_Author").setValue(Author_val);
newPost.child("Images").setValue(downloadUrl);
mProgess.dismiss();

startActivity(new Intent(adminUpdateQuotesSend.this, QuoteList.class));
}
});
}
}


I am using:



implementation 'com.google.firebase:firebase-storage:9.2.0'









share|improve this question
















I want to uploading image to the Firebase. For that I am using Firebase Storage OnSuccessListener. But OnSuccessListener is not working. It shows:




Cannot resolve symbol 'OnSuccessListener'




 private void startPosting(){

mProgess.setMessage("Uploading Quotes");
mProgess.show();

final String Quote_val = mPostQuote.getText().toString().trim();

final String Author_val = mPostAuthor.getText().toString().trim();

if (!TextUtils.isEmpty(Quote_val) && !TextUtils.isEmpty(Author_val) && mImageUri != null){

StorageReference filepath = mStorage.child("Quote_Image").child(mImageUri.getLastPathSegment());

filepath.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {

@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

Uri downloadUrl = taskSnapshot.getDownloadUrl();
DatabaseReference newPost = mDatbase.push();
newPost.child("Quotes").setValue(Quote_val);

newPost.child("Quote_Author").setValue(Author_val);
newPost.child("Images").setValue(downloadUrl);
mProgess.dismiss();

startActivity(new Intent(adminUpdateQuotesSend.this, QuoteList.class));
}
});
}
}


I am using:



implementation 'com.google.firebase:firebase-storage:9.2.0'






android firebase firebase-storage






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 14:16









Frank van Puffelen

239k29382408




239k29382408










asked Nov 15 '18 at 9:41









itz Prateekitz Prateek

349




349













  • Add FailureListener also to check if there error.

    – Dhaval Patel
    Nov 15 '18 at 9:45











  • update your implementation 'com.google.firebase:firebase-storage:9.2.0' version to implementation 'com.google.firebase:firebase-storage:16.0.4' try with this one

    – Ali Ahmed
    Nov 15 '18 at 9:48













  • Please share the content of your both` build.gradle` files. Please also responde with @AlexMamo

    – Alex Mamo
    Nov 15 '18 at 9:59











  • You're using an old version of com.google.firebase:firebase-storage (released in 2017). You really should follow Get Started with Cloud Storage on Android and use the dependency version listed there (currently implementation 'com.google.firebase:firebase-storage:16.0.4').

    – Grimthorr
    Nov 15 '18 at 10:04













  • I am using 'com.google.firebase:firebase-storage:9.2.0' @AlexMamo

    – itz Prateek
    Nov 15 '18 at 10:13





















  • Add FailureListener also to check if there error.

    – Dhaval Patel
    Nov 15 '18 at 9:45











  • update your implementation 'com.google.firebase:firebase-storage:9.2.0' version to implementation 'com.google.firebase:firebase-storage:16.0.4' try with this one

    – Ali Ahmed
    Nov 15 '18 at 9:48













  • Please share the content of your both` build.gradle` files. Please also responde with @AlexMamo

    – Alex Mamo
    Nov 15 '18 at 9:59











  • You're using an old version of com.google.firebase:firebase-storage (released in 2017). You really should follow Get Started with Cloud Storage on Android and use the dependency version listed there (currently implementation 'com.google.firebase:firebase-storage:16.0.4').

    – Grimthorr
    Nov 15 '18 at 10:04













  • I am using 'com.google.firebase:firebase-storage:9.2.0' @AlexMamo

    – itz Prateek
    Nov 15 '18 at 10:13



















Add FailureListener also to check if there error.

– Dhaval Patel
Nov 15 '18 at 9:45





Add FailureListener also to check if there error.

– Dhaval Patel
Nov 15 '18 at 9:45













update your implementation 'com.google.firebase:firebase-storage:9.2.0' version to implementation 'com.google.firebase:firebase-storage:16.0.4' try with this one

– Ali Ahmed
Nov 15 '18 at 9:48







update your implementation 'com.google.firebase:firebase-storage:9.2.0' version to implementation 'com.google.firebase:firebase-storage:16.0.4' try with this one

– Ali Ahmed
Nov 15 '18 at 9:48















Please share the content of your both` build.gradle` files. Please also responde with @AlexMamo

– Alex Mamo
Nov 15 '18 at 9:59





Please share the content of your both` build.gradle` files. Please also responde with @AlexMamo

– Alex Mamo
Nov 15 '18 at 9:59













You're using an old version of com.google.firebase:firebase-storage (released in 2017). You really should follow Get Started with Cloud Storage on Android and use the dependency version listed there (currently implementation 'com.google.firebase:firebase-storage:16.0.4').

– Grimthorr
Nov 15 '18 at 10:04







You're using an old version of com.google.firebase:firebase-storage (released in 2017). You really should follow Get Started with Cloud Storage on Android and use the dependency version listed there (currently implementation 'com.google.firebase:firebase-storage:16.0.4').

– Grimthorr
Nov 15 '18 at 10:04















I am using 'com.google.firebase:firebase-storage:9.2.0' @AlexMamo

– itz Prateek
Nov 15 '18 at 10:13







I am using 'com.google.firebase:firebase-storage:9.2.0' @AlexMamo

– itz Prateek
Nov 15 '18 at 10:13














1 Answer
1






active

oldest

votes


















0














You can use CompletionListener:



filepath.putFile(mImageUri, new DatabaseReference.CompletionListener() {
void onComplete(DatabaseError error, DatabaseReference ref) {
if(error==null){
//success
}
}
});





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53316459%2ffirebase-storage-onsuccesslistener-is-not-working%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You can use CompletionListener:



    filepath.putFile(mImageUri, new DatabaseReference.CompletionListener() {
    void onComplete(DatabaseError error, DatabaseReference ref) {
    if(error==null){
    //success
    }
    }
    });





    share|improve this answer




























      0














      You can use CompletionListener:



      filepath.putFile(mImageUri, new DatabaseReference.CompletionListener() {
      void onComplete(DatabaseError error, DatabaseReference ref) {
      if(error==null){
      //success
      }
      }
      });





      share|improve this answer


























        0












        0








        0







        You can use CompletionListener:



        filepath.putFile(mImageUri, new DatabaseReference.CompletionListener() {
        void onComplete(DatabaseError error, DatabaseReference ref) {
        if(error==null){
        //success
        }
        }
        });





        share|improve this answer













        You can use CompletionListener:



        filepath.putFile(mImageUri, new DatabaseReference.CompletionListener() {
        void onComplete(DatabaseError error, DatabaseReference ref) {
        if(error==null){
        //success
        }
        }
        });






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 '18 at 10:55









        ManishPrajapatiManishPrajapati

        221314




        221314
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53316459%2ffirebase-storage-onsuccesslistener-is-not-working%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine