Code Monkey home page Code Monkey logo

Comments (8)

Ereza avatar Ereza commented on August 16, 2024

Hi @utkarshGithub, sorry for taking a while to reply. Did you manage to solve the problem?

Your code appears to be fine (however, if you set the errorActivity via CaocConfig, the intent-filter is not really needed). Could you provide a minimal project so I can check if there is any other issue that causes this?

Thanks!

from customactivityoncrash.

alaegin avatar alaegin commented on August 16, 2024

The same issue.

Some details:

Tested on OnePlus 5 with 7.1 android and HTC One S on 4.1.
Caoc ver. 2.2.0

compileSdkVersion 26
buildToolsVersion '26.0.2'
...
targetSdkVersion 26
...
compile 'cat.ereza:customactivityoncrash:2.2.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
    transitive = true
}

Config in application class:

        CaocConfig.Builder.create()
                .backgroundMode(CaocConfig.BACKGROUND_MODE_SILENT) 
                .logErrorOnRestart(true)
                .errorActivity(CrashActivity.class)
                .apply();

CrashActivity.class is my custom activity which works absolutely 100%.

The issue takes part if I call throw new RuntimeException(); at the end of activitie's onCreate method - there will be nothing. If I call it from onDestroy/onResume etc. it will work right.

Also, if I use throw with some delay it will work!


        // At the end of onCreate in first activity
        new Handler().postDelayed(new Runnable() {
            @Override public void run() {

            }
        }, 500);

It seems as if it does not have time to start. If I call any exception after some delay from initialization - it will work fine. Also, it will work fine in any onCreate methods in future activities.

from customactivityoncrash.

Ereza avatar Ereza commented on August 16, 2024

Hi @DominuS-RU, can you provide a minimal project with all the code so I can reproduce the issue? I'm assuming that the problem doesn't happen on the sample project, can you check?

Thanks!!

from customactivityoncrash.

alaegin avatar alaegin commented on August 16, 2024

@Ereza Hello!
I've updated my previous comment with some details.
I'll test sample project and will try to give you test one in some hours.

Hope, my current details will help you.

from customactivityoncrash.

Ereza avatar Ereza commented on August 16, 2024

Thanks, I'll take a look into it!

from customactivityoncrash.

alaegin avatar alaegin commented on August 16, 2024

@Ereza, I've found the mistake.
It's the config for your sample:

CaocConfig.Builder.create()
.backgroundMode(CaocConfig.BACKGROUND_MODE_SILENT)
.apply();

An exception for MainActivity
throw new RuntimeException("boom");

studio64_2018-01-19_16-58-20

Then, start you application and see nothing.
The main issue in .backgroundMode(CaocConfig.BACKGROUND_MODE_SILENT), if we delete this one the library will work fine. All behavior is repeated as I've described in my first comment.

from customactivityoncrash.

alaegin avatar alaegin commented on August 16, 2024

Anything new about this issue?

from customactivityoncrash.

Ereza avatar Ereza commented on August 16, 2024

Hi, sorry for the ultralate reply.

With the examples you provided, I saw that there was an issue when the background mode is "silent" and the app is being launched. The background/foreground detection mechanism relies on started activities, and obviously a new activity that crashes in onCreate is not started yet, so the library thinks that the app is in background and does not show the error activity.

I solved this by recording the last time an activity was created (onActivityCreated is called before onCreate ends). If the activity crashes while in "background" but the last activity creation was less than 500 ms ago, the app is assumed to be in foreground and the activity is shown.

This will be available in the next release of the library.

from customactivityoncrash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.