How to get a list of installed media players

后端 未结 6 2103
春和景丽
春和景丽 2020-12-06 07:48

In my app I have a menu item that I want to open up the user\'s preferred media player, only interested in audio. Ideally the first time the user chooses this item it would

6条回答
  •  不思量自难忘°
    2020-12-06 08:07

    /* For my samsung galaxy s4 running android version 5.0, none of the solutions above works but i found another solution. Works perfectly. Here is the code for someone who might need help. */

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(new File("content://media/internal/audio/media")), "audio/*");
    List activities = this.getPackageManager().queryIntentActivities(intent, 0);
    List activities; activities = getPackageManager().queryIntentActivities(intent, 0); int count = activities.size(); String a = Integer.toString(count);
    
    //set alert for executing the task
    AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
    builder1.setMessage("Handle: " + a);
    builder1.setCancelable(true);
    
    AlertDialog alert11 = builder1.create();
    alert11.show(); 
    

提交回复
热议问题