我正在创建一个自定义启动器,用作手机的信息亭模式。这意味着大多数东西都被隐藏起来,但允许用户访问某些应用程序。我注意到当我从最近的应用程序列表中启动应用程序时,当我按下后退按钮时,库存启动器会出现,而不是我的自定义启动器。我确保我的自定义启动器是默认启动器,因为这是我按下主页按钮时启动的启动器。有没有人遇到过这个问题?我该如何解决?
答案 0 :(得分:0)
在我尝试自己创建自定义启动器时,为了获得该结果,您需要禁用默认启动器,这是我能够使用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();
}
}
答案 1 :(得分:-1)
我遇到同样问题时找到的唯一解决方案是重启设备。在此之后从最近的应用程序启动应用程序并按后退按钮时,您将看到正确的主屏幕。