@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); }
// 画像選択画面を開く 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, ""); }
void initPage() { Intent intent = getIntent(); if (intent != null) { // カメラ画面を呼び出した際のURIを復旧 String v = intent.getStringExtra(PrefKey.EXTRA_CAPTURE_URI); if (v != null) this.capture_uri = Uri.parse(v); String action = intent.getAction(); if (Intent.ACTION_SEND_MULTIPLE.equals(action)) { try { ArrayList<UploadItem> tmp = new ArrayList<UploadItem>(); for (Parcelable p : intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM)) { String path = MushroomHelper.uri_to_path(env, (Uri) p); if (path != null) tmp.add(new UploadItem(env, path)); } upload_list_adapter.replace(tmp); } catch (Throwable ex) { env.report_ex(ex); } } } updateUploadButtonStatus(); }