Closed mu-hasan closed 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
}
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
anyException
. I want to create this feature and pull request but I'm not familiar with kotlin :smile: :v: