ファイル チューザーの可用性をテストしようとしています。利用できない場合はエラーが返されると思いましたが、そうではありません。
これが私のコードです:
public void doImport() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
startActivityForResult(Intent.createChooser(intent, "Select a File to Import"), IMPORT_RACES_CODE);
} catch (android.content.ActivityNotFoundException ex) {
// Potentially direct the user to the Market with a Dialog
Utils.Error(this, "THERE WAS NO NAVIGATOR FOUND, Install a navigator!");
} catch (Exception e) {
Utils.Error(this, "Some other error occurred!");
}
}
ただし、例外は私のルーチンに送り返されていません。OS がエラーを処理し、「このアクションを実行できるアプリはありません」というダイアログ ボックスを生成しているようです。
ここで何が間違っているのか分かりますか?
ありがとう!