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

Main activity should be obtained automatically from Manifest file #4

Closed
AizazZaidee opened this issue Jul 23, 2015 · 6 comments
Closed
Milestone

Comments

@AizazZaidee
Copy link
Contributor

CustomActivityOnCrash.setRestartActivityClass(MainActivity.class);
why not by default get Main Activity from Manifest file?

@Ereza
Copy link
Owner

Ereza commented Jul 23, 2015

That would be cool!

There are some drawbacks however:

  • An app may have more than one activity with intent filter with category LAUNCHER.
  • An app may have NO launchable activity (for example, apps that are only widgets).

What should we do in those cases?

If you are willing to provide a proposal via pull request I can take a look at it.

Thanks!

@Ereza Ereza changed the title CustomActivityOnCrash.setRestartActivityClass(MainActivity.class); Main activity should be obtained automatically from Manifest file Jul 23, 2015
@alorma
Copy link
Contributor

alorma commented Jul 23, 2015

Maybe it can add a custom action in order to be launched from library:

        <activity
            android:name=".view.activity.ErrorActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme">
            <intent-filter>
                <action android:name="cat.ereza.customactivityoncrash.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

@alorma
Copy link
Contributor

alorma commented Jul 23, 2015

Library should check for this action first, if there is no Activity with that, search for default android launcher activities, and if not launch the default library error Activity

@Ereza
Copy link
Owner

Ereza commented Jul 23, 2015

@alorma I think that's more complicated than the currently needed configuration... Anyway, we are talking about the activity that gets launched when pressing the "restart" button, so launching the error activity is independent from that.

IMHO, it should be like this:

  • If a restart activity has been specified with CustomActivityOnCrash.setRestartActivityClass(), use that.
  • If not specified, get the launchable activities via PackageManager, if one or more exist, just grab the first one by default (although I don't personally like that).
  • If no activities are launchable, just close the app.

Also, add an option to always close the app instead of restarting.

@alorma
Copy link
Contributor

alorma commented Jul 23, 2015

Oh, sorry i missunderstood the Issue :D i will move it to a new Issue.

Anyway, it can be used in a similar way, with an extra action.

<action android:name="cat.ereza.customactivityoncrash.RELAUNCH" />

@Ereza
Copy link
Owner

Ereza commented Jul 24, 2015

Closed with the pull request #6 by @AizazAZ. Thanks!

@Ereza Ereza closed this as completed Jul 24, 2015
@Ereza Ereza added this to the 1.2.0 milestone Aug 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants