android.content.Intent#ACTION_AIRPLANE_MODE_CHANGED源码实例Demo

下面列出了android.content.Intent#ACTION_AIRPLANE_MODE_CHANGED 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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);
    }
}
 
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();
        }
    }
 
源代码3 项目: android_9.0.0_r45   文件: LegacyGlobalActions.java
/**
 * 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;
    }
}
 
源代码4 项目: Easer   文件: AirplaneModeLoader.java
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;
}
 
源代码5 项目: PhoneProfilesPlus   文件: TwilightScanner.java
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();
}
 
源代码6 项目: Status   文件: AirplaneModeIconData.java
@Override
public IntentFilter getIntentFilter() {
    return new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
}
 
源代码7 项目: DoingDaily   文件: NetworkUtil.java
/**
 * 设置飞行模式状态
 * 需添加权限:
 * <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);
}
 
 方法所在类
 同类方法