0

I have a button on my application that triggers the camera and stores the image a directory of the SDCARD.

For some reason, the device "LG Optimus F5" error of this procedure. Already tested in a series of devices with different versions of Android, and this error does not occur. Does anyone know how to solve this problem?

My code is:

public void executeAction() {

    if (Application.getInstance().getStatus() == AppStatus.ONLINE) {

        fileUri = getOutputMediaFileUri("ImagePrisma3");

        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
        intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivityForResult(intent, 0);
    }
}

Post Execution:

protected void onPostExecute(Integer result) {

        if (parameterValue.equals("1")) {
            TxtRequester.setText(Application.getInstance().getUser());
        } else {
            TxtRequester.setText("");
        }

        loadWorkRequestTypeSpinner();
        // loadWorkTypeSpinner();

        if(progress.isShowing())
        {
            progress.dismiss();
            progress = null;
        }
    }

The following exception is being thrown:

08-28 10:41:40.177: E/AndroidRuntime(8019): FATAL EXCEPTION: main
08-28 10:41:40.177: E/AndroidRuntime(8019): java.lang.IllegalArgumentException: View not attached to window manager
08-28 10:41:40.177: E/AndroidRuntime(8019):     at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:671)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:364)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at android.view.WindowManagerImpl$CompatModeWrapper.removeView(WindowManagerImpl.java:163)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at android.app.Dialog.dismissDialog(Dialog.java:361)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at android.app.Dialog.dismiss(Dialog.java:344)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at com.sisteplantbrasil.WorkRequestOpen$Processo.onPostExecute(WorkRequestOpen.java:239)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at com.sisteplantbrasil.WorkRequestOpen$Processo.onPostExecute(WorkRequestOpen.java:1)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at android.os.AsyncTask.finish(AsyncTask.java:631)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at android.os.AsyncTask.access$600(AsyncTask.java:177)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at android.os.Looper.loop(Looper.java:137)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at android.app.ActivityThread.main(ActivityThread.java:4904)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at java.lang.reflect.Method.invokeNative(Native Method)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at java.lang.reflect.Method.invoke(Method.java:511)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
08-28 10:41:40.177: E/AndroidRuntime(8019):     at dalvik.system.NativeStart.main(Native Method)
08-28 10:41:42.760: E/Trace(8298): error opening trace file: No such file or directory (2)
Jay Snayder
  • 4,298
  • 4
  • 27
  • 53
Flávio Costa
  • 895
  • 5
  • 18
  • 41
  • can you post the code in the onPostExecute of com.sisteplantbrasil.WorkRequestOpen – hoomi Aug 28 '14 at 14:42
  • Have a look at this http://stackoverflow.com/questions/2745061/java-lang-illegalargumentexception-view-not-attached-to-window-manager – hoomi Aug 28 '14 at 14:48
  • I just did, but the same error happened. : / – Flávio Costa Aug 28 '14 at 14:55
  • Is there any chance that you finish the activity before onPostExecute is called? – hoomi Aug 28 '14 at 14:57
  • No, because I need to carry two spinners with a select information that needs to be done in AsyncTask. – Flávio Costa Aug 28 '14 at 17:00
  • The problem occurs because in my Activity in OnCreate () method we perform background task (AsyncTask). This background task is responsible for carrying the information of two spinners. After loading the information, I click button that makes the call the Intent of camera, which is displayed. After taking the picture, my Activity reruns the background process, generating the error. No idea how to solve this. – Flávio Costa Aug 28 '14 at 18:11
  • Can you post the whole activity code ? If it ia not too big – hoomi Aug 28 '14 at 20:31

0 Answers0