質問編集履歴
2
Log.v("test",data.getData().toString());の結果追記
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -89,7 +89,13 @@ | |
| 89 89 |  | 
| 90 90 | 
             
            追記
         | 
| 91 91 | 
             
            half_sleepingさんのおっしゃっていたLogの内容は以下です。
         | 
| 92 | 
            +
             | 
| 93 | 
            +
            Log.v("test","path=" + path);
         | 
| 92 | 
            -
            V/test﹕ path=null
         | 
| 94 | 
            +
             V/test﹕ path=null
         | 
| 95 | 
            +
             | 
| 96 | 
            +
            Log.v("test",data.getData().toString());
         | 
| 97 | 
            +
             V/test﹕ content://com.android.providers.media.documents/document/image%3A209887
         | 
| 98 | 
            +
             | 
| 93 99 | 
             
            エラー表示等はありませんでした。
         | 
| 94 100 |  | 
| 95 101 | 
             
            ソース文をWeb上から持ってきた分ではなくアクティビティ全体のソースに変更しました。
         | 
1
half_sleepingさんの指摘点の追加、ソースをアクティビティ全体のものへと変更
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -2,13 +2,67 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            以下はWebで拾ってそのまま流用したが、パスが取得出来なかったソースです、参考にどうぞ
         | 
| 4 4 |  | 
| 5 | 
            -
                    // ギャラリー呼び出し
         | 
| 6 | 
            -
                    Intent intent = new Intent();
         | 
| 7 | 
            -
                    intent.setType("image/*");
         | 
| 8 | 
            -
             | 
| 5 | 
            +
            public class AddDiary extends Activity implements View.OnClickListener {
         | 
| 9 | 
            -
             | 
| 6 | 
            +
                private static final int REQUEST_GALLERY= 0;
         | 
| 10 7 |  | 
| 11 8 | 
             
                @Override
         | 
| 9 | 
            +
                protected void onCreate(Bundle savedInstanceState) {
         | 
| 10 | 
            +
                    super.onCreate(savedInstanceState);
         | 
| 11 | 
            +
                    setContentView(R.layout.activity_add_diary);
         | 
| 12 | 
            +
                    Button date = (Button) findViewById(R.id.BtnDate);
         | 
| 13 | 
            +
                    Button save = (Button) findViewById(R.id.BtnSave);
         | 
| 14 | 
            +
                    Button back = (Button) findViewById(R.id.BtnReturn);
         | 
| 15 | 
            +
                    Button selectpic = (Button) findViewById(R.id.BtnSelPic);
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                    date.setOnClickListener(this);
         | 
| 18 | 
            +
                    save.setOnClickListener(this);
         | 
| 19 | 
            +
                    back.setOnClickListener(this);
         | 
| 20 | 
            +
                    selectpic.setOnClickListener(this);
         | 
| 21 | 
            +
                }
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                @Override
         | 
| 24 | 
            +
                public boolean onCreateOptionsMenu(Menu menu) {
         | 
| 25 | 
            +
                    // Inflate the menu; this adds items to the action bar if it is present.
         | 
| 26 | 
            +
                    getMenuInflater().inflate(R.menu.menu_add_diary, menu);
         | 
| 27 | 
            +
                    return true;
         | 
| 28 | 
            +
                }
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                @Override
         | 
| 31 | 
            +
                public boolean onOptionsItemSelected(MenuItem item) {
         | 
| 32 | 
            +
                    // Handle action bar item clicks here. The action bar will
         | 
| 33 | 
            +
                    // automatically handle clicks on the Home/Up button, so long
         | 
| 34 | 
            +
                    // as you specify a parent activity in AndroidManifest.xml.
         | 
| 35 | 
            +
                    int id = item.getItemId();
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                    //noinspection SimplifiableIfStatement
         | 
| 38 | 
            +
                    if (id == R.id.action_settings) {
         | 
| 39 | 
            +
                        return true;
         | 
| 40 | 
            +
                    }
         | 
| 41 | 
            +
                    return super.onOptionsItemSelected(item);
         | 
| 42 | 
            +
                }
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                @Override
         | 
| 45 | 
            +
                public void onClick(View v) {
         | 
| 46 | 
            +
                    switch (v.getId()) {
         | 
| 47 | 
            +
                        case R.id.BtnDate:
         | 
| 48 | 
            +
                            //日付ダイアログ呼び出し
         | 
| 49 | 
            +
                            break;
         | 
| 50 | 
            +
                        case R.id.BtnSave:
         | 
| 51 | 
            +
                            //記入されているデータの保存
         | 
| 52 | 
            +
                            break;
         | 
| 53 | 
            +
                        case R.id.BtnReturn:
         | 
| 54 | 
            +
                            //タイトル画面に戻る
         | 
| 55 | 
            +
                            break;
         | 
| 56 | 
            +
                        case R.id.BtnSelPic:
         | 
| 57 | 
            +
                            // ギャラリー呼び出し
         | 
| 58 | 
            +
                            Intent intent = new Intent();
         | 
| 59 | 
            +
                            intent.setType("image/*");
         | 
| 60 | 
            +
                            intent.setAction(Intent.ACTION_GET_CONTENT);
         | 
| 61 | 
            +
                            startActivityForResult(intent, REQUEST_GALLERY);
         | 
| 62 | 
            +
                    }
         | 
| 63 | 
            +
                }
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                @Override
         | 
| 12 66 | 
             
                protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         | 
| 13 67 | 
             
                    // これはパスを取るためだけのコードです。
         | 
| 14 68 | 
             
                    if (requestCode == REQUEST_GALLERY && resultCode == RESULT_OK) {
         | 
| @@ -24,10 +78,18 @@ | |
| 24 78 | 
             
                        Log.v("test", "path=" + path);
         | 
| 25 79 | 
             
                    }
         | 
| 26 80 | 
             
                }
         | 
| 81 | 
            +
            }
         | 
| 27 82 |  | 
| 28 83 | 
             
            開発環境
         | 
| 29 84 | 
             
            AndroidStudio
         | 
| 30 85 | 
             
            端末OS
         | 
| 31 86 | 
             
            Android 4.4 KitKat
         | 
| 32 87 |  | 
| 33 | 
            -
            すみませんが、よろしくお願い致します。
         | 
| 88 | 
            +
            すみませんが、よろしくお願い致します。
         | 
| 89 | 
            +
             | 
| 90 | 
            +
            追記
         | 
| 91 | 
            +
            half_sleepingさんのおっしゃっていたLogの内容は以下です。
         | 
| 92 | 
            +
            V/test﹕ path=null
         | 
| 93 | 
            +
            エラー表示等はありませんでした。
         | 
| 94 | 
            +
             | 
| 95 | 
            +
            ソース文をWeb上から持ってきた分ではなくアクティビティ全体のソースに変更しました。
         | 
