I made a app,This is the app that store the location information by interval and send it to the server Services are working in background or forground mode.It is working well in common android phones. Btw app is not working well in oppo and vivo After launching the first activity,app(this activity) is killing after 3~5 min.
try {
Intent intent = new Intent();
String manufacturer = android.os.Build.MANUFACTURER;
if ("xiaomi".equalsIgnoreCase(manufacturer)) {
intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
} else if ("oppo".equalsIgnoreCase(manufacturer)) {
intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity"));
} else if ("vivo".equalsIgnoreCase(manufacturer)) {
//intent.setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity"));
intent.setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity"));
}
List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0) {
startActivity(intent);
}
} catch (Exception e) {
Crashlytics.logException(e);
}
Account account = createSyncAccount(this);
Intent locationIntent = new Intent(this, UserLocationService.class);
locationIntent.putExtra("extra.account", account);
startService(locationIntent);
Intent i = new Intent(this, SynchronizeService.class);
SharedPreferences prefs =
PreferenceManager.getDefaultSharedPreferences(this);
long synchTime =
Long.parseLong(prefs.getString(Constants.SETTINGS_SYNCHRONIZE_INTERVAL, "210"));
i.setAction(SynchronizeService.ACTION_SET_ALARM);
if (!UserLocationService.isRepeated)
i.putExtra(SynchronizeService.EXTRA_TIME, Long.valueOf("30"));
else i.putExtra(SynchronizeService.EXTRA_TIME, synchTime);
startService(i);
This is piece of my source. Could you help me?I didn't find correct solution.If anyone have a solution?Could you let me know about it?