【问题标题】:Quitbutton for Kiosk-Mode AppKiosk 模式应用程序的退出按钮
【发布时间】:2014-05-21 18:59:04
【问题描述】:

我正在寻找在 Android 上退出 kioskmode-application 的解决方案。

Out 应用程序正在 Kiosk 模式下运行,以防止通过按返回或主页按钮意外关闭,但我们需要根据请求将其关闭。有没有人可以解决这个问题?

我们通过添加实现自助服务终端模式

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"/>

【问题讨论】:

    标签: android android-layout kiosk kiosk-mode


    【解决方案1】:

    我使用这个代码:

    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);
    }
    

    也许它也适合你。

    【讨论】:

      猜你喜欢
      • 2015-12-30
      • 1970-01-01
      • 2014-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多