Example usage for android.content Intent ACTION_AIRPLANE_MODE_CHANGED

List of usage examples for android.content Intent ACTION_AIRPLANE_MODE_CHANGED

Introduction

In this page you can find the example usage for android.content Intent ACTION_AIRPLANE_MODE_CHANGED.

Prototype

String ACTION_AIRPLANE_MODE_CHANGED

To view the source code for android.content Intent ACTION_AIRPLANE_MODE_CHANGED.

Click Source Link

Document

Broadcast Action: The user has switched the phone into or out of Airplane Mode.

Usage

From source file:net.kidlogger.kidlogger.KLService.java

public void setupLogging() {
    // Set up GPS / Network logging      
    if (Settings.loggingGps(this)) {
        startGpsUpdates();//w  ww .  j a v  a  2 s  .c o  m
        gpsOn = true;
    }

    // Set up WiFi logging
    if (Settings.loggingWifi(this)) {
        wifiReceiver = new WifiReceiver(this);
        registerReceiver(wifiReceiver, new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION));
        wifiOn = true;
    }

    // Set up SMS logging
    if (Settings.loggingSms(this)) {
        smsObserver = new SmsObserver(this, handlering);
        IntentFilter smsFilter = new IntentFilter(SMS_RECEIVED);
        registerReceiver(smsObserver.inSms, smsFilter);
        smsOn = true;
    }

    // Set up Calls logging
    if (Settings.loggingCalls(this)) {
        IntentFilter callsFilter = new IntentFilter(TelephonyManager.ACTION_PHONE_STATE_CHANGED);

        callsReceiver = new CallsReceiver(this);
        registerReceiver(callsReceiver, callsFilter);
        callOn = true;
    }

    // Set up Idle logging
    IntentFilter idleFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
    idleFilter.addAction(Intent.ACTION_USER_PRESENT);

    idleReceiver = new IdleReceiver(this);
    registerReceiver(idleReceiver, idleFilter);
    idleOn = true;
    /*if(Settings.loggingIdle(this)){
       IntentFilter idleFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
       idleFilter.addAction(Intent.ACTION_USER_PRESENT);
               
       idleReceiver = new IdleReceiver(this);
       registerReceiver(idleReceiver, idleFilter);
       idleOn = true;
    }*/

    // Set up URL logging
    if (Settings.loggingUrl(this)) {
        urlObserver = new HistoryObserver(this, handlering);
        urlOn = true;
    }

    // Set up USB logging
    if (Settings.loggingUsb(this)) {
        IntentFilter usbFilter = new IntentFilter(Intent.ACTION_UMS_CONNECTED);
        usbFilter.addAction(Intent.ACTION_UMS_DISCONNECTED);

        usbReceiver = new UsbReceiver(this);
        registerReceiver(usbReceiver, usbFilter);
        usbOn = true;
    }

    // Set up Tasks logging
    if (logTask) {
        // Check if a new Application was started
        taskScan = new Runnable() {
            public void run() {
                new Thread(new Runnable() {
                    public void run() {
                        doScanTask();
                    }
                }).start();
                if (userPresent) {
                    handleTask.postDelayed(this, SCAN_TASK_TIME);
                    scanningTask = true;
                } else {
                    scanningTask = false;
                }
            }
        };
        handleTask.postDelayed(taskScan, SCAN_TASK_TIME);
        taskOn = true;
    }

    // Set up Clipboard logging
    if (logClip) {
        // Scan clipboard content, only first 30 characters
        clipboardScan = new Runnable() {
            public void run() {
                new Thread(new Runnable() {
                    public void run() {
                        doScanClipboard();
                    }
                }).start();
                if (userPresent) {
                    handleClipb.postDelayed(this, SCAN_CLIP_TIME);
                    scanningClip = true;
                } else {
                    scanningClip = false;
                }
            }
        };
        handleClipb.postDelayed(clipboardScan, SCAN_CLIP_TIME);
        clipOn = true;
    }

    // Set up Power logging
    if (Settings.loggingPower(this)) {
        IntentFilter powerFilter = new IntentFilter(Intent.ACTION_SHUTDOWN);

        powerReceiver = new ShutdownReceiver(this);
        registerReceiver(powerReceiver, powerFilter);
        powerOn = true;
    }

    // Set up Memory Card logging
    if (Settings.loggingMedia(this)) {
        IntentFilter mediaFilter = new IntentFilter(Intent.ACTION_MEDIA_REMOVED);
        mediaFilter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);
        mediaFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
        mediaFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
        mediaFilter.addAction(Intent.ACTION_MEDIA_SHARED);
        mediaFilter.addDataScheme("file");

        mediaReceiver = new MediaReceiver(this);
        registerReceiver(mediaReceiver, mediaFilter);

        mediaOn = true;
    }

    // Set up GSM logging
    if (Settings.loggingGsm(this)) {
        gsmObserver = new GsmObserver(this);
        telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        telManager.listen(gsmObserver,
                PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_CELL_LOCATION);
        gsmOn = true;
    }

    // Set up Airplane mode receiver
    if (Settings.loggingAir(this)) {
        IntentFilter airFilter = new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);

        airReceiver = new AirplaneReceiver(this);
        registerReceiver(airReceiver, airFilter);
        airOn = true;
    }

    // Set up Photos logging
    if (Settings.loggingPhotos(this)) {
        photoObserver = new PhotoObserver(this, this, handlering);
        photoOn = true;
    }

    // Set up SliceMultimediaFile
    if (Settings.uploadPhotos(this) || Settings.uploadRecords(this)) {
        mediaSlicer = new SliceMultimediaFile(this);
    }

    // Set up ConnectivityReceiver
    mConReceiver = new ConnectivityReceiver(this);
    registerReceiver(mConReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));

    // Ser up CallIntentReceiver
    //outCallReceiver = new CallIntentReceiver();
    //registerReceiver(outCallReceiver, new IntentFilter(KLService.OUTGOING_CALL));
}

From source file:saphion.services.ForegroundService.java

@SuppressWarnings("deprecation")
@Override/*from   w  w  w  . j  a va2s. c  o m*/
public void onCreate() {

    mPref = ForegroundService.this.getSharedPreferences(PREF_NAME, MODE_MULTI_PROCESS);

    // receive ACTION_BATTERY_CHANGED.
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_BATTERY_CHANGED);
    filter.addAction(Intent.ACTION_POWER_CONNECTED);
    filter.addAction(Intent.ACTION_POWER_DISCONNECTED);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    filter.addAction(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intents.MYBAT_INTENT);
    filter.addAction(Intents.TORCH_ON);
    filter.addAction(Intents.TORCH_OFF);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
        filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
        filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
        filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
        filter.addAction(ConnectivityManager.ACTION_BACKGROUND_DATA_SETTING_CHANGED);
        filter.addAction(Intents.SWITCHER_INTENT);
        filter.addAction(Intents.SWITCHER_NOTI);
        filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
    }
    registerReceiver(mBroadcastReceiver, filter);

    readbattery();

    mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    if (!mPref.getBoolean(PreferenceHelper.NOTIFICATION_ENABLE, true)) {
        mNM.cancelAll();// .notify(id, notification);

    }
    try {
        mStartForeground = getClass().getMethod("startForeground", mStartForegroundSignature);
        mStopForeground = getClass().getMethod("stopForeground", mStopForegroundSignature);
        return;
    } catch (NoSuchMethodException e) {
        // Running on an older platform.
        mStartForeground = mStopForeground = null;
    }
    try {
        mSetForeground = getClass().getMethod("setForeground", mSetForegroundSignature);
    } catch (NoSuchMethodException e) {
        throw new IllegalStateException("OS doesn't have Service.startForeground OR Service.setForeground!");
    }
}

From source file:ua.mkh.settings.full.MainActivity.java

public void onClick(View v) {
    int id = v.getId();

    if (id == R.id.ButtonWifi) {
        Intent intent = new Intent(this, ActivityWifi.class);
        startActivity(intent);//from   www .j a v  a 2  s .c om
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonBluetooth) {
        Intent intent1 = new Intent(this, ActivityBth.class);
        startActivity(intent1);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonSota) {
        Intent intent2 = new Intent(this, ActivitySota.class);
        startActivity(intent2);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonDisturb) {
        Intent intent11 = new Intent(this, ActivityDisturb.class);
        startActivity(intent11);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonOperator) {

        Intent settingsIntent = new Intent(this, ActivityOperator.class);
        startActivity(settingsIntent);
        overridePendingTransition(center_to_left, center_to_left2);

    }

    else if (id == R.id.ButtonZvuki) {
        Intent intent4 = new Intent(this, ActivityZvuki.class);
        startActivity(intent4);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonOboi) {
        Intent intent5 = new Intent(this, ActivityOboi.class);
        //intent5.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
        startActivity(intent5);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonOsnova) {
        Intent intent6 = new Intent(this, ActivityOsnova.class);
        intent6.putExtra("verintent", VerIntent);
        startActivity(intent6);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonPasscode) {
        Intent settingsIntent = new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS);
        startActivity(settingsIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    } else if (id == R.id.ButtonBattery) {
        Intent intent4 = new Intent(this, ActivityBattery.class);
        startActivity(intent4);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonPrivacy) {
        Intent settingsIntent = new Intent(android.provider.Settings.ACTION_PRIVACY_SETTINGS);
        startActivity(settingsIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ToggleButton01) {
        if (tb_am.isChecked())//means this is the request to turn ON AIRPLANE mode
        {
            if (OS > 16) {
                Intent settingsIntent = new Intent(android.provider.Settings.ACTION_AIRPLANE_MODE_SETTINGS);
                startActivity(settingsIntent);
                overridePendingTransition(center_to_left, center_to_left2);
            } else {
                Settings.System.putInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 1);//Turning ON Airplane mode.
                Intent intent10 = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);//creating intent and Specifying action for AIRPLANE mode.
                intent10.putExtra("state", true);////indicate the "state" of airplane mode is changed to ON
                sendBroadcast(intent10);//Broadcasting and Intent
                //
                btn_sota.setTextColor(Color.parseColor("#808080"));
                btn_operator.setTextColor(Color.parseColor("#808080"));
                btn_gps.setTextColor(Color.parseColor("#808080"));
                btn_sota.setClickable(false);
                btn_operator.setClickable(false);
                btn_gps.setClickable(false);
            }
        } else//means this is the request to turn OFF AIRPLANE mode
        {
            if (OS > 16) {
                Intent settingsIntent = new Intent(android.provider.Settings.ACTION_AIRPLANE_MODE_SETTINGS);
                startActivity(settingsIntent);
                overridePendingTransition(center_to_left, center_to_left2);
            } else {
                Settings.System.putInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0);//Turning OFF Airplane mode.
                Intent intent9 = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);//creating intent and Specifying action for AIRPLANE mode.
                intent9.putExtra("state", false);//indicate the "state" of airplane mode is changed to OFF
                sendBroadcast(intent9);//Broadcasting and Intent
                //
                btn_sota.setTextColor(Color.parseColor("#000000"));
                btn_operator.setTextColor(Color.parseColor("#000000"));
                btn_gps.setTextColor(Color.parseColor("#000000"));
                btn_sota.setClickable(true);
                btn_operator.setClickable(true);
                btn_gps.setClickable(true);
            }
        }
    }

    else if (id == R.id.ButtonGeo) {

        Intent intent8 = new Intent(this, ActivityGeo.class);
        startActivity(intent8);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonNotification) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(notifications_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonControl) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(control_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonMail) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(mail_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonNotes) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(notes_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonPhone) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(phone_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonMessages) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(messages_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonSafari) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(safari_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonMusic) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(music_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonCompass) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(compass_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonWeather) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(weather_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonGameCenter) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(gamecenter_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonMaps) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(maps_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.Button02) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(new1_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.Button03) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(new2_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.Button04) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(new3_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.Button05) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(new4_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonCloud) {
        Intent intent10 = new Intent(this, ActivityiCloud.class);
        startActivity(intent10);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonTunes) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(itunes_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.Button06) {
        Intent intent10 = new Intent(this, ActivityVPN.class);
        startActivity(intent10);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonDisplay) {
        Intent intent12 = new Intent(this, ActivityBrightness.class);
        startActivity(intent12);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonVk) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(vk_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonViber) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(viber_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonOk) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(ok_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonSkype) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(skype_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonWhatsapp) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(whatsapp_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonTwitter) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(twitter_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonFacebook) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(facebook_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }

    else if (id == R.id.ButtonInstagram) {
        Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(instagram_app);
        startActivity(LaunchIntent);
        overridePendingTransition(center_to_left, center_to_left2);
    }
}

From source file:com.tct.mail.ui.ConversationListFragment.java

@Override
public void onResume() {
    super.onResume();

    if (!isCursorReadyToShow()) {
        // If the cursor got reset, let's reset the analytics state variable and show the list
        // view since we are waiting for load again
        mInitialCursorLoading = true;//from   www .j av a  2  s  .com
        showListView();
    }

    final ConversationCursor conversationCursor = getConversationListCursor();
    if (conversationCursor != null) {
        conversationCursor.handleNotificationActions();

        restoreLastScrolledPosition();
    }

    mSelectedSet.addObserver(mConversationSetObserver);
    //TS: wenggangjin 2015-01-26 EMAIL BUGFIX_-908180 MOD_S
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
    filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);//TS: junwei-xu 2015-1-26 EMAIL BUGFIX_898211 ADD
    getActivity().registerReceiver(myReceiver, filter);
    //TS: wenggangjin 2015-01-26 EMAIL BUGFIX_-908180 MOD_E
}