Restart Preview funktioniert nicht

  • 0 Antworten
  • Letztes Antwortdatum
J

jimmicool

Neues Mitglied
0
Hallo, ich versuche nach dem ich ein Foto gemacht habe die Kamera-Preview neu zu starten, aber es kommt folgende Exception:

java.lang.RuntimeException: startPreview failed
at android.hardware.Camera.startPreview(Native Method)
at com.imagero.mycam.MainActivity$1.onClick(MainActivity.java:57)
at android.view.View.performClick(View.java:4202)
at android.view.View$PerformClick.run(View.java:17340)
at android.os.Handler.handleCallback(Handler.java:725)

Was mache ich falsch??

Hier ist mein Click-Handler:
(Preview funktioniert bis ich ein Foto mache)

Code:
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]enum[/COLOR][/SIZE][/COLOR][/SIZE][/B]
[LEFT][SIZE=2]Camera_State {[/SIZE][/LEFT]
 
[LEFT][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0] K_STATE_FROZEN[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]K_STATE_PREVIEW[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]K_STATE_BUSY[/COLOR][/SIZE][/COLOR][/SIZE][/I][/LEFT]
 
[LEFT][SIZE=2]}[/SIZE]
...[/LEFT]
 
 
[LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]button[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setOnClickListener([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] View.OnClickListener() {[/SIZE][/LEFT]
 
 
 
 
 
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Camera_State [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mPreviewState[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Camera_State.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]K_STATE_PREVIEW[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2];[/SIZE][/LEFT]
 
 
 
 
[LEFT][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/COLOR][/SIZE][/COLOR][/SIZE]

[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onClick(View v) {[/SIZE]
[LEFT][SIZE=2]Log.[I]i[/I](getString(R.string.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]app_name[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]), [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"onClick "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mPreviewState[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE][/LEFT]
[/LEFT]

 
 
 
 
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]switch[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mPreviewState[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) {[/SIZE]

[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055] case[/COLOR][/SIZE][/COLOR][/SIZE][/B][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]K_STATE_FROZEN[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]:[/SIZE]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055] try[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] {[/SIZE]
[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]    mCamera[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].startPreview();[/SIZE]
[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]    mPreviewState[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Camera_State.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]K_STATE_PREVIEW[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2];[/SIZE]
[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]    button[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setText(getString(R.string.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]button_photo[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]));[/SIZE]
[SIZE=2] } [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]catch[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] (Throwable t) {[/SIZE]
[SIZE=2]    t.printStackTrace();[/SIZE]
[SIZE=2] }[/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055] break[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2];[/SIZE][/LEFT]
[/LEFT]

 
 
 
 
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055] default[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]:[/SIZE]

[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]    mCamera[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].takePicture([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]rawCallback[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE]
[LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]    mPreviewState[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Camera_State.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]K_STATE_BUSY[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2];[/SIZE]
[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]    button[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setText(getString(R.string.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]button_photo_processing[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]));[/SIZE]
[SIZE=2] }[/SIZE]
[SIZE=2]}[/SIZE][/LEFT]
[/LEFT]

 
 
 
 
[LEFT][SIZE=2]PictureCallback [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]rawCallback[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] PictureCallback() {[/SIZE][/LEFT]
 
 
 
[LEFT][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/COLOR][/SIZE][/COLOR][/SIZE]

[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onPictureTaken([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]byte[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][] data, Camera camera) {[/SIZE]
[LEFT][SIZE=2] Log.[I]i[/I](getString(R.string.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]app_name[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]), [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"onPictureTaken"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE][/LEFT]
[/LEFT]

 
 
 
 
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f] // [/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#7f9fbf][SIZE=2][COLOR=#7f9fbf]TODO[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f] Auto-generated method stub[/COLOR][/SIZE][/COLOR][/SIZE]

[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0] mPreviewState[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Camera_State.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]K_STATE_FROZEN[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2];[/SIZE]
[LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0] button[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setText(getString(R.string.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]button_restart_preview[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]));[/SIZE][/LEFT]
[/LEFT]

 
 
 
 
[LEFT][SIZE=2] }[/SIZE]

[SIZE=2]};[/SIZE][/LEFT]

 
 
 
[LEFT][SIZE=2]});[/SIZE][/LEFT]
 

Ähnliche Themen

AnnaBauer21
Antworten
0
Aufrufe
596
AnnaBauer21
AnnaBauer21
AnnaBauer21
Antworten
6
Aufrufe
1.167
AnnaBauer21
AnnaBauer21
Zurück
Oben Unten