Java Code Examples for android.content.Intent#ACTION_AIRPLANE_MODE_CHANGED

The following examples show how to use android.content.Intent#ACTION_AIRPLANE_MODE_CHANGED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmergencyAffordanceService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void onBootPhase(int phase) {
    if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
        mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
        mVoiceCapable = mTelephonyManager.isVoiceCapable();
        if (!mVoiceCapable) {
            updateEmergencyAffordanceNeeded();
            return;
        }
        mSubscriptionManager = SubscriptionManager.from(mContext);
        HandlerThread thread = new HandlerThread(TAG);
        thread.start();
        mHandler = new MyHandler(thread.getLooper());
        mHandler.obtainMessage(INITIALIZE_STATE).sendToTarget();
        startScanning();
        IntentFilter filter = new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
        mContext.registerReceiver(mAirplaneModeReceiver, filter);
        mSubscriptionManager.addOnSubscriptionsChangedListener(mSubscriptionChangedListener);
    }
}
 
Example 2
Source File: OBConnectionManager.java    From GLEXP-Team-onebillion with Apache License 2.0 6 votes vote down vote up
private void connectToNetwork_disconnect ()
    {
        final WifiManager wfMgr = (WifiManager) MainActivity.mainActivity.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
        //
        MainActivity.log("OBConnectionManager.connectToNetWork_complete.block complete");
        //
        MainActivity.log("OBConnectionManager.connectToNetWork_complete.disable wifi");
        wfMgr.setWifiEnabled(false);
        //
        try
        {
            MainActivity.log("OBConnectionManager.connectToNetWork_complete.enable airplane mode");
            Settings.Global.putInt(MainActivity.mainActivity.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
            Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
            intent.putExtra("state", true);
            MainActivity.mainActivity.sendBroadcast(intent);
        }
        catch (Exception e)
        {
            MainActivity.log("Exception caught while trying to set the airplane mode");
//            e.printStackTrace();
        }
    }
 
Example 3
Source File: LegacyGlobalActions.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Change the airplane mode system setting
 */
private void changeAirplaneModeSystemSetting(boolean on) {
    Settings.Global.putInt(
            mContext.getContentResolver(),
            Settings.Global.AIRPLANE_MODE_ON,
            on ? 1 : 0);
    Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
    intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
    intent.putExtra("state", on);
    mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
    if (!mHasTelephony) {
        mAirplaneState = on ? ToggleAction.State.On : ToggleAction.State.Off;
    }
}
 
Example 4
Source File: AirplaneModeLoader.java    From Easer with GNU General Public License v3.0 5 votes vote down vote up
private boolean switchBefore17(boolean newState) {
    Settings.System.putInt(
            context.getContentResolver(),
            Settings.System.AIRPLANE_MODE_ON, newState ? 1 : 0);

    Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
    intent.putExtra("state", !newState);
    context.sendBroadcast(intent);
    return true;
}
 
Example 5
Source File: TwilightScanner.java    From PhoneProfilesPlus with Apache License 2.0 5 votes vote down vote up
void start() {
    IntentFilter filter = new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
    filter.addAction(Intent.ACTION_TIME_CHANGED);
    filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
    filter.addAction(TwilightScanner.ACTION_UPDATE_TWILIGHT_STATE);
    context.registerReceiver(mUpdateLocationReceiver, filter);

    mLocationHandler.enableLocationUpdates();
}
 
Example 6
Source File: AirplaneModeIconData.java    From Status with Apache License 2.0 4 votes vote down vote up
@Override
public IntentFilter getIntentFilter() {
    return new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
}
 
Example 7
Source File: NetworkUtil.java    From DoingDaily with Apache License 2.0 3 votes vote down vote up
/**
 * 设置飞行模式状态
 * 需添加权限:
 * <pre>
 *     android.permission.WRITE_SETTINGS
 * </pre>
 *
 * @param context          上下文
 * @param isAirplaneModeOn 是否开启飞行模式
 */
public static void setAirplaneMode(Context context, boolean isAirplaneModeOn) {
    Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, isAirplaneModeOn ? 1 : 0);
    // 广播飞行模式的改变,让相应的程序可以处理
    // 不发送广播,在非飞行模式下,Android 2.2.1 上测试关闭了 WIFI,不关闭通话网络(GMS/GPRS等)
    // 不发送广播,在飞行模式下,Android 2.2.1 上测试无法关闭飞行模式
    Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
    context.sendBroadcast(intent);
}