Camera intent staying open on android -
I'm making an application for my app, I've got a camera intent, when an activity is created, the problem is that When I click OK for the captured picture, it re-opens the camera again to take a picture. Here the code is given: I can confirm that something is set to false on another activity That when this activity begins, the false thing taken is wrong
Enhances PublicExtra QuickEditActivity Activity {took public stable bullion; Override public null on @reate (bundle saved instainstate) {super.naught (savedinstenstate); SetContentView (R.layout.quickedit); If (! QuickEditActivity.taken) {RunCam (); }} Private Zero RunCam () {QuickEditActivity.taken = true; Meaning camIntent = new intent (MediaStore.ACTION_IMAGE_CAPTURE); StartActivityForResult (camIntent, 1); } @ Override Public Wide OnActivity Result (The result of int execcode code, the result code, intent data) {if (data! = Null and data. Gate extras = =!) =) Empty (bitmap bitmap = (bitmap) data. Gate Extras ) ("Info"); if (bitmap! = Tap) {ImageView imgView = (ImageView) findViewById (R.id.CamView); imgView.setImageBitmap (bitmap);} Else {this.finish ();}} Else {This.finish ();} Super.onActivityResult (requestCode, Outcome Code, Data);}}
My mental strength tells you that you have good In addition, my mental powers tell me that when you start the > via camera capture activity , your process is being killed and then when the camera Capture activity is complete so that your variable variable is taken is being reset to incorrectly, so that your onCreate method always thinks it It's starting for the first time, so you have an infinite number of State has put in capture loop. You can confirm it by adding the following statement to your onCreate method: log D. ("QuickEditActivity", "taken value =" + (taken? "True": "wrong")); You can fix this problem by overriding:
Protected over @OverrideSaveInstanceState (bundle outstate) {outState.putBoolean ("taken" This is the truth); } Then check this value in the code >> on the bundle method. Make sure to tell me how my psychic powers do.
Comments
Post a Comment