gpt4 book ai didi

java - Recent Apps 中的应用程序退回到库存启动器而不是自定义启动器

转载 作者:搜寻专家 更新时间:2023-10-30 19:47:39 24 4
gpt4 key购买 nike

我正在创建一个自定义启动器,用作手机的信息亭模式。这意味着大部分内容都被隐藏起来,但允许用户访问某些应用程序。我注意到,当我从“最近的应用程序”列表中启动应用程序时,当我按下后退按钮时,会出现常用启动器而不是我的自定义启动器。我确保我的自定义启动器是默认启动器,因为这是我按下主页按钮时出现的启动器。有人遇到过这个问题吗?我该如何解决?

最佳答案

在我尝试自己制作一个自定义启动器时,为了达到这个结果,您需要禁用默认启动器,我可以使用 KeyguardManager 来做到这一点。

package com.themejunky.locker.services;


public class KeyguardService extends Service {

BroadcastReceiver mReceiver, mBatteryReceiver;

// Intent myIntent;
public class LocalBinder extends Binder {
public KeyguardService getService() {
return KeyguardService.this;
}
}

@Override
public IBinder onBind(Intent intent) {
return mBinder;
}

private final IBinder mBinder = new LocalBinder();

@Override
public void onCreate() {
KeyguardManager.KeyguardLock k1;

KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
k1 = km.newKeyguardLock("IN");
k1.disableKeyguard();

KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardManager.KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard();

IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.setPriority(999);

mReceiver = new LockScreenReceiver();
registerReceiver(mReceiver, filter);

mBatteryReceiver = new BatteryReceiver();
IntentFilter filter2 = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
filter2.addAction(Intent.ACTION_BATTERY_OKAY);
filter2.addAction(Intent.ACTION_BATTERY_LOW);
registerReceiver(mBatteryReceiver, filter2);

super.onCreate();
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}

@Override
public void onDestroy() {
unregisterReceiver(mReceiver);
unregisterReceiver(mBatteryReceiver);
super.onDestroy();
}

关于java - Recent Apps 中的应用程序退回到库存启动器而不是自定义启动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26639317/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com