如何从内置Web浏览器中的代码而不是在我的应用程序中打开URL?
我试过这个:
try {
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(download_link));
startActivity(myIntent);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, "No application can handle this request."
+ " Please install a webbrowser", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
但我有一个例外:
No activity found to handle Intent{action=android.intent.action.VIEW data =www.google.com
Run Code Online (Sandbox Code Playgroud) 我只是想知道如何启动一个Intent到手机的浏览器打开一个特定的URL并显示它.
有人可以给我一个提示吗?
我认为这很容易但事实证明不幸的是.
是)我有的:
我的外部存储器上有一个名为"myFolder"的文件夹(不是SD卡,因为它是Nexus 4,但这应该不是问题).该文件夹包含一些*.csv文件.
我想要的是:
我想写一个方法,它执行以下操作:显示各种应用程序(文件浏览器),我可以从中选择一个(见图片).单击它后,所选的文件浏览器应该启动并显示"myFolder"的内容.不多也不少.

我的问题:
我到底该怎么做?我想我接下来的代码非常接近,但无论我做什么 - 而且我确定必须有一些我还没有做到的事情 - 它始终只打开来自外部存储器的主文件夹.
public void openFolder()
{
File file = new File(Environment.getExternalStorageDirectory(),
"myFolder");
Log.d("path", file.toString());
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setDataAndType(Uri.fromFile(file), "*/*");
startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud) android SDK上有一些“选择文件夹对话框”吗?我用谷歌搜索,但没有找到任何东西。
我的意思是我正在寻找会弹出的对话框,并为我提供选择文件夹路径的选项(例如选择文件对话框...,但是return参数将是文件夹的完整路径)
很难相信,在这个奇妙的SDK中无法选择完整的文件夹路径。
任何帮助请..
谢谢。
我正在尝试使用意图查看特定文件夹中的图像。我的代码如下:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri imgUri = Uri.parse("file://sdcard/download");
intent.setDataAndType(imgUri, "image/*");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
但是,每次运行时,我都会在日志中收到此消息:
02-25 00:40:16.271:错误/(8359):无法打开'/下载
'02-25 00:40:16.271:错误/(8359):无法打开'/下载'
我究竟做错了什么?