을 해결책을 찾았습니다. 아래 내 방법입니다.
private void enableKioskMode() {
ComponentName deviceAdmin = new ComponentName(this, AdminReceiver.class);
DevicePolicyManager mDpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
// First of all, to access anything you must be device owner
if (mDpm.isDeviceOwnerApp(getPackageName())) {
// If not device admin, ask to become one
if (!mDpm.isAdminActive(deviceAdmin) &&
mDpm.isDeviceOwnerApp(getPackageName())) {
Log.v(TAG, "Not device admin. Asking device owner to become one.");
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, deviceAdmin);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
"You need to be a device admin to enable kiosk mode.");
startActivity(intent);
}
// Device owner and admin : enter kiosk mode
else {
mDpm.setLockTaskPackages(deviceAdmin, new String[]{
getPackageName(), /** PUT OTHER PACKAGE NAMES HERE! */
});
startLockTask();
}
}
// Not device owner - can't access anything
else {
Log.v(TAG, "Not device owner");
Toast.makeText(this, "Not device owner", Toast.LENGTH_SHORT).show();
}
}
당신이해야 할 모든 당신이 mDpm.setLockTaskPackages()
에서 만든 위의 String[]
에서 키오스크 모드에서 실행 할 다른 애플리케이션의 패키지 이름을 넣어. 다음으로 다른 신청서에 인 텐트를 보내기 전에 stopLockTask()
으로 전화하십시오. 그렇지 않으면 이미 잠겨 있기 때문에이 앱에서 다른 곳으로 이동할 수 없습니다.
그런 다음 String[]
에있는 해당 응용 프로그램에서 startLockTask()
으로 전화하면됩니다. 앱을 고정 할 것인지 묻는 대신에 집 및 최근 앱 버튼이 사라지고 바로 키오스크 모드로 잠글 것입니다. 완료되면 stopLockTask()
에 전화하는 것을 잊지 마십시오!