Example usage for android.content Context POWER_SERVICE

List of usage examples for android.content Context POWER_SERVICE

Introduction

In this page you can find the example usage for android.content Context POWER_SERVICE.

Prototype

String POWER_SERVICE

To view the source code for android.content Context POWER_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.os.PowerManager for controlling power management, including "wake locks," which let you keep the device on while you're running long tasks.

Usage

From source file:com.wordpress.httpstheredefiningproductions.phonefinder.recorder.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    //initialize the thing that will keep the service running
    mgr = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
    //turn on the wakelock
    PowerManager.WakeLock wakeLock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
    wakeLock.acquire();/*from   www. j a  v a2s . com*/
    //start the notification
    startForeground(FOREGROUND_ID, buildForegroundNotification("Phone Finder"));
    try {
        //start the listening
        Message msg = new Message();
        msg.what = MSG_RECOGNIZER_START_LISTENING;
        mServerMessenger.send(msg);
    } catch (RemoteException e) {

    }
    //keep running the service:
    return START_STICKY;
}

From source file:cm.aptoide.pt.services.ServiceDownloadManager.java

@Override
public void onCreate() {
    if (!isRunning) {
        PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
        keepScreenOn = powerManager//from   w  w  w. j  ava  2  s.co m
                .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "Full Power");

        ongoingDownloads = new HashMap<Integer, ViewDownloadManagement>();
        completedDownloads = new HashMap<Integer, ViewDownloadManagement>();
        failedDownloads = new HashMap<Integer, ViewDownloadManagement>();

        globaDownloadStatus = new ViewDownload("local:\\GLOBAL");

        cachedThreadPool = Executors.newCachedThreadPool();

        helperDownload = new HelperDownload(this);
        isRunning = true;
    }
    super.onCreate();
}

From source file:com.sentaroh.android.SMBExplorer.FileIo.java

@SuppressWarnings("deprecation")
@Override//from w  ww.  j  av  a2s.  co m
public void run() {
    sendLogMsg("I", "Task has started.");

    final WakeLock wake_lock = ((PowerManager) mContext.getSystemService(Context.POWER_SERVICE))
            .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP
    //                         | PowerManager.ON_AFTER_RELEASE
                    , "SMBExplorer-ScreenOn");
    final WifiLock wifi_lock = ((WifiManager) mContext.getSystemService(Context.WIFI_SERVICE))
            .createWifiLock(WifiManager.WIFI_MODE_FULL, "SMBExplorer-wifi");

    if (mGp.fileIoWakeLockRequired)
        wake_lock.acquire();
    if (mGp.fileIoWifiLockRequired)
        wifi_lock.acquire();

    try {
        if (fileIoArea == null)
            fileIoArea = new byte[SMB_BUFF_SIZE];//4096*64];

        taskBeginTime = System.currentTimeMillis();

        waitMediaScanner(true);

        boolean fileioTaskResultOk = false;
        for (int i = 0; i < fileioLinkParm.size(); i++) {
            fileioTaskResultOk = fileOperation(fileioLinkParm.get(i));
            if (!fileioTaskResultOk)
                break;
        }
        sendLogMsg("I", "Task was ended. fileioTaskResultOk=" + fileioTaskResultOk + ", fileioThreadCtrl:"
                + fileioThreadCtrl.toString());
        sendLogMsg("I", "Task elapsed time=" + (System.currentTimeMillis() - taskBeginTime));
        if (fileioTaskResultOk) {
            fileioThreadCtrl.setThreadResultSuccess();
            sendDebugLogMsg(1, "I", "Task was endeded without error.");
        } else if (fileioThreadCtrl.isEnabled()) {
            fileioThreadCtrl.setThreadResultError();
            sendLogMsg("W", "Task was ended with error.");
        } else {
            fileioThreadCtrl.setThreadResultCancelled();
            sendLogMsg("W", "Task was cancelled.");
        }
        fileioThreadCtrl.setDisabled();
        mediaScanner.disconnect();
        waitMediaScanner(false);

        uiHandler.post(new Runnable() {// UI thread
            @Override
            public void run() {
                notifyEvent.notifyToListener(true, null);
            }
        });
    } finally {
        if (wake_lock.isHeld())
            wake_lock.release();
        if (wifi_lock.isHeld())
            wifi_lock.release();
    }
}

From source file:com.sentaroh.android.SMBSync.SMBSyncMain.java

/** Called when the activity is first created. */
@Override// w  w  w .ja  v  a2 s  .c o m
public void onCreate(Bundle savedInstanceState) {
    //      StrictMode.enableDefaults();
    //      setTheme(android.R.style.Theme_Dialog);
    //      setTheme(android.R.style.Theme_Holo_Light);
    //      setTheme(android.R.style.Theme_Light);
    super.onCreate(savedInstanceState);
    //      requestWindowFeature(Window.FEATURE_NO_TITLE);

    mCurrentLocal = getResources().getConfiguration().locale;

    setContentView(R.layout.main);
    mContext = this;
    mGp = (GlobalParameters) getApplication();
    mGp.enableMainUi = true;
    mGp.uiHandler = new Handler();
    mGp.SMBSync_External_Root_Dir = LocalMountPoint.getExternalStorageDir();

    startService(new Intent(mContext, SMBSyncService.class));

    mDimScreenWakelock = ((PowerManager) getSystemService(Context.POWER_SERVICE))
            .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK
                    //                    PowerManager.PARTIAL_WAKE_LOCK
                    | PowerManager.ACQUIRE_CAUSES_WAKEUP
    //                         | PowerManager.ON_AFTER_RELEASE
                    , "SMBSync-ScreenOn");

    mWifiLock = ((WifiManager) mContext.getSystemService(Context.WIFI_SERVICE))
            .createWifiLock(WifiManager.WIFI_MODE_FULL, "SMBSync-wifi");

    if (tcService == null)
        tcService = new ThreadCtrl();

    //      if (Build.VERSION.SDK_INT>=14)
    //         this.getActionBar().setHomeButtonEnabled(false);

    if (util == null)
        util = new SMBSyncUtil(this.getApplicationContext(), "Main", mGp);
    util.setActivityIsForeground(true);

    if (ccMenu == null)
        ccMenu = new CustomContextMenu(getResources(), getSupportFragmentManager());
    commonDlg = new CommonDialog(mContext, getSupportFragmentManager());

    createTabView();
    loadMsgString();
    initSettingsParms();
    applySettingParms();
    initJcifsOption();

    checkExternalStorage();
    mGp.SMBSync_Internal_Root_Dir = getFilesDir().toString();

    util.openLogFile();

    initAdapterAndView();

    util.addDebugLogMsg(1, "I", "onCreate entered, " + "resartStatus=" + restartStatus
            + ", isActivityForeground=" + util.isActivityForeground());

    getApplVersionName();

    if (profMaint == null)
        profMaint = new ProfileMaintenance(util, this, commonDlg, ccMenu, mGp);

    SchedulerMain.setTimer(mContext, SCHEDULER_INTENT_SET_TIMER_IF_NOT_SET);
}

From source file:ca.nehil.rter.streamingapp.StreamingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_streaming);

    poilist = new ArrayList<POI>();

    /* Retrieve server URL from stored app values */
    storedValues = getSharedPreferences(getString(R.string.sharedPreferences_filename), MODE_PRIVATE);
    server_url = storedValues.getString("server_url", "not-set");

    /* Orientation listenever implementation to orient video */
    myOrientationEventListener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL) {
        @Override//from  www.j a va  2s .c om
        public void onOrientationChanged(int orientation) {
            int rotation = getWindowManager().getDefaultDisplay().getRotation();
            if (rotation == Surface.ROTATION_270) {
                flipVideo = true;
            } else {
                flipVideo = false;
            }
        }
    };
    myOrientationEventListener.enable();

    /* Retrieve user auth data from cookie */
    cookies = getSharedPreferences("RterUserCreds", MODE_PRIVATE);
    cookieEditor = cookies.edit();
    setUsername = cookies.getString("Username", "not-set");
    setRterCredentials = cookies.getString("RterCreds", "not-set");
    if (setRterCredentials.equalsIgnoreCase("not-set") || setRterCredentials == null) {
        Log.e("PREFS", "Login Not successful, please restart");
    }
    Log.d("PREFS", "Prefs ==> rter_Creds:" + setRterCredentials);

    URL serverURL = null;
    try {
        serverURL = new URL(server_url);
        CookieStore myCookieStore = new BasicCookieStore();
        client.setCookieStore(myCookieStore);
        String[] credentials = setRterCredentials.split("=", 2);
        BasicClientCookie newCookie = new BasicClientCookie(credentials[0], credentials[1]);
        newCookie.setDomain(serverURL.getHost());
        newCookie.setPath("/");
        myCookieStore.addCookie(newCookie);
        mSensorSource = SensorSource.getInstance(this, GET_LOCATION_FROM_SERVER, serverURL, setRterCredentials,
                setUsername);
        POIs = new POIList(this, serverURL, setRterCredentials, mSensorSource);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    overlay = new OverlayController(this, POIs, mSensorSource); // OpenGL overlay 

    /* Get location */

    Location location = mSensorSource.getLocation();
    if (location != null) {
        lati = (float) (location.getLatitude());
        longi = (float) (location.getLongitude());
    } else {
        Toast toast = Toast.makeText(this, "Location not available", Toast.LENGTH_LONG);
        toast.setGravity(Gravity.TOP, 0, 0);
        toast.show();
        lati = (float) (45.505958f); // Hard coded location for testing purposes.
        longi = (float) (-73.576254f);
    }

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, CLASS_LABEL);
    mWakeLock.acquire();

    /* Test, set desired orienation to north */
    overlay.setDesiredOrientation(0.0f);
}

From source file:com.snappy.GCMIntentService.java

/**
 * Issues a notification to inform the user that server has sent a message.
 *///from  www  .j ava2 s.com
private void generateNotification(Context context, String message, String fromName, Bundle pushExtras,
        String body) {

    db = new LocalDB(context);
    List<LocalMessage> myMessages = db.getAllMessages();

    // Open a new activity called GCMMessageView
    Intent intento = new Intent(this, SplashScreenActivity.class);
    intento.replaceExtras(pushExtras);
    // Pass data to the new activity
    intento.putExtra(Const.PUSH_INTENT, true);
    intento.setAction(Long.toString(System.currentTimeMillis()));
    intento.addFlags(
            Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_FROM_BACKGROUND | Intent.FLAG_ACTIVITY_TASK_ON_HOME);

    // Starts the activity on notification click
    PendingIntent pIntent = PendingIntent.getActivity(this, 0, intento, PendingIntent.FLAG_UPDATE_CURRENT);

    // Create the notification with a notification builder
    NotificationCompat.Builder notification = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.icon_notification).setWhen(System.currentTimeMillis())
            .setContentTitle(myMessages.size() + " " + this.getString(R.string.push_new_message_message))
            .setStyle(new NotificationCompat.BigTextStyle().bigText("Mas mensajes")).setAutoCancel(true)
            .setDefaults(
                    Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS)
            .setContentText(body).setContentIntent(pIntent);

    NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
    inboxStyle.setBigContentTitle(myMessages.size() + " " + this.getString(R.string.push_new_message_message));

    for (int i = 0; i < myMessages.size(); i++) {

        inboxStyle.addLine(myMessages.get(i).getMessage());
    }

    notification.setStyle(inboxStyle);

    // Remove the notification on click
    //notification.flags |= Notification.FLAG_AUTO_CANCEL;
    //notification.defaults |= Notification.DEFAULT_VIBRATE;
    //notification.defaults |= Notification.DEFAULT_SOUND;
    //notification.defaults |= Notification.DEFAULT_LIGHTS;

    NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    manager.notify(R.string.app_name, notification.build());
    {
        // Wake Android Device when notification received
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);

        final PowerManager.WakeLock mWakelock = pm
                .newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "GCM_PUSH");
        mWakelock.acquire();
        // Timer before putting Android Device to sleep mode.
        Timer timer = new Timer();
        TimerTask task = new TimerTask() {
            public void run() {
                mWakelock.release();
            }
        };
        timer.schedule(task, 5000);
    }
}

From source file:android_network.hetnet.vpn_service.Util.java

public static boolean isInteractive(Context context) {
    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT_WATCH)
        return (pm != null && pm.isScreenOn());
    else/*from   w  w  w .java2  s  . c o  m*/
        return (pm != null && pm.isInteractive());
}

From source file:org.protocoderrunner.base.BaseActivity.java

public void setWakeLock(boolean b) {

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    if (wl == null) {
        wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
        if (b) {//from   w w  w.j  a v a 2s . c om
            wl.acquire();
        }
    } else {
        if (!b) {
            wl.release();
        }
    }

}

From source file:com.daiv.android.twitter.utils.NotificationUtils.java

public static void refreshNotification(Context context, boolean noTimeline) {
    AppSettings settings = AppSettings.getInstance(context);

    SharedPreferences sharedPrefs = context.getSharedPreferences("com.daiv.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
    int currentAccount = sharedPrefs.getInt("current_account", 1);

    //int[] unreadCounts = new int[] {4, 1, 2}; // for testing
    int[] unreadCounts = getUnreads(context);

    int timeline = unreadCounts[0];
    int realTimelineCount = timeline;

    // if they don't want that type of notification, simply set it to zero
    if (!settings.timelineNot || (settings.pushNotifications && settings.liveStreaming) || noTimeline) {
        unreadCounts[0] = 0;/*ww  w.j a va 2s .c  o m*/
    }
    if (!settings.mentionsNot) {
        unreadCounts[1] = 0;
    }
    if (!settings.dmsNot) {
        unreadCounts[2] = 0;
    }

    if (unreadCounts[0] == 0 && unreadCounts[1] == 0 && unreadCounts[2] == 0) {

    } else {
        Intent markRead = new Intent(context, MarkReadService.class);
        PendingIntent readPending = PendingIntent.getService(context, 0, markRead, 0);

        String shortText = getShortText(unreadCounts, context, currentAccount);
        String longText = getLongText(unreadCounts, context, currentAccount);
        // [0] is the full title and [1] is the screenname
        String[] title = getTitle(unreadCounts, context, currentAccount);
        boolean useExpanded = useExp(context);
        boolean addButton = addBtn(unreadCounts);

        if (title == null) {
            return;
        }

        Intent resultIntent;

        if (unreadCounts[1] != 0 && unreadCounts[0] == 0) {
            // it is a mention notification (could also have a direct message)
            resultIntent = new Intent(context, RedirectToMentions.class);
        } else {
            resultIntent = new Intent(context, MaterialMainActivity.class);
        }

        PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, 0);

        NotificationCompat.Builder mBuilder;

        Intent deleteIntent = new Intent(context, NotificationDeleteReceiverOne.class);

        mBuilder = new NotificationCompat.Builder(context).setContentTitle(title[0])
                .setContentText(TweetLinkUtils.removeColorHtml(shortText, settings))
                .setSmallIcon(R.drawable.ic_stat_icon).setLargeIcon(getIcon(context, unreadCounts, title[1]))
                .setContentIntent(resultPendingIntent).setAutoCancel(true)
                .setTicker(TweetLinkUtils.removeColorHtml(shortText, settings))
                .setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent, 0))
                .setPriority(NotificationCompat.PRIORITY_HIGH);

        if (unreadCounts[1] > 1 && unreadCounts[0] == 0 && unreadCounts[2] == 0) {
            // inbox style notification for mentions
            mBuilder.setStyle(getMentionsInboxStyle(unreadCounts[1], currentAccount, context,
                    TweetLinkUtils.removeColorHtml(shortText, settings)));
        } else if (unreadCounts[2] > 1 && unreadCounts[0] == 0 && unreadCounts[1] == 0) {
            // inbox style notification for direct messages
            mBuilder.setStyle(getDMInboxStyle(unreadCounts[1], currentAccount, context,
                    TweetLinkUtils.removeColorHtml(shortText, settings)));
        } else {
            // big text style for an unread count on timeline, mentions, and direct messages
            mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(Html.fromHtml(
                    settings.addonTheme ? longText.replaceAll("FF8800", settings.accentColor) : longText)));
        }

        // Pebble notification
        if (sharedPrefs.getBoolean("pebble_notification", false)) {
            sendAlertToPebble(context, title[0], shortText);
        }

        // Light Flow notification
        sendToLightFlow(context, title[0], shortText);

        int homeTweets = unreadCounts[0];
        int mentionsTweets = unreadCounts[1];
        int dmTweets = unreadCounts[2];

        int newC = 0;

        if (homeTweets > 0) {
            newC++;
        }
        if (mentionsTweets > 0) {
            newC++;
        }
        if (dmTweets > 0) {
            newC++;
        }

        if (settings.notifications && newC > 0) {

            if (settings.vibrate) {
                mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
            }

            if (settings.sound) {
                try {
                    mBuilder.setSound(Uri.parse(settings.ringtone));
                } catch (Exception e) {
                    mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
                }
            }

            if (settings.led)
                mBuilder.setLights(0xFFFFFF, 1000, 1000);

            // Get an instance of the NotificationManager service
            NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);

            if (addButton) { // the reply and read button should be shown

                Log.v("username_for_noti", title[1]);
                sharedPrefs.edit().putString("from_notification", "@" + title[1] + " " + title[2]).commit();
                MentionsDataSource data = MentionsDataSource.getInstance(context);
                long id = data.getLastIds(currentAccount)[0];
                PendingIntent replyPending = PendingIntent.getActivity(context, 0, null, 0);
                sharedPrefs.edit().putLong("from_notification_long", id).commit();
                sharedPrefs.edit()
                        .putString("from_notification_text",
                                "@" + title[1] + ": " + TweetLinkUtils.removeColorHtml(shortText, settings))
                        .commit();

                // Create the remote input
                RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
                        .setLabel("@" + title[1] + " ").build();

                // Create the notification action
                NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(
                        R.drawable.ic_action_reply_dark, context.getResources().getString(R.string.noti_reply),
                        replyPending).addRemoteInput(remoteInput).build();

                NotificationCompat.Action.Builder action = new NotificationCompat.Action.Builder(
                        R.drawable.ic_action_read_dark, context.getResources().getString(R.string.mark_read),
                        readPending);

                mBuilder.addAction(replyAction);
                mBuilder.addAction(action.build());
            }

            // Build the notification and issues it with notification manager.
            notificationManager.notify(1, mBuilder.build());

            // if we want to wake the screen on a new message
            if (settings.wakeScreen) {
                PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
                final PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK
                        | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
                wakeLock.acquire(5000);
            }
        }

        // if there are unread tweets on the timeline, check them for favorite users
        if (settings.favoriteUserNotifications && realTimelineCount > 0) {
            favUsersNotification(currentAccount, context);
        }
    }

    try {

        ContentValues cv = new ContentValues();

        cv.put("tag", "com.daiv.android.twitter/com.daiv.android.twitter.ui.MainActivity");

        // add the direct messages and mentions
        cv.put("count", unreadCounts[1] + unreadCounts[2]);

        context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv);

    } catch (IllegalArgumentException ex) {

        /* Fine, TeslaUnread is not installed. */

    } catch (Exception ex) {

        /* Some other error, possibly because the format
           of the ContentValues are incorrect.
                
        Log but do not crash over this. */

        ex.printStackTrace();

    }
}

From source file:com.android.development.Connectivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setContentView(R.layout.connectivity);

    mWm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    mPm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
    mNetd = INetworkManagementService.Stub.asInterface(b);

    findViewById(R.id.enableWifi).setOnClickListener(mClickListener);
    findViewById(R.id.disableWifi).setOnClickListener(mClickListener);

    findViewById(R.id.startDelayedCycle).setOnClickListener(mClickListener);
    findViewById(R.id.stopDelayedCycle).setOnClickListener(mClickListener);
    mDCOnDurationEdit = (EditText) findViewById(R.id.dc_wifi_on_duration);
    mDCOnDurationEdit.setText(Long.toString(mDCOnDuration));
    mDCOffDurationEdit = (EditText) findViewById(R.id.dc_wifi_off_duration);
    mDCOffDurationEdit.setText(Long.toString(mDCOffDuration));
    mDCCycleCountView = (TextView) findViewById(R.id.dc_wifi_cycles_done);
    mDCCycleCountView.setText(Integer.toString(mDCCycleCount));

    findViewById(R.id.startScreenCycle).setOnClickListener(mClickListener);
    findViewById(R.id.stopScreenCycle).setOnClickListener(mClickListener);
    mSCOnDurationEdit = (EditText) findViewById(R.id.sc_wifi_on_duration);
    mSCOnDurationEdit.setText(Long.toString(mSCOnDuration));
    mSCOffDurationEdit = (EditText) findViewById(R.id.sc_wifi_off_duration);
    mSCOffDurationEdit.setText(Long.toString(mSCOffDuration));
    mSCCycleCountView = (TextView) findViewById(R.id.sc_wifi_cycles_done);
    mSCCycleCountView.setText(Integer.toString(mSCCycleCount));

    mScanButton = (Button) findViewById(R.id.startScan);
    mScanButton.setOnClickListener(mClickListener);
    mScanCyclesEdit = (EditText) findViewById(R.id.sc_scan_cycles);
    mScanCyclesEdit.setText(Long.toString(mScanCycles));
    mScanDisconnect = (CheckBox) findViewById(R.id.scanDisconnect);
    mScanDisconnect.setChecked(true);//  w  w  w .  j  a v a2  s  . c  om
    mScanResults = (TextView) findViewById(R.id.sc_scan_results);
    mScanResults.setVisibility(View.INVISIBLE);

    mScanRecv = new WifiScanReceiver();
    mIntentFilter = new IntentFilter();
    mIntentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);

    findViewById(R.id.startTdls).setOnClickListener(mClickListener);
    findViewById(R.id.stopTdls).setOnClickListener(mClickListener);

    findViewById(R.id.start_mms).setOnClickListener(mClickListener);
    findViewById(R.id.stop_mms).setOnClickListener(mClickListener);
    findViewById(R.id.start_hipri).setOnClickListener(mClickListener);
    findViewById(R.id.stop_hipri).setOnClickListener(mClickListener);
    findViewById(R.id.crash).setOnClickListener(mClickListener);

    findViewById(R.id.add_default_route).setOnClickListener(mClickListener);
    findViewById(R.id.remove_default_route).setOnClickListener(mClickListener);
    findViewById(R.id.bound_http_request).setOnClickListener(mClickListener);
    findViewById(R.id.bound_socket_request).setOnClickListener(mClickListener);
    findViewById(R.id.routed_http_request).setOnClickListener(mClickListener);
    findViewById(R.id.routed_socket_request).setOnClickListener(mClickListener);
    findViewById(R.id.default_request).setOnClickListener(mClickListener);
    findViewById(R.id.default_socket).setOnClickListener(mClickListener);

    registerReceiver(mReceiver, new IntentFilter(CONNECTIVITY_TEST_ALARM));
}