webviewでファイルをアップロードしたい。Android バージョンが 3.0 を超えるデバイスの [選択] ボタンをクリックすると、セレクターにボイス レコーダーのオプションが表示されません。これが私のコードです
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
String path = Environment.getExternalStorageDirectory().toString();
File file = new File(path, "temp.jpg");
file.delete();
mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("*/*");
Intent openInChooser=Intent.createChooser(i,"File Chooser");
Intent value[]=new Intent[2];
value[0]= new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
value[0].addCategory(Intent.CATEGORY_OPENABLE);
Intent fileExplorer= new Intent(MainActivity.this,DirectoryBrowser.class);
fileExplorer.setComponent(new ComponentName(MainActivity.this, DirectoryBrowser.class));
value[1] = new LabeledIntent(fileExplorer, "com.app.insta7", "File Explorer", R.drawable.folder);
openInChooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, value);
MainActivity.this.startActivityForResult(openInChooser, FILECHOOSER_RESULTCODE);
}
この行を追加してインテント配列のサイズを 3 に増やした場合
value[2] = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
デバイスのバージョンが 3.0 未満の場合、チューザーでオプションが 2 回表示されます。この問題の解決策がある場合は、解決策を教えてください。