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.amaze.filemanager.services.CopyService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Bundle b = new Bundle();
    ArrayList<BaseFile> files = intent.getParcelableArrayListExtra("FILE_PATHS");
    String FILE2 = intent.getStringExtra("COPY_DIRECTORY");
    int mode = intent.getIntExtra("MODE", 0);
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    b.putInt("id", startId);
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent.putExtra("openprocesses", true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    mBuilder = new NotificationCompat.Builder(c);
    mBuilder.setContentIntent(pendingIntent);
    mBuilder.setContentTitle(getResources().getString(R.string.copying))

            .setSmallIcon(R.drawable.ic_content_copy_white_36dp);
    if (foreground) {
        startForeground(Integer.parseInt("456" + startId), mBuilder.build());
        foreground = false;//from   w w  w .j a  v  a2s.c o m
    }
    b.putBoolean("move", intent.getBooleanExtra("move", false));
    b.putString("FILE2", FILE2);
    b.putInt("MODE", mode);
    b.putParcelableArrayList("files", files);
    hash.put(startId, true);
    DataPackage intent1 = new DataPackage();
    intent1.setName(files.get(0).getName());
    intent1.setTotal(0);
    intent1.setDone(0);
    intent1.setId(startId);
    intent1.setP1(0);
    intent1.setP2(0);
    intent1.setMove(intent.getBooleanExtra("move", false));
    intent1.setCompleted(false);
    hash1.put(startId, intent1);
    //going async
    new DoInBackground().execute(b);

    // If we get killed, after returning from here, restart
    return START_STICKY;
}

From source file:org.transdroid.core.gui.TorrentsActivity.java

@OnActivityResult(RESULT_DETAILS)
protected void onDetailsScreenResult(Intent result) {
    // If the details activity returns whether the torrent was removed or updated, update the torrents list as well
    // (the details fragment is the source, so no need to update that)
    if (result != null && result.hasExtra("affected_torrent")) {
        Torrent affected = result.getParcelableExtra("affected_torrent");
        fragmentTorrents.quickUpdateTorrent(affected, result.getBooleanExtra("torrent_removed", false));
    }//from  w ww  .j av  a 2  s .  c  o m
}

From source file:com.filemanager.free.services.CopyService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) throws NullPointerException {
    Bundle b = new Bundle();
    ArrayList<BaseFile> files = intent.getParcelableArrayListExtra("FILE_PATHS");
    String FILE2 = intent.getStringExtra("COPY_DIRECTORY");
    int mode = intent.getIntExtra("MODE", 0);
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    b.putInt("id", startId);
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent.putExtra("openprocesses", true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    mBuilder = new NotificationCompat.Builder(c);
    mBuilder.setContentIntent(pendingIntent);
    mBuilder.setContentTitle(getResources().getString(R.string.copying))

            .setSmallIcon(R.drawable.ic_content_copy_white_36dp);
    if (foreground) {
        startForeground(Integer.parseInt("456" + startId), mBuilder.build());
        foreground = false;/*from ww  w .  j av  a  2 s.co  m*/
    }
    b.putBoolean("move", intent.getBooleanExtra("move", false));
    b.putString("FILE2", FILE2);
    b.putInt("MODE", mode);
    b.putParcelableArrayList("files", files);
    hash.put(startId, true);
    DataPackage intent1 = new DataPackage();
    intent1.setName(files.get(0).getName());
    intent1.setTotal(0);
    intent1.setDone(0);
    intent1.setId(startId);
    intent1.setP1(0);
    intent1.setP2(0);
    intent1.setMove(intent.getBooleanExtra("move", false));
    intent1.setCompleted(false);
    hash1.put(startId, intent1);
    //going async
    new DoInBackground().execute(b);

    // If we get killed, after returning from here, restart
    return START_STICKY;
}

From source file:com.android.deskclock.AlarmClockFragment.java

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

    final DeskClock activity = (DeskClock) getActivity();
    if (activity.getSelectedTab() == DeskClock.ALARM_TAB_INDEX) {
        setFabAppearance();// w w w.  j av  a2s.co  m
        setLeftRightButtonAppearance();
    }
    final int startDay = Utils.getZeroIndexedFirstDayOfWeek(getActivity());
    mDayOrder = new int[DaysOfWeek.DAYS_IN_A_WEEK];

    for (int i = 0; i < DaysOfWeek.DAYS_IN_A_WEEK; ++i) {
        mDayOrder[i] = DAY_ORDER[(startDay + i) % 7];
    }

    // Check if another app asked us to create a blank new alarm.
    final Intent intent = getActivity().getIntent();
    if (intent.hasExtra(ALARM_CREATE_NEW_INTENT_EXTRA)) {
        if (intent.getBooleanExtra(ALARM_CREATE_NEW_INTENT_EXTRA, false)) {
            // An external app asked us to create a blank alarm.
            startCreatingAlarm();
        }

        // Remove the CREATE_NEW extra now that we've processed it.
        intent.removeExtra(ALARM_CREATE_NEW_INTENT_EXTRA);
    } else if (intent.hasExtra(SCROLL_TO_ALARM_INTENT_EXTRA)) {
        long alarmId = intent.getLongExtra(SCROLL_TO_ALARM_INTENT_EXTRA, Alarm.INVALID_ID);
        if (alarmId != Alarm.INVALID_ID) {
            mScrollToAlarmId = alarmId;
            if (mCursorLoader != null && mCursorLoader.isStarted()) {
                // We need to force a reload here to make sure we have the latest view
                // of the data to scroll to.
                mCursorLoader.forceLoad();
            }
        }

        // Remove the SCROLL_TO_ALARM extra now that we've processed it.
        intent.removeExtra(SCROLL_TO_ALARM_INTENT_EXTRA);
    }

    setTimePickerListener();
}

From source file:com.swisscom.safeconnect.activity.DashboardActivity.java

private void share() {
    final String appUrl = Config.GPLAY_URL;
    final String content = getString(R.string.share_content);
    final String subject = getString(R.string.share_subject);

    List<Intent> shareIntents = new ArrayList<Intent>();
    //fb & twitter
    shareIntents.add(new FacebookSharing(this).getIntent(content, appUrl));
    shareIntents.add(new TwitterSharing(this).getIntent(content, appUrl));

    //favorite sharing apps
    for (String packageName : Sharing.favoriteApps) {
        Intent i = Sharing.getSharingApp(packageName, subject, content + ' ' + appUrl, this);
        if (i != null) {
            shareIntents.add(i);/*from  w ww. j av  a  2s.  co  m*/
        }
    }

    //trigger to load all sharing apps
    LabeledIntent share = new LabeledIntent(new Intent(), "", getString(R.string.share_more_apps), 0);
    share.putExtra("more", true);
    shareIntents.add(share);

    AlertDialog.Builder builder = new AlertDialog.Builder(DashboardActivity.this,
            R.style.AppCompat_Pipe_Dialog_Alert);
    builder.setTitle(R.string.share_with);
    final SharingAdapter adapter = new SharingAdapter(this, R.layout.item_sharing, shareIntents);
    builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent i = adapter.getItem(which);

            //Trigger to load the standard android sharing dialog
            if (i.getBooleanExtra("more", false)) {
                Intent intent = Intent.createChooser(Sharing.getSharingIntent(subject, content + ' ' + appUrl),
                        getString(R.string.share_with));
                startActivity(intent);
                return;
            }

            //fix exception when launching labeled-intent
            if (i instanceof LabeledIntent) {
                i = new Intent(i);
            }
            startActivity(i);
        }
    });

    builder.show();
}

From source file:com.android.email.activity.MessageView.java

void initFromIntent() {
    Intent intent = getIntent();
    mMessageId = intent.getLongExtra(EXTRA_MESSAGE_ID, -1);
    mMailboxId = intent.getLongExtra(EXTRA_MAILBOX_ID, -1);
    mDisableReplyAndForward = intent.getBooleanExtra(EXTRA_DISABLE_REPLY, false);
    if (mDisableReplyAndForward) {
        findViewById(R.id.reply).setEnabled(false);
        findViewById(R.id.reply_all).setEnabled(false);
    }/*  www .  j ava2s. c  om*/
}

From source file:com.jea.gisandroidapplication.controller.activity.MapActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Check which request we're responding to
    if (requestCode == SETTINGS_REQUEST) {
        // Preferences changed
        // Check for change
        if (mLocationPref != sharedPref.getBoolean(SettingsActivity.KEY_PREF_LOCATION, true)) {
            mLocationPref = sharedPref.getBoolean(SettingsActivity.KEY_PREF_LOCATION, true);
            // Turn off location for fragment
            mMapFragment.toggleLocation();
            // Hide location FAB
            toggleLocFabVisibility();/*from   w ww. j  av  a2s  .c  o  m*/
        }
    } else if (requestCode == FIND_REQUEST) {
        if (resultCode == RESULT_OK) {
            // Close navigation drawer
            closeDrawer();
            // Get results from data intent
            ArrayList<Result> results = data.getParcelableArrayListExtra(FindActivity.EXTRA_RESULTS);
            // Display results
            displayResults(results);
        }
    } else if (requestCode == STREET_VIEW_REQUEST) {
        // Required?
    } else if (requestCode == GOOGLE_ERROR_DIALOG_REQUEST) {
        // ?
    } else if (requestCode == LAYER_MANAGER_REQUEST) {
        if (resultCode == RESULT_OK) {
            boolean isAdd = data.getBooleanExtra(LayerManagerActivity.EXTRA_LAYER_ISADD, true);
            String layerName = data.getStringExtra(LayerManagerActivity.EXTRA_LAYER_NAME);
            if (isAdd) {
                mMapFragment.addExtraLayer(layerName);
            } else {
                // Remove
                mMapFragment.removeLayer(layerName);
            }

        }
    }

}

From source file:com.owncloud.android.ui.activity.Preferences.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == ACTION_REQUEST_PASSCODE && resultCode == RESULT_OK) {
        String passcode = data.getStringExtra(PassCodeActivity.KEY_PASSCODE);
        if (passcode != null && passcode.length() == 4) {
            SharedPreferences.Editor appPrefs = PreferenceManager
                    .getDefaultSharedPreferences(getApplicationContext()).edit();

            for (int i = 1; i <= 4; ++i) {
                appPrefs.putString(PassCodeActivity.PREFERENCE_PASSCODE_D + i, passcode.substring(i - 1, i));
            }/*from  w  w w .j a  v  a  2  s.c  om*/
            appPrefs.putBoolean(PassCodeActivity.PREFERENCE_SET_PASSCODE, true);
            appPrefs.apply();
            Toast.makeText(this, R.string.pass_code_stored, Toast.LENGTH_LONG).show();
        }
    } else if (requestCode == ACTION_CONFIRM_PASSCODE && resultCode == RESULT_OK) {
        if (data.getBooleanExtra(PassCodeActivity.KEY_CHECK_RESULT, false)) {

            SharedPreferences.Editor appPrefs = PreferenceManager
                    .getDefaultSharedPreferences(getApplicationContext()).edit();
            appPrefs.putBoolean(PassCodeActivity.PREFERENCE_SET_PASSCODE, false);
            appPrefs.apply();

            Toast.makeText(this, R.string.pass_code_removed, Toast.LENGTH_LONG).show();
        }
    } else if (requestCode == ACTION_REQUEST_CODE_DAVDROID_SETUP && resultCode == RESULT_OK) {
        Toast.makeText(this, R.string.prefs_calendar_contacts_sync_setup_successful, Toast.LENGTH_LONG).show();
    }
}

From source file:com.android.documentsui.DocumentsActivity.java

private void buildDefaultState() {
    mState = new State();

    final Intent intent = getIntent();
    final String action = intent.getAction();
    if (Intent.ACTION_OPEN_DOCUMENT.equals(action)) {
        mState.action = ACTION_OPEN;//www.j  a  v  a2s .  c  o  m
    } else if (Intent.ACTION_CREATE_DOCUMENT.equals(action)) {
        mState.action = ACTION_CREATE;
    } else if (Intent.ACTION_GET_CONTENT.equals(action)) {
        mState.action = ACTION_GET_CONTENT;
    } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) {
        mState.action = ACTION_MANAGE;
    }

    if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) {
        mState.allowMultiple = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false);
    }

    if (mState.action == ACTION_MANAGE) {
        mState.acceptMimes = new String[] { "*/*" };
        mState.allowMultiple = true;
    } else if (intent.hasExtra(Intent.EXTRA_MIME_TYPES)) {
        mState.acceptMimes = intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES);
    } else {
        mState.acceptMimes = new String[] { intent.getType() };
    }

    mState.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false);
    mState.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false);
    mState.showAdvanced = mState.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(this);
}

From source file:com.att.arocollector.AROCollectorActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "onCreate(...)");
    // Setup handler for uncaught exceptions.
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        @Override/*from w ww.  j a  v  a2 s . co m*/
        public void uncaughtException(Thread thread, Throwable e) {
            handleUncaughtException(thread, e);
        }
    });

    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
    final TextView splashText = (TextView) findViewById(R.id.splash_message);
    splashText.setText(String.format(getString(R.string.splashmessageopensource),
            getString(R.string.app_brand_name), getString(R.string.app_url_name)));
    AttenuatorManager.getInstance().init();
    Intent intent = getIntent();
    //delay
    int delayDl = intent.getIntExtra(BundleKeyUtil.DL_DELAY, 0);
    int delayUl = intent.getIntExtra(BundleKeyUtil.UL_DELAY, 0);

    if (delayDl >= 0) {
        AttenuatorManager.getInstance().setDelayDl(delayDl);
    } else {
        Log.i(TAG, "Invalid attenuation delay value" + delayDl + "ms");
    }

    if (delayUl >= 0) {
        AttenuatorManager.getInstance().setDelayUl(delayUl);
    } else {
        Log.i(TAG, "Invalid attenuation delay value" + delayUl + "ms");
    }

    //throttle
    int throttleDl = intent.getIntExtra(BundleKeyUtil.DL_THROTTLE, AttenuatorUtil.DEFAULT_THROTTLE_SPEED);
    int throttleUl = intent.getIntExtra(BundleKeyUtil.UL_THROTTLE, AttenuatorUtil.DEFAULT_THROTTLE_SPEED);

    AttenuatorManager.getInstance().setThrottleDL(throttleDl);
    Log.d(TAG, "Download speed throttle value: " + throttleDl + " kbps");

    AttenuatorManager.getInstance().setThrottleUL(throttleUl);
    Log.d(TAG, "Upload speed throttle value: " + throttleUl + " kbps");

    printLog = intent.getBooleanExtra(BundleKeyUtil.PRINT_LOG, false);

    setVideoOption(intent);

    bitRate = intent.getIntExtra(BundleKeyUtil.BIT_RATE, 0);
    String screenSizeTmp = intent.getStringExtra(BundleKeyUtil.SCREEN_SIZE);
    screenSize = screenSizeTmp == null ? screenSize : screenSizeTmp;

    setVideoOrient(intent);

    Log.i(TAG,
            "get from intent delayTime: " + AttenuatorManager.getInstance().getDelayDl()
                    + "get from intent delayTimeUL: " + AttenuatorManager.getInstance().getDelayUl()
                    + "get from intent throttleDL: " + AttenuatorManager.getInstance().getThrottleDL()
                    + "get from intnetn throttleUL: " + AttenuatorManager.getInstance().getThrottleUL()
                    + " video: " + videoOption + " bitRate: " + bitRate + " screenSize: " + screenSize
                    + " orientation: " + videoOrient);

    context = getApplicationContext();
    launchAROCpuTraceService();
    launchAROCpuTempService();
    if (networkAndAirplaneModeCheck()) {

        // register to listen for close down message
        registerAnalyzerCloseCmdReceiver();
        Log.d(TAG, "register the attenuator delay signal");

        startVPN();
    }

    { // test code
        PackageInfo packageInfo = null;
        try {
            packageInfo = this.getPackageManager().getPackageInfo(this.getPackageName(), 0);
        } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        boolean valu = (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
        // build datetime
        Date buildDate = new Date(BuildConfig.TIMESTAMP);
        String appBuildDate = "";
        if (buildDate != null) {
            appBuildDate = buildDate.toString();
        }

        String display = "App Build Date: " + appBuildDate + "\n"
        //               +" DownStream Delay Time: " + AttenuatorManager.getInstance().getDelayDl() + " ms\n"
        //               +" UpStream Delay Time: " + AttenuatorManager.getInstance().getDelayUl() + " ms\n"
        //               +" DownStream Throttle: " + AttenuatorManager.getInstance().getThrottleDL() + " kbps\n"
        //               +" Upstream Throttle: " + AttenuatorManager.getInstance().getThrottleUL() + " kbps\n"
                + AttenuatorUtil.getInstance().notificationMessage() + "\n" + " Version: "
                + packageInfo.versionName + " (" + (valu ? "Debug" : "Production") + ")";

        ((TextView) findViewById(R.id.version)).setText(display);
    }
}