get Audio File Intent - Android Media

Android examples for Media:Auto Player

Description

get Audio File Intent

Demo Code


//package com.java2s;

import android.content.Intent;

import android.net.Uri;
import java.io.File;

public class Main {

    public static Intent getAudioFileIntent(String param) {

        Intent intent = new Intent("android.intent.action.VIEW");
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.putExtra("oneshot", 0);
        intent.putExtra("configchange", 0);
        Uri uri = Uri.fromFile(new File(param));
        intent.setDataAndType(uri, "audio/*");
        return intent;
    }/* w w w .  j  ava  2 s . c  o m*/
}

Related Tutorials