• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

App Inventor Android Firebase - help

Code:
Toast.makeText(PostActivity.this, "Loading...", Toast.LENGTH_SHORT).show();
final String postTitle = "PostTitle";
final String postDescription = "PostDescription";
StorageReference filepath = storage.child("post_image").child(uri.getLastPathSegment());
filepath.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
    [USER=1021285]@override[/USER]
    public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
        final Uri downloadUri = taskSnapshot.getDownloadUrl();
        Toast.makeText(PostActivity.this, "Uploaded Succesful", Toast.LENGTH_SHORT).show();
        final DatabaseReference newPost = databaseReference.push();
        mDatabaseUsers.addValueEventListener(new ValueEventListener() {
            [USER=1021285]@override[/USER]
            public void onDataChange(DataSnapshot dataSnapshot) {
                newPost.child("title").setValue(postTitle);
                newPost.child("description").setValue(postDescription);
                newPost.child("imageURL").setValue(downloadUri.toString());
                newPost.child("uid").setValue(mCurrentUser.getUid());
                newPost.child("username").setValue(dataSnapshot.child("name").getValue()).addOnCompleteListener(new OnCompleteListener<Void>() {
                    [USER=1021285]@override[/USER]
                    public void onComplete(@NonNull Task<Void> task) {
                        if (task.isComplete()) {
                            Intent mainIntent = new Intent(PostActivity.this,MainActivity.class);
                            startActivity(mainIntent);
                        }
                    }
                });
            }

            [USER=1021285]@override[/USER]
            public void onCancelled(DatabaseError databaseError) {
                Toast.makeText(PostActivity.this, "Canceled", Toast.LENGTH_SHORT).show();
            }
        });
    }
});

i have this code in my app, i want to upload post to firebase (image, title, description), in final to firebase was uploaded only image, but mDatabaseUsers.addValueEventListener.. not be executed, can anyone help me?
 
Last edited by a moderator:
Back
Top Bottom