Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apps from Recent Apps back out to stock launcher instead of custom launcher

I'm creating a custom launcher that is used like a kiosk mode for the phone. This means most things are hidden away but allows the user to access some apps. I've noticed that when I launch apps from the Recent Apps list, when I press the back button, the stock launcher comes up instead of my custom launcher. I made sure my custom launcher is the default launcher since that's the launcher that comes up when I press the home button. Has anyone run into this issue? How do I solve it?

like image 266
Huy T Avatar asked Nov 18 '25 13:11

Huy T


1 Answers

In my attempt to make a Custom Launcher myself, to make that result you needed to disable the default launcher, that i was able to do using 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();
}

}

like image 117
Tazz Avatar answered Nov 20 '25 04:11

Tazz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!