I've integrated some library from the third party into my android app.
They use background service with the location, but it caused java.lang.IllegalStateException error since Android 8 has updated the background location limits.
I've tried to add the following lines to avoid the error but it fails:
if(Build.VERSION.SDK_INT <= 25) { // below Android 8.0
PushAd.startPush(activity);
}else{
PushAd.disablePush(activity);
}
dependencies {
implementation 'com.adlocus:library:3.5.7@aar'
}
Can I delete or remove the library, or stop the service in the main activity programmatically?
[Solved]
I discovered a possible solution to solve the problem, we can use PackageManager to enable/disable a Service/Receiver/Activity from third party library.
ComponentName component = new ComponentName(context, MyReceiver.class);
context.getPackageManager().setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_DISABLED , PackageManager.DONT_KILL_APP);
Thanks Varun's answer.