Example usage for android.content Intent getBooleanExtra

List of usage examples for android.content Intent getBooleanExtra

Introduction

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

Prototype

public boolean getBooleanExtra(String name, boolean defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.nogago.android.tracks.ImportActivity.java

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

    Intent intent = getIntent();
    importAll = intent.getBooleanExtra(EXTRA_IMPORT_ALL, false);
    if (importAll) {
        path = FileUtils.buildExternalDirectoryPath("gpx");
    } else {/* ww  w  .  j av  a 2  s.  c om*/
        String action = intent.getAction();
        if (!(Intent.ACTION_ATTACH_DATA.equals(action) || Intent.ACTION_VIEW.equals(action))) {
            Log.d(TAG, "Invalid action: " + intent);
            finish();
            return;
        }

        Uri data = intent.getData();
        if (!UriUtils.isFileUri(data)) {
            Log.d(TAG, "Invalid data: " + intent);
            finish();
            return;
        }
        path = data.getPath();
    }

    Object retained = getLastNonConfigurationInstance();
    if (retained instanceof ImportAsyncTask) {
        importAsyncTask = (ImportAsyncTask) retained;
        importAsyncTask.setActivity(this);
    } else {
        importAsyncTask = new ImportAsyncTask(this, importAll, path);
        importAsyncTask.execute();
    }
}

From source file:biz.shadowservices.DegreesToolbox.UpdateWidgetService.java

private void handleCommand(Intent intent) {
    Log.d(TAG, "Starting service");
    if (intent != null) {
        force = intent.getBooleanExtra("biz.shadowservices.PhoneBalanceWidget.forceUpdates", false);
    }/*from   www  .  ja va  2  s  . c o m*/
    // Locking to make sure we only run one thread at a time.
    synchronized (lock) {
        if (!isThreadRunning) {
            Log.d(TAG, "Thread not running, starting.");
            isThreadRunning = true;
            new Thread(this).start();
        } else {
            Log.d(TAG, "Thread already running, not doing anything.");
        }

    }
}

From source file:ca.hoogit.garagepi.Controls.Doors.java

@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getStringExtra(Consts.KEY_BROADCAST_ACTION);
    if (Consts.ACTION_DOORS_QUERY.equals(action)) {
        boolean wasSuccess = intent.getBooleanExtra(Consts.KEY_BROADCAST_SUCCESS, false);
        if (wasSuccess) {
            this.mDoors = intent.getParcelableArrayListExtra(Consts.KEY_DOORS);
        }//from   w  ww . j  a  v a  2 s  .  c  om
    }
}

From source file:de.hero.vertretungsplan.CheckForAppUpdate.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    boolean setTimer = intent.getBooleanExtra("setTimer", false);
    boolean checkNow = intent.getBooleanExtra("checkNow", false);

    Intent i = new Intent(this, de.hero.vertretungsplan.CheckForAppUpdate.class);
    i.putExtra("checkNow", true);
    PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
    AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

    am.cancel(pi);/*  w  w w  .  ja  v  a 2s  . co m*/
    Log.d("CheckForAppUpdate", "Alarm canceled");
    if (setTimer) {

        long lngInterval = AlarmManager.INTERVAL_DAY * 7;
        Log.d("CheckForAppUpdate", "Alarm set");
        am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME,
                SystemClock.elapsedRealtime() + AlarmManager.INTERVAL_DAY * 6, lngInterval, pi);
        //For debugging: after 10 seconds
        //am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 25000 , AlarmManager.INTERVAL_HOUR , pi);

    }

    if (checkNow) {
        ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

        if (cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnected()) {
            try {
                new HtmlWorkAppUpdate(this).execute(new URI(getString(R.string.htmlAdresseAktuelleVersion)));
            } catch (URISyntaxException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    return START_NOT_STICKY;
}

From source file:android.romstats.ReportingService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    boolean canReport = true;
    if (intent.getBooleanExtra("promptUser", false)) {
        Log.d(Const.TAG, "Prompting user for opt-in.");
        promptUser();//from  w  w w .  ja  v a2s.c  o  m
        canReport = false;
    }

    String RomStatsUrl = Utilities.getStatsUrl();
    if (RomStatsUrl == null || RomStatsUrl.isEmpty()) {
        Log.e(Const.TAG, "This ROM is not configured for ROM Statistics.");
        canReport = false;
    }

    if (canReport) {
        Log.d(Const.TAG, "User has opted in -- reporting.");

        if (mTask == null || mTask.getStatus() == AsyncTask.Status.FINISHED) {
            mTask = new StatsUploadTask();
            mTask.execute();
        }
    }

    return Service.START_REDELIVER_INTENT;
}

From source file:com.github.marcosalis.kraken.utils.network.NetworkBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {

    logNetworkInfo(intent);/*from  www  . j a  v a 2  s .  com*/

    // use EXTRA_NO_CONNECTIVITY to check if there is no connection
    if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false)) {
        notifyConnectionGone(context);
        return;
    }

    final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo netInfo = cm.getActiveNetworkInfo();

    // send local broadcast to notify all registered receivers
    if (netInfo != null && netInfo.isConnected()) { // connection active
        notifyConnectionActive(context, netInfo.getType());
    } else {
        // connection has gone
        notifyConnectionGone(context);
    }
}

From source file:com.robwilliamson.healthyesther.dropbox.DropboxSyncActivity.java

@Override
protected synchronized void loadData() {
    if (!hasRequiredPermissions()) {
        return;/*from   w  w w.j av  a  2 s . co  m*/
    }

    setBusy(true);

    Boolean restore = false;

    Intent intent = getIntent();

    if (intent != null && intent.hasExtra(RESTORE)) {
        restore = intent.getBooleanExtra(RESTORE, false);
    }

    final Boolean backup = !restore;

    AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            try {
                if (backup) {
                    HealthDbHelper.getInstance().backupToDropbox();
                } else {
                    HealthDbHelper.getInstance().restoreFromDropbox();
                }
            } catch (IOException | DbxException e) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(DropboxSyncActivity.this, R.string.dropbox_sync_failed,
                                Toast.LENGTH_SHORT).show();
                    }
                });
                e.printStackTrace();
            } finally {
                setBusy(false);
                finish();
            }

            return null;
        }
    };
    task.execute();
}

From source file:arun.com.chromer.appdetect.AppDetectService.java

private void clearLastAppIfNeeded(Intent intent) {
    if (intent != null && intent.getBooleanExtra(EXTRA_KEY_CLEAR_LAST_TOP_APP, false)) {
        appDetectionManager.clear();//from w  ww  .ja  v  a  2s  . c  o m
        Timber.d("Last app cleared");
    }
}

From source file:com.example.gate360player.SphericalPlayerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_360video_player);
    videoPlayer = (SphericalVideoPlayer) findViewById(R.id.spherical_video_player);
    final Intent intent = getIntent();
    String videoPath = intent.getStringExtra("proxy");
    videoPlayer.setVideoURIPath(videoPath);
    videoPlayer.setPlayStaticVideo(intent.getBooleanExtra("isStaticVideo", true));
    videoPlayer.playWhenReady();/* w  w  w .  j a  v a 2 s  . c o  m*/

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    requestExternalStoragePermission();
}

From source file:com.andernity.launcher2.InstallShortcutReceiver.java

private static boolean installShortcut(Context context, Intent data, ArrayList<ItemInfo> items, String name,
        final Intent intent, final int screen, boolean shortcutExists, final SharedPreferences sharedPrefs,
        int[] result) {
    int[] tmpCoordinates = new int[2];
    if (findEmptyCell(context, items, tmpCoordinates, screen)) {
        if (intent != null) {
            if (intent.getAction() == null) {
                intent.setAction(Intent.ACTION_VIEW);
            } else if (intent.getAction().equals(Intent.ACTION_MAIN) && intent.getCategories() != null
                    && intent.getCategories().contains(Intent.CATEGORY_LAUNCHER)) {
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
            }/*from  w  w  w  .  ja v a2 s.  co m*/

            // By default, we allow for duplicate entries (located in
            // different places)
            boolean duplicate = data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE, true);
            if (duplicate || !shortcutExists) {
                new Thread("setNewAppsThread") {
                    public void run() {
                        synchronized (sLock) {
                            // If the new app is going to fall into the same page as before,
                            // then just continue adding to the current page
                            final int newAppsScreen = sharedPrefs.getInt(NEW_APPS_PAGE_KEY, screen);
                            SharedPreferences.Editor editor = sharedPrefs.edit();
                            if (newAppsScreen == -1 || newAppsScreen == screen) {
                                addToStringSet(sharedPrefs, editor, NEW_APPS_LIST_KEY, intent.toUri(0));
                            }
                            editor.putInt(NEW_APPS_PAGE_KEY, screen);
                            editor.commit();
                        }
                    }
                }.start();

                // Update the Launcher db
                LauncherApplication app = (LauncherApplication) context.getApplicationContext();
                ShortcutInfo info = app.getModel().addShortcut(context, data,
                        LauncherSettings.Favorites.CONTAINER_DESKTOP, screen, tmpCoordinates[0],
                        tmpCoordinates[1], true);
                if (info == null) {
                    return false;
                }
            } else {
                result[0] = INSTALL_SHORTCUT_IS_DUPLICATE;
            }

            return true;
        }
    } else {
        result[0] = INSTALL_SHORTCUT_NO_SPACE;
    }

    return false;
}