Android 浏览器在我的应用程序中使用
当我点击按钮时,程序会询问我要使用哪个文件管理器(或Dropbox等)。然后我选择,例如,.mp3文件。我怎么能告诉我的程序在我需要的时候启动这个.mp3?如何记住这个选定的文件Android 浏览器在我的应用程序中使用,android,audio,filesystems,Android,Audio,Filesystems,当我点击按钮时,程序会询问我要使用哪个文件管理器(或Dropbox等)。然后我选择,例如,.mp3文件。我怎么能告诉我的程序在我需要的时候启动这个.mp3?如何记住这个选定的文件 ring_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated me
ring_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent_for_ring_button = new Intent();
intent_for_ring_button.setAction(Intent.ACTION_GET_CONTENT);
File file = new File(REPORTS_DIRECTORY);
intent_for_ring_button.setDataAndType(Uri.fromFile(file),"application/file");
startActivityForResult(Intent.createChooser(intent_for_ring_button,"Open folder"), 0);
}
});
试试这个
Uri myUri = Uri.parse(entry.getFile());
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(myUri, "audio/*");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);