Android examples for android.media:Audio
play Audio via mimetype using Intent
import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.webkit.MimeTypeMap; public class Main{ public static void playAudio(Context context, Uri uri) { Intent intent = new Intent(Intent.ACTION_VIEW); String type = "audio/*"; String extension = MimeTypeMap.getFileExtensionFromUrl(uri .toString());//w ww . j a v a2s. c o m type = MimeTypeMap.getSingleton().getMimeTypeFromExtension( extension); intent.setDataAndType(uri, type); try { context.startActivity(intent); } catch (ActivityNotFoundException e) { e.printStackTrace(); } } }