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.commonsware.android.job.PollReceiver.java

@Override
public void onReceive(Context ctxt, Intent i) {
    boolean isDownload = i.getBooleanExtra(EXTRA_IS_DOWNLOAD, false);
    startWakefulService(ctxt,/*from  ww  w .j a v  a 2  s .  c  om*/
            new Intent(ctxt, DemoScheduledService.class).putExtra(EXTRA_IS_DOWNLOAD, isDownload));

    long period = i.getLongExtra(EXTRA_PERIOD, -1);

    if (period > 0) {
        scheduleExactAlarm(ctxt, (AlarmManager) ctxt.getSystemService(Context.ALARM_SERVICE), period,
                isDownload);
    }
}

From source file:com.commonsware.android.job.DemoScheduledService.java

@Override
public void onHandleWork(Intent i) {
    Log.d(getClass().getSimpleName(), "scheduled work begins");

    if (i.getBooleanExtra(PollReceiver.EXTRA_IS_DOWNLOAD, false)) {
        new DownloadJob().run(); // do synchronously, as we are on
                                 // a background thread already
    }/*  www  .  j av  a2 s.c  o  m*/

    Log.d(getClass().getSimpleName(), "scheduled work ends");
}

From source file:com.nadmm.airports.tfr.TfrService.java

private void getTfrList(Intent intent) {
    boolean force = intent.getBooleanExtra(FORCE_REFRESH, false);

    File tfrFile = getFile(TFR_CACHE_NAME);
    if (!tfrFile.exists() || force) {
        URI uri;/*  w  ww. ja  v a 2 s.c om*/
        try {
            uri = URIUtils.createURI("http", TFR_HOST, 80, TFR_PATH, TFR_QUERY, null);
            fetch(uri, tfrFile);
        } catch (URISyntaxException e) {
            UiUtils.showToast(this, "TFR: " + e.getMessage());
        }
    }

    TfrList tfrList = new TfrList();
    mParser.parse(tfrFile, tfrList);
    Collections.sort(tfrList.entries);

    Intent result = makeResultIntent(intent.getAction());
    result.putExtra(TFR_LIST, tfrList);
    sendResultIntent(result);
}

From source file:com.airbnb.deeplinkdispatch.sample.MainActivity.java

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

    Intent intent = getIntent();
    if (intent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false)) {
        String toastMessage;//from  www.  ja  v  a 2s .  c o m
        Bundle parameters = intent.getExtras();
        Log.d(TAG, "Deeplink params: " + parameters);

        if (ACTION_DEEP_LINK_METHOD.equals(intent.getAction())) {
            toastMessage = "method with param1:" + parameters.getString("param1");
        } else if (ACTION_DEEP_LINK_COMPLEX.equals(intent.getAction())) {
            toastMessage = parameters.getString("arbitraryNumber");
        } else if (parameters.containsKey("arg")) {
            toastMessage = "class and found arg:" + parameters.getString("arg");
        } else {
            toastMessage = "class";
        }

        // You can pass a query parameter with the URI, and it's also in parameters, like
        // dld://classDeepLink?qp=123
        if (parameters.containsKey("qp")) {
            toastMessage += " with query parameter " + parameters.getString("qp");
        }
        Uri referrer = ActivityCompat.getReferrer(this);
        if (referrer != null) {
            toastMessage += " and referrer: " + referrer.toString();
        }

        showToast(toastMessage);
    }
}

From source file:com.android.settings.aokpstats.ReportingService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent.getBooleanExtra("firstBoot", false)) {
        promptUser();// ww w. ja  v a 2s  .  com
        Log.d(TAG, "Prompting user for opt-in.");
    } else {
        Log.d(TAG, "User has opted in -- reporting.");
        Thread thread = new Thread() {
            @Override
            public void run() {
                report();
            }
        };
        thread.start();
    }
    return Service.START_REDELIVER_INTENT;
}

From source file:com.google.samples.apps.topeka.activity.SignInActivity.java

private boolean isInEditMode() {
    final Intent intent = getIntent();
    boolean edit = false;
    if (null != intent) {
        edit = intent.getBooleanExtra(EXTRA_EDIT, false);
    }/*from w  ww  .ja  v  a2 s. c o  m*/
    return edit;
}

From source file:com.phonemetra.turbo.keyboard.latin.settings.SettingsActivity.java

@Override
protected void onCreate(final Bundle savedState) {
    super.onCreate(savedState);
    final ActionBar actionBar = getActionBar();
    final Intent intent = getIntent();
    if (actionBar != null) {
        mShowHomeAsUp = intent.getBooleanExtra(EXTRA_SHOW_HOME_AS_UP, true);
        actionBar.setDisplayHomeAsUpEnabled(mShowHomeAsUp);
        actionBar.setHomeButtonEnabled(mShowHomeAsUp);
    }//from  ww w  .j a va2 s.c o m

}

From source file:com.android.inputmethod.latin.settings.SettingsActivity.java

@Override
protected void onCreate(final Bundle savedState) {
    super.onCreate(savedState);
    final ActionBar actionBar = getActionBar();
    final Intent intent = getIntent();
    if (actionBar != null) {
        mShowHomeAsUp = intent.getBooleanExtra(EXTRA_SHOW_HOME_AS_UP, true);
        actionBar.setDisplayHomeAsUpEnabled(mShowHomeAsUp);
        actionBar.setHomeButtonEnabled(mShowHomeAsUp);
    }//from   ww w. j a  v a2 s  .  co m
    StatsUtils.onSettingsActivity(intent.hasExtra(EXTRA_ENTRY_KEY) ? intent.getStringExtra(EXTRA_ENTRY_KEY)
            : EXTRA_ENTRY_VALUE_SYSTEM_SETTINGS);
}

From source file:com.example.android.amplacenta.MainActivity.java

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

    if (savedInstanceState == null) {
        Intent intent = getIntent();
        boolean isMaster = intent.getBooleanExtra(SelectLayoutActivity.LAYOUT_TYPE, false);

        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        Fragment fragment;//from w w  w.j ava  2 s  . c o m
        if (isMaster) {
            fragment = new HostFragment();
        } else {
            fragment = new GuestFragment();
        }
        transaction.replace(R.id.sample_content_fragment, fragment);
        transaction.commit();
    }
}

From source file:com.scooter1556.sms.android.activity.HomeActivity.java

private void startFullScreenActivityIfNeeded(Intent intent) {
    if (intent != null && intent.getBooleanExtra(EXTRA_START_FULLSCREEN, false)) {
        Intent fullScreenIntent = new Intent(this, FullScreenPlayerActivity.class)
                .setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP)
                .putExtra(EXTRA_CURRENT_MEDIA_DESCRIPTION,
                        intent.getParcelableExtra(EXTRA_CURRENT_MEDIA_DESCRIPTION));

        startActivity(fullScreenIntent);
    }//from   w  w  w .  j a  va 2  s .co m
}