judemanutd / AutoStarter

This library helps bring up the autostart permission manager of a phone to the user so they can add an app to autostart.
MIT License
626 stars 115 forks source link

[Feature Request] Callback when failed #16

Closed mu-hasan closed 5 years ago

mu-hasan commented 5 years ago

I think you need to add a callback when device isn't supported yet or device use custom ROM (or something) so the "package" not found. Because I haven't catch any Exception. I want to create this feature and pull request but I'm not familiar with kotlin :smile: :v:

Chuque commented 5 years ago

Will be better to also add a function to return a boolean that indicates if the autostart permission is found. This way the dev can disable the button for this permission on activity onCreate() or handle it in some other way. Below is a code in java that can be used to achieve this.

Intent autoStartIntent = new Intent();
        autoStartIntent.setComponent(new ComponentName("manufacturer.package", 
"manufacturer.class"));

List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(autoStartIntent,
            PackageManager.MATCH_DEFAULT_ONLY);
    if(list.size() > 0){
           //activity for autostart found
    } else {
           //activity for autostart not found
    }