3
respostas

Erro ao salvar foto

quando coloco app pra rodar no celular, eu bato uma foto e quando confirmo a aplicação retorna do começo e sem salvar a foto



import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import java.io.File;

public class QualidadeActivity extends AppCompatActivity {


    public static final int CODIGO_CAMERA = 567;
    private String caminhofoto;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_qualidade);

        Button botaofoto = (Button) findViewById(R.id.buttonqualidadefoto);
        botaofoto.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               Intent intentCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
               caminhofoto = getExternalFilesDir(null) + "/" + System.currentTimeMillis() + ".jpg";
               File arquivofoto = new File(caminhofoto);
               intentCamera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(arquivofoto));
               startActivityForResult(intentCamera, CODIGO_CAMERA);


            }
        });

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == Activity.RESULT_OK) {
        if (requestCode == CODIGO_CAMERA) {
            ImageView foto = (ImageView) findViewById(R.id.qualidadefoto);
            Bitmap bitmap = BitmapFactory.decodeFile(caminhofoto);
            Bitmap bitmapReduzido = Bitmap.createScaledBitmap(bitmap, 300, 300, true);
            foto.setImageBitmap(bitmapReduzido);
            foto.setScaleType(ImageView.ScaleType.FIT_XY);
            }
        }
    }
}
3 respostas

Fala ai Bernardo, de boa ?

Provavelmente deve rolar uma excepetion no logcat, consegue ver e passar pra gente ver o que pode estar rolando ?

09-20 02:02:22.797 1576-1576/? E/AudioFlinger: createRecordTrack_l() initCheck failed -12; no control block?
09-20 02:02:22.797 1576-31665/? I/AudioFlinger: AudioFlinger's thread 0xe3583840 tid=31665 ready to run
09-20 02:02:22.798 2523-31506/com.google.android.googlequicksearchbox:search E/IAudioFlinger: createRecord returned error -12
09-20 02:02:22.798 2523-31506/com.google.android.googlequicksearchbox:search E/AudioRecord: AudioFlinger could not create record track, status: -12
09-20 02:02:22.799 2523-31506/com.google.android.googlequicksearchbox:search E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -12.
09-20 02:02:22.799 2523-31506/com.google.android.googlequicksearchbox:search E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.
09-20 02:02:22.799 2523-31506/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_started  SR : 16000 CC : 16 SO : 6
09-20 02:02:22.800 2523-2523/com.google.android.googlequicksearchbox:search I/MicroDetectionWorker: onReady
09-20 02:02:22.806 2523-31506/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_close  SR : 16000 CC : 16 SO : 6
09-20 02:02:22.806 2523-18364/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Detection finished
09-20 02:02:22.806 2523-18364/com.google.android.googlequicksearchbox:search W/ErrorReporter: reportError [type: 211, code: 524300]: Error reading from input stream
09-20 02:02:22.807 2523-3028/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Stopping hotword detection.
09-20 02:02:22.808 2523-18364/com.google.android.googlequicksearchbox:search W/ErrorProcessor: onFatalError, processing error from engine(4)
    com.google.android.apps.gsa.shared.speech.b.g: Error reading from input stream
        at com.google.android.apps.gsa.staticplugins.microdetection.d.k.a(SourceFile:91)
        at com.google.android.apps.gsa.staticplugins.microdetection.d.l.run(Unknown Source:14)
        at com.google.android.libraries.gsa.runner.a.a.b(SourceFile:32)
        at com.google.android.libraries.gsa.runner.a.c.call(Unknown Source:4)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at com.google.android.apps.gsa.shared.util.concurrent.b.g.run(Unknown Source:4)
        at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
        at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
        at com.google.android.apps.gsa.shared.util.concurrent.b.i.run(SourceFile:6)
     Caused by: com.google.android.apps.gsa.shared.exception.GsaIOException: Error code: 393238 | Buffer overflow, no available space.
        at com.google.android.apps.gsa.speech.audio.Tee.j(SourceFile:103)
        at com.google.android.apps.gsa.speech.audio.au.read(SourceFile:2)
        at java.io.InputStream.read(InputStream.java:101)
        at com.google.android.apps.gsa.speech.audio.ao.run(SourceFile:17)
        at com.google.android.apps.gsa.speech.audio.an.run(SourceFile:2)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
        at com.google.android.apps.gsa.shared.util.concurrent.b.g.run(Unknown Source:4) 
        at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4) 
        at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:764) 
        at com.google.android.apps.gsa.shared.util.concurrent.b.i.run(SourceFile:6) 
09-20 02:02:22.809 2523-18364/com.google.android.googlequicksearchbox:search I/AudioController: internalShutdown
09-20 02:02:22.810 2523-2523/com.google.android.googlequicksearchbox:search I/MicroDetector: Keeping mic open: false
09-20 02:02:22.810 2523-2523/com.google.android.googlequicksearchbox:search I/MicroDetectionWorker: #onError(false)
09-20 02:02:22.810 2523-30775/com.google.android.googlequicksearchbox:search I/DeviceStateChecker: DeviceStateChecker cancelled

Esse erro não diz muito sobre o que pode estar rolando :(