Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashes when minimize the App and Open App again #18

Open
codingjeremy opened this issue Sep 6, 2019 · 3 comments
Open

App crashes when minimize the App and Open App again #18

codingjeremy opened this issue Sep 6, 2019 · 3 comments
Labels
migrated googlesamples Migrated from old googlesamples repos PdfRendererBasic

Comments

@codingjeremy
Copy link
Collaborator

Issue by abhay222
Thursday Feb 15, 2018 at 14:06 GMT
Originally opened as googlearchive/android-PdfRendererBasic#20


Hi, App goes to crash when I minimize App and then open
The app from minimized state.

Android Version : 7.0
Android Device : MOTO C Plus

FATAL EXCEPTION: main Process: com.example.android.pdfrendererbasic, PID: 32027 java.lang.RuntimeException: Unable to resume activity {com.example.android.pdfrendererbasic/com.example.android.pdfrendererbasic.MainActivity}: java.lang.IllegalStateException: Already closed at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3506) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3546) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1577) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:203) at android.app.ActivityThread.main(ActivityThread.java:6251) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1075) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) Caused by: java.lang.IllegalStateException: Already closed at android.graphics.pdf.PdfRenderer$Page.throwIfClosed(PdfRenderer.java:423) at android.graphics.pdf.PdfRenderer$Page.close(PdfRenderer.java:398) at com.example.android.pdfrendererbasic.PdfRendererBasicFragment.showPage(PdfRendererBasicFragment.java:197) at com.example.android.pdfrendererbasic.PdfRendererBasicFragment.onStart(PdfRendererBasicFragment.java:122) at android.support.v4.app.Fragment.performStart(Fragment.java:2380) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1458) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809) at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3217) at android.support.v4.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:3176) at android.support.v4.app.FragmentController.dispatchStart(FragmentController.java:203) at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570) at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1248) at android.app.Activity.performStart(Activity.java:6683) at android.app.Activity.performRestart(Activity.java:6757) at android.app.Activity.performResume(Activity.java:6762) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3477) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3546) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1577) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:203) at android.app.ActivityThread.main(ActivityThread.java:6251) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1075) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

@codingjeremy
Copy link
Collaborator Author

Comment by rickyin
Thursday Jun 28, 2018 at 06:57 GMT


@abhay222 I have the same problem with you, and i solved it like this

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mPageIndex = 0;
        if (null != savedInstanceState) {
            mPageIndex = savedInstanceState.getInt(STATE_CURRENT_PAGE_INDEX, 0);
        }
        showPage(mPageIndex);
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        try {
            openRenderer(context);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    @Override
    public void onDestroy() {
        try {
            closeRenderer();
        } catch (IOException e) {
            e.printStackTrace();
        }
        super.onDestroy();
    }

openRenderer in onAttach() instead of onStart() , and showPage(mPageIndex) in onViewCreated method, closeRenderer in onDestroy()

@codingjeremy
Copy link
Collaborator Author

Comment by abhay222
Friday Jun 29, 2018 at 08:03 GMT


Thanks @rickyin

@codingjeremy
Copy link
Collaborator Author

Comment by zainabz1995
Wednesday Aug 21, 2019 at 05:53 GMT


Thanks a lot @rickyin ... Your solution is perfect :)

@codingjeremy codingjeremy added the migrated googlesamples Migrated from old googlesamples repos label Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migrated googlesamples Migrated from old googlesamples repos PdfRendererBasic
Projects
None yet
Development

No branches or pull requests

2 participants