【发布时间】:2019-08-08 16:05:31
【问题描述】:
我做了一个应用程序,这是一个按时间间隔存储位置信息并发送到服务器的应用程序 服务在后台或前台模式下工作。在普通的安卓手机上运行良好。 顺便说一句,应用程序在 oppo 和 vivo 中运行不佳 启动第一个活动后,应用程序(此活动)在 3~5 分钟后被杀死。
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);
这是我的来源。 你能帮我吗?我没有找到正确的解决方案。如果有人有解决方案?你能告诉我吗?
【问题讨论】:
标签: android