简体   繁体   English

应用程序可在Android上关闭飞行模式

[英]App to turn off airplane mode on android

First little background why i need to write this app. 首先,我需要编写此应用程序的小背景。 My phone got wet and unfortunately screen doesn't work now (I can't see anything and I can't press anything). 我的手机弄湿了,不幸的是屏幕现在无法工作(我什么也看不到,也不能按任何东西)。 Phone has airplane mode turn on so my photos cannot synchronize. 手机已开启飞行模式,因此我的照片无法同步。 I cannot connect with USB cable because it is in "Only recharge state". 我的USB电缆处于“仅充电”状态,因此无法连接。 USB debugging is turn off so I cannot connect with adb to turn off airplane mode. USB调试已关闭,因此我无法与adb连接以关闭飞行模式。 But there is a little light in a tunnel. 但是隧道里有一点光。 There is WIFI working. 有WIFI工作。 I hear a sound when it connects to my network so I know it's working. 当它连接到我的网络时,我听到声音,所以我知道它正在工作。 My idea is to write a simple app that will turn off airplane mode. 我的想法是编写一个简单的应用程序来关闭飞行模式。 I'll install it from PC using Play Store but I need a way to turn it on. 我将使用Play商店从PC安装它,但我需要一种打开它的方法。 I think it can be done by registering this app as a listener to some system call. 我认为可以通过将该应用程序注册为某个系统调用的侦听器来完成。 Can Play Store register app as a listener without a need to run this app? Play商店是否可以将应用注册为监听器而无需运行此应用?

Do you think that's all possible? 您认为这一切都有可能吗? Maybe someone has other idea? 也许有人有其他想法?

Thanks! 谢谢!

From android 4.2: This is no longer possible, except by apps that are signed by the firmware signing key or are installed on the system partition (typically by a rooted device user). 从android 4.2开始:除通过固件签名密钥签名的应用程序或已安装在系统分区上的应用程序(通常由具有root权限的设备用户使用)之外,这不再可能。 (Copied from here ) (从这里复制)

Android 4.1 and below: Android 4.1及以下版本:

// read the airplane mode setting
boolean isEnabled = Settings.System.getInt(
      getContentResolver(), 
      Settings.System.AIRPLANE_MODE_ON, 0) == 1;

// toggle airplane mode
Settings.System.putInt(
      getContentResolver(),
      Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1);

// Post an intent to reload
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", !isEnabled);
sendBroadcast(intent);

Also add the WRITE_SETTINGS permission to your android manifest 还要将WRITE_SETTINGS权限添加到您的Android清单中

Copied from here 这里复制

You may be able to open the settings with this code and tell the user to disable airplane mode: 您可能可以使用以下代码打开设置,并告诉用户禁用飞行模式:

if (android.os.Build.VERSION.SDK_INT < 17){
    try{
        Intent intentAirplaneMode = new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS);
        intentAirplaneMode.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intentAirplaneMode);
    }
    catch (ActivityNotFoundException e){
        Log.e("exception", e + "");
    }
}
else{
    Intent intent1 = new Intent("android.settings.WIRELESS_SETTINGS");
    intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent1);
}

Coped from here 这里应对

Currently I am not aware how to programmatically build an app to turn on/off system settings, but what I can tell you is, there is an app already available in Play Store which I feel does the same thing. 目前,我尚不知道如何以编程方式构建用于打开/关闭系统设置的应用程序,但是我可以告诉你的是,Play Store中已经有一个应用程序,我觉得它也可以做到这一点。

You can have a look at this app, called Trigger . 您可以看看这个名为Trigger的应用程序。

https://play.google.com/store/apps/details?id=com.jwsoft.nfcactionlauncher&hl=en https://play.google.com/store/apps/details?id=com.jwsoft.nfcactionlauncher&hl=en

All you have to do is to create a task to turn the Airplane mode Off and that task can be triggered through Wi-Fi. 您要做的只是创建一个任务来关闭飞行模式,然后可以通过Wi-Fi触发该任务。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM