Question:I have an Android app that needs to call a Service provided by another app, but when the other app is killed, bindService() returns false. How can I achieve this on Android 10 or later?
private boolean bindService() {
try {
Intent intent = new Intent();
intent.setComponent(new ComponentName(ConfigCons.MYKEY_PACKAGE_NAME, ConfigCons.CONNECT_CLASS_PATH));
context.startService(intent);
boolean bindResult = context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
if (!bindResult) {
LogUtil.e(TAG, "can not bind connect service");
}
return bindResult;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}