[英]Android 8.1 (API 27) - Keyboard not showing in Kiosk-mode app after reboot
[英]Quitbutton for Kiosk-Mode App
我正在尋找用於退出Android上的kioskmode應用程序的解決方案。
Out應用程序正在Kiosk模式下運行,以防止通過按返回或Home鍵意外關閉,但是我們需要根據要求將其關閉。 有人對此有解決方案嗎?
我們通過添加來實現et信息亭模式
AndroidManifest.xml中:
<uses-permission android:name="android.permission.REORDER_TASKS"/>
[...]android:theme="@android:style/Theme.NoTitleBar">[...]
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT"/>
我使用以下代碼:
public void getDefaultLauncher()
{
final Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
PackageManager pm = getPackageManager();
final List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
pm.clearPackagePreferredActivities(getApplicationContext().getPackageName());
for(ResolveInfo ri : list)
{
if(!ri.activityInfo.packageName.equals(getApplicationContext().getPackageName()))
{
startSpecificActivity(ri);
return;
}
}
}
private void startSpecificActivity(ResolveInfo launchable)
{
ActivityInfo activity=launchable.activityInfo;
ComponentName name=new ComponentName(activity.applicationInfo.packageName, activity.name);
Intent i=new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
i.setComponent(name);
startActivity(i);
}
也許它也對您有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.