android文件管理选择器,Android文件选择器

该博客介绍了如何使用AndExplorer在Android应用中弹出文件选择对话框,并在用户缺少AndExplorer应用时,引导用户从市场安装。通过startCreation方法启动外部文件选择器,如果发现AndExplorer未安装,则显示提示对话框,用户可以选择安装或退出。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

为此,我使用了AndExplorer,我的解决方案是弹出一个对话框,然后在市场上重定向以安装漏取应用程序:

我的startCreation试图调用外部文件/目录选择器。如果缺少调用,请显示installResultMessage函数。private void startCreation(){

Intent intent = new Intent();

intent.setAction(Intent.ACTION_PICK);

Uri startDir = Uri.fromFile(new File("/sdcard"));

intent.setDataAndType(startDir,

"vnd.android.cursor.dir/lysesoft.andexplorer.file");

intent.putExtra("browser_filter_extension_whitelist", "*.csv");

intent.putExtra("explorer_title", getText(R.string.andex_file_selection_title));

intent.putExtra("browser_title_background_color",

getText(R.string.browser_title_background_color));

intent.putExtra("browser_title_foreground_color",

getText(R.string.browser_title_foreground_color));

intent.putExtra("browser_list_background_color",

getText(R.string.browser_list_background_color));

intent.putExtra("browser_list_fontscale", "120%");

intent.putExtra("browser_list_layout", "2");

try{

ApplicationInfo info = getPackageManager()

.getApplicationInfo("lysesoft.andexplorer", 0 );

startActivityForResult(intent, PICK_REQUEST_CODE);

} catch( PackageManager.NameNotFoundException e ){

showInstallResultMessage(R.string.error_install_andexplorer);

} catch (Exception e) {

Log.w(TAG, e.getMessage());

}}

这个方法只是拿起一个对话框,如果用户想从市场上安装外部应用程序private void showInstallResultMessage(int msg_id) {

AlertDialog dialog = new AlertDialog.Builder(this).create();

dialog.setMessage(getText(msg_id));

dialog.setButton(getText(R.string.button_ok),

new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

finish();

}

});

dialog.setButton2(getText(R.string.button_install),

new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setData(Uri.parse("market://details?id=lysesoft.andexplorer"));

startActivity(intent);

finish();

}

});

dialog.show();}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值