Hello people from StackOverflow.
I am a student of an Android course and in classes we started to see how to work with Firebase. The fact is that I have managed to get my application to play a series of mp3 audio from the database, but now I would like to share it in another application, for this I have done this:
this.stRef = FirebaseStorage.getInstance().getReference().child("audios/nombredelaudio.mp3");
File localFile = null;
try {
localFile = File.createTempFile("nombreaudio", ".mp3");
audiotempdescargado = localFile.getPath();
} catch (IOException e) {
e.printStackTrace();
}
stRef.getFile(localFile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(getContext(),"creado",Toast.LENGTH_LONG).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
Toast.makeText(getContext(),"fallo al crear"+exception,Toast.LENGTH_LONG).show();
}
});
So far more or less well, I have been able to verify that the app downloads a temporary file while browsing from Android Studio, but when you pass it to another application with this method, it does not transfer anything:
Uri uri = Uri.parse(audiotempdescargado);
Intent share = new Intent(Intent.ACTION_SEND,uri);
share.setType("audio/*");
c.startActivity(Intent.createChooser(share,"Compartir sonido en: "));
}
I followed the instructions given by the Firebase guide itself to download files, but I can not succeed ( link ).
Would anyone know where I can be failing?
Thank you very much.