2013-05-08 17 views
8

画像キャプチャインテントに余分なファイルパスを追加すると、在庫システムバージョン4.2.1のTF300t Androidタブレットでカメラアプリが誤動作します。 「完了」ボタンを押すと何も起こりません。カメラアプリのアクティビティを閉じることさえできません。結果は返されません。写真を「簡単に」撮ることができない

私が使用しているコードのように定義 createImageFile()Adroid developers site

Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
File imageFile = createImageFile(); 
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile)); 
startActivityForResult(cameraIntent, THIS_CAMERA_REQUEST); 

から抽出した

:ライン

cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile)); 

が除去されると

private File createImageFile() throws IOException { 
    File outputDir = getBaseContext().getCacheDir(); 

    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); 
    String imageFileName = "photo_" + timeStamp + "_"; 
    File image = new File(outputDir, imageFileName); 

    return image; 
} 

、カメラアプリは期待どおりに動作します。

共鳴的な回避策はありますか?私はむしろ写真を撮るためにカメラアプリを自分で構築するつもりはない。

答えて

4

問題のある行:

File outputDir = getBaseContext().getCacheDir(); 

私はそれを交換しました:

private File createImageFile() throws IOException { 
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); 
    String imageFileName = "1mind_" + timeStamp + ".jpg"; 
    File photo = new File(Environment.getExternalStorageDirectory(), imageFileName); 
    return photo; 
} 

が判明し、画像は、外部記憶装置上にないキャッシュディレクトリに格納する必要があります。

+2

同じ問題があります。エラーメッセージなしの非常に欺かれたバグ。私は写真を自分のアプリケーションのプライベートストレージに直接保存しようとしていましたが、それはいいえです。あなたの投稿に感謝します。 –

関連する問題