2016-11-18 7 views
0

これは重複している可能性がありますが、開発中のアンドロイドアプリにイメージを読み込む方法が必要です。イメージは、Venns Road Accidentというカスタムフォルダに保存されます。私は複数のソースを見てきましたが、何も私のために働くようです。アンドロイドデバイスのフォルダから画像を取得してアプリケーションに表示する

これは、画像をキャプチャして保存するためのコードです。

File[] imgFileArray = myDir.listFiles(); 
  • 今、あなたは繰り返すことができます - 下記によって

    public void Pictures (View v) 
    { 
        //Call the camera and get phone date and time 
        Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); 
    
        //Create the folder for the images to be saved 
        File imagesFolder = new File(Environment.getExternalStorageDirectory(), "Venns Road Accident"); 
        imagesFolder.mkdirs(); 
    
        //Apply the system date and time as the name of the image 
        File image = new File(imagesFolder, "VCA_" + timeStamp + ".png"); 
        Uri uriSavedImage = Uri.fromFile(image); 
    
        //Saving of image and allowing for new image to be captured 
        imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage); 
        startActivityForResult(imageIntent, CAMERA_REQUEST); 
    } 
    
    @Override 
    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
        super.onActivityResult(requestCode, resultCode, data); 
    
        if (requestCode == CAMERA_REQUEST) 
         Toast.makeText(Pictures.this, "Image Saved", Toast.LENGTH_LONG).show(); 
        else 
         Toast.makeText(Pictures.this, "Image not Saved", Toast.LENGTH_LONG).show(); 
    } 
    
  • +0

    実際の問題の詳細については、こちらをご覧ください。 – raxelsson

    +0

    あなたが掲示したコードは、画像を読み取るためのものではなく、画像を取り込むためのものです。アプリから画像を読み込んだり表示したりするために作成したコードを投稿し、エラーの原因を教えてください。 – pleft

    答えて

    0
    1. アクセスローカルフォルダは、以下のように)(今LISTFILESを呼び出すことにより、すべてのファイルを取得

      File myDir = new File(Environment.getExternalStorageDirectory(), "Venns Road Accident"); 
      
    2. をコード - ファイルを作成します。

    関連する問題