打开使用意图三星探险家指定的文件夹 [英] Opening a specified folder using Intents for samsung explorer
本文介绍了打开使用意图三星探险家指定的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我能够打开我的文件,应用程序,但我需要的是在我的文件打开一个特定的文件夹。这表明我对其它文件探险的文件夹。下面是另一篇文章中把我的code:
公共无效中openFile(URI数据){
意向意图=新意图(Intent.ACTION_GET_CONTENT);
intent.setDataAndType(数据,文件/ *);
intent.addCategory(Intent.CATEGORY_OPENABLE);意图sIntent =新意图(com.sec.android.app.myfiles.PICK_DATA);
//如果你想要的任何文件类型,你可以跳过下一行
sIntent.putExtra(CONTENT_TYPE,* / *);
sIntent.addCategory(Intent.CATEGORY_DEFAULT);
意图chooserIntent;
如果(getPackageManager()。resolveActivity(sIntent,0)!= NULL){
//它与三星的文件管理器
chooserIntent = Intent.createChooser(sIntent,打开文件夹);
chooserIntent.putExtra(Intent.EXTRA_STREAM,data.toString());
}
其他{
chooserIntent = Intent.createChooser(意向,打开文件);
} 尝试{
startActivity(chooserIntent);
}赶上(android.content.ActivityNotFoundException前){
Toast.makeText(getApplicationContext(),没有合适的文件管理器被发现。Toast.LENGTH_SHORT).show();
}
}
解决方案
我使用它来打开特定文件夹我的文件应用程序:
意向意图=新的Intent();
intent.setAction(com.sec.android.app.myfiles.VIEW);
intent.putExtra(FOLDERPATH,Environment.getExternalStorageDirectory()的getPath()+/ MyFolder中/);
startActivity(意向);
希望它帮助。
I am able to open the My files app but my need is to open a particular folder in My files . It shows me the folder for other File explorers. Below is my code taken from another post:
public void openFile(Uri data) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setDataAndType(data,"file/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
Intent sIntent = new Intent("com.sec.android.app.myfiles.PICK_DATA");
// if you want any file type, you can skip next line
sIntent.putExtra("CONTENT_TYPE", "*/*");
sIntent.addCategory(Intent.CATEGORY_DEFAULT);
Intent chooserIntent;
if (getPackageManager().resolveActivity(sIntent, 0) != null){
// it is device with samsung file manager
chooserIntent = Intent.createChooser(sIntent, "Open folder");
chooserIntent.putExtra(Intent.EXTRA_STREAM,data.toString() );
}
else {
chooserIntent = Intent.createChooser(intent, "Open file");
}
try {
startActivity(chooserIntent);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getApplicationContext(), "No suitable File Manager was found.", Toast.LENGTH_SHORT).show();
}
}
解决方案
I use this to open specific folder with my Files application :
Intent intent = new Intent();
intent.setAction("com.sec.android.app.myfiles.VIEW");
intent.putExtra("folderPath", Environment.getExternalStorageDirectory().getPath()+ "/myFolder/");
startActivity(intent);
Hope it helps.
这篇关于打开使用意图三星探险家指定的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文