'Lock Task Mode Android 5.0 Launcher not launching apps
I'm building a Launcher-Kiosk app for Android 5+ (>= API 21) using the Device Owner to set up the device, manage the list of apps allowed to be used, start automatically the Kiosk. The Apps are in a GridView. The user clicks on one app icon, it launchs the app.
So far so good.
But, since this weekend the apps don't start when i'm in kiosk mode. The launcher is ok, if I disable the kiosk mode, the apps start.
It doesn't work on Android 5 anymore (6+ is ok). Tried on different devices and the emulator with API 21.
I checked several times the source code of my app. Nothing changed in the weekend. I've tryed the previous versions of the code, it's not working anymore.
I tried this example, adding a button to launch the app and adding the PackageName in setLockTaskPackages. Not working.
Even the Test-DPC doesn't allow kiosk Mode without API 23+ (Android M)
I created a new Android project just to try without the rest of my code, not working either. Here is the code (Simple new project with one button to launch an app, the app is set as device owner via adb) :
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button1 = (Button) findViewById(R.id.button1);
DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
final String[] kioskApps = new String[2];
kioskApps[0] = getPackageName();
kioskApps[1] = "com.android.email";
ComponentName deviceAdmin = new ComponentName(this, DeviceOwnerReceiver.class);
assert dpm != null;
dpm.setLockTaskPackages(deviceAdmin, kioskApps);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent launchIntent = getPackageManager().getLaunchIntentForPackage(kioskApps[1]);
if (launchIntent != null) {
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(launchIntent);//null pointer check in case package name was not found
}
}
});
startLockTask();
}
}
If a disable the tasklock, the email app starts. When the tasklock is on, it doesn't.
It worked before. Do you have any ideas, how is it possible ?
If you need more of my code, let me know...
Thank you very much ! :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
