如何禁用飞行模式平板电脑支持4.4.2 [英] How Do I Disable AIRPLANE MODE tablet supports 4.4.2

查看:395
本文介绍了如何禁用飞行模式平板电脑支持4.4.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要停用 飞行模式在我的应用程序日期时间设置,为此,我使用了这些意图过滤器,但它们作品

 <使用-权限的Andr​​oid:名称=android.permission.WRITE_SETTINGS/>

        <意向滤光器>
            <作用机器人:名称=android.intent.action.MAIN/>
            <类机器人:名称=android.intent.category.HOME/>
            <类机器人:名称=android.intent.category.DEFAULT/>
            <类机器人:名称=android.intent.category.LAUNCHER/>
        &所述; /意图滤光器>

        <意向滤光器>
           <作用机器人:名称=android.settings.AIRPLANE_MODE_SETTINGS/>
           <类机器人:名称=android.intent.category.DEFAULT/>
        &所述; /意图滤光器>

        <意向滤光器>
           <作用机器人:名称=android.settings.DATE_SETTINGS/>
           <类机器人:名称=android.intent.category.DEFAULT/>
        &所述; /意图滤光器>
 

不过,早些时候,我成功的禁用 设置通过以下意图过滤器

 <意向滤光器>
            <作用机器人:名称=android.settings.SETTINGS/>
            <类机器人:名称=android.intent.category.DEFAULT/>
        &所述; /意图滤光器>
 

解决方案

对于4.2及以上版本,你是不是能够通过编程控制飞行模式。

您可以如果用户有一个根深蒂固的设备所以才这样做。

由于写的API文档:

由Settings.System定义的一些设备设置现在只读。如果你的应用程序试图写在Settings.System定义更改设置有搬到 Settings.Global ,在安卓4.2 和更高的运行时,写操作将静默失败。 即使你对安卓值:targetSdkVersion 安卓的minSdkVersion 低于 17 ,您的应用程序无法修改的Andr​​oid 4.2运行时已经转移到 Settings.Global 高。

I have to disable AIRPLANE MODE and DATE TIME SETTINGS in my app, for that i used these intent filters but none of them works for me

        <uses-permission android:name="android.permission.WRITE_SETTINGS" />

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.HOME" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <intent-filter>
           <action android:name="android.settings.AIRPLANE_MODE_SETTINGS" />
           <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

        <intent-filter>
           <action android:name="android.settings.DATE_SETTINGS" />
           <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

But earlier i successfully disabled Settings by using below intent-filter

        <intent-filter >
            <action android:name="android.settings.SETTINGS" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

解决方案

As for version 4.2 and up you are not able to control the Airplane mode programmatically.

You are able to do so only if the user has a rooted device.

As written in the API DOC:

"Some device settings defined by Settings.System are now read-only. If your app attempts to write changes to settings defined in Settings.System that have moved to Settings.Global, the write operation will silently fail when running on Android 4.2 and higher. Even if your value for android:targetSdkVersion and android:minSdkVersion is lower than 17, your app is not able to modify the settings that have moved to Settings.Global when running on Android 4.2 and higher."

这篇关于如何禁用飞行模式平板电脑支持4.4.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆