私も試しましたが、
intent = new Intent(Intent.ACTION_PICK);
intent.setDataAndType(startDir, "vnd.android.cursor.dir/*");
しかし、FileManager、Gallery、Music、Contects など、考えられるすべてのインテントが表示されます。Android が「名前を付け
て保存」機能をサポートするインテントを決定する方法が見つかりませんでした。
だから、私は次の解決策を持っています。ここでは、名前を付けて保存機能をサポートするさまざまなファイル エクスプローラーに対して試行回数を増やしていく必要があります。
int iLoop = 0;
int iTryCount = 2;
for (iLoop = 0; iLoop < iTryCount; iLoop++)
{
Intent intent = null;
if (iLoop == 0)
{
// OI File Manager
intent = new Intent(Intent.ACTION_PICK);
intent.setData(startDir);
intent.setAction("org.openintents.action.PICK_FILE");
intent.putExtra("org.openintents.extra.TITLE", "Save As...");
}
else if (iLoop == 1)
{
// AndExplorer
intent = new Intent(Intent.ACTION_PICK);
intent.setDataAndType(startDir,
"vnd.android.cursor.dir/lysesoft.andexplorer.file");
intent.putExtra("explorer_title", "Save As...");
intent.putExtra("browser_filter_extension_whitelist", "*.png");
intent.putExtra("browser_line", "enabled");
intent.putExtra("browser_line_textfield", "file1.png");
}
if (intent != null)
{
try
{
// Try to launch activity
startActivityForResult(intent, REQUEST_SAVE_FILE);
// TODO: Remove this notification on Publish
Toast.makeText(m_baseSurfaceView.getContext(),
"Try : " + iLoop, Toast.LENGTH_SHORT).show();
// If everything gone well, then break from here
// otherwise see catch(..) block
break;
}
catch (Exception e)
{
e.printStackTrace();
// If all tries are done, then conclusion is that,
// the user needs to install some file-manager application
// to locate where to save the file
if (iLoop == iTryCount - 1)
{
Toast.makeText(
m_baseSurfaceView.getContext(),
"Please Install some File Manager"
+ " application to locate destination.",
Toast.LENGTH_LONG).show();
}
}
}
}
提案があればコメントしてください。