Advertisement
anthraxGamma

Untitled

Jun 24th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. @Override
  2.     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  3.         super.onActivityResult(requestCode, resultCode, data);
  4.         switch (requestCode){
  5.             case Pick_song:
  6.             if (resultCode ==RESULT_OK) {
  7.                 String patch = data.getDataString();
  8.  
  9.                 try{
  10.                     MediaPlayer audio = new MediaPlayer();
  11.                     audio.setDataSource(getApplicationContext(), Uri.parse(patch));
  12.                     audio.prepare();
  13.                     audio.start();
  14.                 }catch (Exception e){
  15.                     Toast.makeText(this, "erro ao executar o áudio", Toast.LENGTH_SHORT).show();
  16.                 }
  17.             }
  18.         }
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement