コード例 #1
0
 // 画像選択画面を開く
 void open_file_picker() {
   try {
     Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
     intent.setType("image/*");
     intent.addCategory(Intent.CATEGORY_OPENABLE);
     // open chooser
     //	startActivityForResult(Intent.createChooser(intent,"file picker"),REQ_FILEPICKER);
     startActivityForResult(intent, MenuDialog.REQ_FILEPICKER);
     return;
   } catch (ActivityNotFoundException ex) {
     env.show_toast(true, R.string.picker_missing);
   }
   log.d("open_file_picker :finish");
   MushroomHelper.finish_mush(env, false, "");
 }
コード例 #2
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent detail) {
   log.d("onActivityResult req=%s res=%sdetail=%s", requestCode, resultCode, detail);
   switch (requestCode) {
     case MenuDialog.REQ_FILEPICKER:
       if (resultCode == RESULT_OK && detail != null) {
         add_item(MushroomHelper.uri_to_path(env, detail.getData()));
       }
       break;
     case MenuDialog.REQ_HISTORY:
       if (resultCode == RESULT_OK && detail != null) {
         MushroomHelper.finish_mush(env, true, detail.getStringExtra("url"));
       }
       break;
     case MenuDialog.REQ_PREF:
       upload_target_manager.reload();
       break;
     case MenuDialog.REQ_ARRANGE:
       if (resultCode == RESULT_OK && detail != null) {
         String path = detail.getStringExtra(PrefKey.EXTRA_DST_PATH);
         replace_path(last_edit_index, path);
       }
       break;
     case MenuDialog.REQ_APPINFO:
       break;
     case MenuDialog.REQ_CAPTURE:
       if (resultCode == RESULT_OK) {
         Uri uri = (detail == null ? null : detail.getData());
         if (uri == null) uri = capture_uri;
         if (uri == null) {
           log.e("cannot get capture uri");
         } else {
           log.d("capture uri = %s", uri);
           add_item(MushroomHelper.uri_to_path(env, uri));
         }
       }
       break;
   }
   super.onActivityResult(requestCode, resultCode, detail);
 }