LoginSignup
1

More than 5 years have passed since last update.

画像取得備忘録 ギャラリー呼び出し

Last updated at Posted at 2017-06-23

久しぶりにアプリ作成。
追加機能として画像取得機能をつけることにしました。

ここでの処理は画像取得前の準備段階という感じで、ギャラリーを呼び出している…でいいのかな。
Intentを準備して、そこに2つの機能を追加してアクティビティを開始。
そして、情報の受け渡しを可能にしている段階。

findViewById(R.id.activity_detail_select_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
                intent.addCategory(Intent.CATEGORY_OPENABLE);
                intent.setType("image/*");
                startActivityForResult(intent, RESULT_PICK_IMAGEFILE);
            }
        });

ここから完全に雑記

ACTION_OPEN_DOCUMENT

ピッカーを使用して、ファイルを選択するためのintent
→ ピッカー = インタフェース

CATEGORY_OPENABLE

URIの受け渡し
URIっていうのは名前や場所を識別するためのもの
これを受け渡す事で今回であれば画像を追加する

"image/*"

→ 文字列の種類としてこれを選択

startActivityForResult

→アクティビティを起動し、アクティビティから何かしらの情報を受け取ることを可能にする

まったくもって自信がないので、指摘を頂けると大変助かります。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1