gpt4 book ai didi

android - 资源管理器在我的应用中使用

转载 作者:行者123 更新时间:2023-12-03 01:59:26 25 4
gpt4 key购买 nike

当我单击按钮时,程序会询问我要使用哪个文件管理器(或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);

关于android - 资源管理器在我的应用中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32923927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com