我是 android 的新手,我正在我的应用程序中实现后台服务,我正在 BOOT_COMPLETED 进程上启动应用程序,我正在调用活动来启动应用程序,并且应用程序进入前台。但我想将应用程序保持在后台(最小化)并且我想在应用程序中进行静默登录。我正在使用以下代码在 Boot_Complete 上启动应用程序。
public class bootUpLocation extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equalsIgnoreCase(Intent.ACTION_BOOT_COMPLETED)) {
// here we start the service
Toast.makeText(context, "broadcast receiver start for location",
Toast.LENGTH_LONG).show();
Intent myIntent = new Intent(context, LoginActivity.class);
myIntent.addCategory(Intent.CATEGORY_HOME);
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myIntent);
}
}
}