在我的应用程序中使用资源管理器
Explorer using in my app
当我点击按钮时,程序会询问我想使用哪个文件管理器(或 Dropbox 等)。然后我选择,例如,.mp3 文件。当我需要它时,我如何告诉我的程序启动这个 .mp3?如何记住这个选择的文件?
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);
当我点击按钮时,程序会询问我想使用哪个文件管理器(或 Dropbox 等)。然后我选择,例如,.mp3 文件。当我需要它时,我如何告诉我的程序启动这个 .mp3?如何记住这个选择的文件?
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);