Auf SD Karte zugreifen?

B

Butch78

Neues Mitglied
0
Hi Leute,

ich würde euch gerne bitten mir bei einem kleinen Problem zu helfen.
Ich greife in meiner App auf die Kamera zu um anschließend das aufgenommene Bild zu verarbeiten.
Der Zugriff auf die Kamera klappt. Mit mein USB Speicher ist mit dem Rechner verbunden (Im Explorer sehe ich den Wechseldatenträger und im Handydisplay steht "USB-Speicher wird verwendet).
Im Manifest habe ich noch folgende Rechte gesetzt:

<uses-permission android:name="android.permission.CAMERA" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Wenn ich nun aber meine App debuggen will, bekomme ich immer die Meldung (sobald ich die Kamera öffne): Warnung: Speicherkarte zur Verwendung der Kamera einlegen...

Die ist doch aber drin...
Verstehe das grad nicht ganz. Hoffe ihr könnt mir helfen?

Gruß

Butch


Code:
[SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onButtonClick(View view){
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Intent intent = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Intent(MediaStore.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]ACTION_IMAGE_CAPTURE[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
intent.putExtra(MediaStore.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]EXTRA_OUTPUT[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], Uri.[I]fromFile[/I](getTempFile([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])) ); 
startActivityForResult(intent, [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TAKE_PHOTO_CODE[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
}

[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] File getTempFile(Context context){
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//it will return /[U]sdcard[/U]/image.tmp[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] File path = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] File( Environment.[I]getExternalStorageDirectory[/I](), context.getPackageName() );
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](!path.exists()){
path.mkdir();
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] File(path, [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"image.tmp"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
}[/LEFT]
[/SIZE]
 
Hi Butch,

Butch78 schrieb:
...
Mit mein USB Speicher ist mit dem Rechner verbunden (Im Explorer sehe ich den Wechseldatenträger und im Handydisplay steht "USB-Speicher wird verwendet).

Damit ist dein Speicher im Rechner gemountet und nicht im Handy.
Android mountet deine SD-Karte wieder, wenn du diese von der Rechnerverbindung trennst. (Auf USB-Verbindung "Keine" setzten)

Wenn du Hintergrundinfos zu mounten haben willst...
linux mount mnt - Google-Suche

regards
 
Ok Super, das wars... Danke...

Gruß

Butch

P.s. Eine kleine Frage noch zum Schluss. Das aufgenommene Bild setze ich anschießend in ein ImageView ein. Dabei wird das Bild aber immer um 90Grad gedreht angezeigt. Wie kann ich das einstellen?

protected​
void onActivityResult(int requestCode, int resultCode, Intent data)

if (resultCode == RESULT_OK) {
switch(requestCode){
case TAKE_PHOTO_CODE:
final File file = getTempFile(this);
try {
Bitmap captureBmp = Media.getBitmap(getContentResolver(), Uri.fromFile(file) );
ImageView iv = (ImageView) findViewById(R.id.
iv_editdialog_image);
iv.setImageBitmap(captureBmp);
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
break;
}
}

}
 

Ähnliche Themen

E
Antworten
0
Aufrufe
684
enrem
E
B
Antworten
4
Aufrufe
406
bb321
B
Zurück
Oben Unten