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.radiofarda.istgah.ui.PodcastsActivity.java

private void startFullScreenActivityIfNeeded(Intent intent) {
    if (intent != null && intent.getBooleanExtra(EXTRA_START_FULLSCREEN, false)) {
        Parcelable parcelableExtra = intent.getParcelableExtra(EXTRA_CURRENT_MEDIA_DESCRIPTION);
        Intent fullScreenIntent = new Intent(this, FullScreenPlayerActivity.class)
                .setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP)
                .putExtra(EXTRA_CURRENT_MEDIA_DESCRIPTION, parcelableExtra);
        startActivity(fullScreenIntent);
    }/*from  www  .  j  a  v  a  2 s .com*/
}

From source file:com.github.secondsun.catfactsdemo.networking.CatFactFetcherService.java

protected void onHandleIntent(Intent intent) {

    if (intent.getBooleanExtra(LOAD, false)) {

        CharSequence contentText;

        if (data.size() > 0) {
            contentText = "Data Loaded";
        } else {// w  w w.  j a v  a 2s .  c  o m
            contentText = "Awaiting Data Load";
        }
        Intent notificationIntent = new Intent(this, CatFacts.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

        Notification notification = new Notification.Builder(this).setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle("CatFact Fetcher").setContentText(contentText).setContentIntent(pendingIntent)
                .build();
        startForeground(ONGOING_NOTIFICATION_ID, notification);
    } else if (intent.getBooleanExtra(UNLOAD, false)) {
        stopForeground(true);
    } else {
        if (intent.getBooleanExtra(RESET, false)) {
            data.clear();
            Intent notificationIntent = new Intent(this, CatFacts.class);
            PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
            Notification notification = new Notification.Builder(this).setSmallIcon(R.mipmap.ic_launcher)
                    .setContentTitle("CatFact Fetcher").setContentText("Awaiting Data Load")
                    .setContentIntent(pendingIntent).build();
            startForeground(ONGOING_NOTIFICATION_ID, notification);
        }
        if (data.size() == 0) {
            try {
                Thread.sleep(Constants.DELAY);

                OkHttpClient client = new OkHttpClient();

                Request request = new Request.Builder().url(Constants.CAT_FACTS_URL).build();

                Response response = client.newCall(request).execute();

                JSONObject responseJson = new JSONObject(response.body().string());
                JSONArray facts = responseJson.getJSONArray("facts");

                ArrayList<String> toReturn = new ArrayList<>(facts.length());

                for (int i = 0; i < facts.length(); i++) {
                    toReturn.add(facts.getString(i));
                }

                data = toReturn;

            } catch (InterruptedException | IOException | JSONException e) {
                ArrayList<String> toReturn = new ArrayList<>();
                toReturn.add("Error:" + e.getMessage());
                data = toReturn;

            }
        }

        Intent notificationIntent = new Intent(this, CatFacts.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
        Notification notification = new Notification.Builder(this).setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle("CatFact Fetcher").setContentText("Data Available")
                .setContentIntent(pendingIntent).build();
        startForeground(ONGOING_NOTIFICATION_ID, notification);

        sendData();
    }

}

From source file:net.peterkuterna.android.apps.devoxxfrsched.service.NewsSyncService.java

@Override
protected void doSync(Intent intent) throws Exception {
    Log.d(TAG, "Refreshing DevoxxFr twitter results");

    boolean noNotifications = intent.getBooleanExtra(EXTRA_NO_NOTIFICATIONS, false);

    final Cursor c = mResolver.query(News.CONTENT_URI, NewsQuery.PROJECTION, null, null, null);

    String newsId = "0";
    try {/*from w  ww .j  a  va2 s.c  om*/
        if (c.moveToFirst()) {
            newsId = c.getString(NewsQuery.MAX_NEWS_ID);
        }
    } finally {
        c.close();
    }

    final Uri uri = TwitterApiUriUtils.buildTwitterSearchUri("from:DevoxxFr +exclude:retweets", newsId);

    mRemoteExecutor.executeGet(uri.toString(), new NewsHandler(noNotifications));

    final NotifierManager notifierManager = new NotifierManager(this);
    notifierManager.notifyNewNewsItems();

    Log.d(TAG, "News sync finished");
}

From source file:com.crea_si.eviacam.service.SplashActivity.java

/**
 * Is the second time this activity is instantiated?
 *
 * @return//  ww w.  ja  v a  2  s  . c  o  m
 */
private boolean isSecondRun() {
    Intent i = SplashActivity.this.getIntent();
    return i.getBooleanExtra(SplashActivity.IS_SECOND_RUN_PARAM, false);
}

From source file:com.crea_si.eviacam.service.SplashActivity.java

/**
 * Was initiated from the accessibility service?
 *
 * @return/*w w  w .  j av a2 s  . co  m*/
 */
private boolean isA11YService() {
    Intent i = SplashActivity.this.getIntent();
    return i.getBooleanExtra(SplashActivity.IS_A11Y_SERVICE_PARAM, false);
}

From source file:com.google.android.apps.muzei.NetworkChangeReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    if (intent == null || !ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
        return;//from  w ww .  ja v  a  2  s. c  om
    }

    boolean hasConnectivity = !intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
    if (hasConnectivity) {
        EventBus.getDefault().post(new GainedNetworkConnectivityEvent());

        // Check with components that may not currently be alive but interested in
        // network connectivity changes.
        Intent retryIntent = ArtworkCache.maybeRetryDownloadDueToGainedConnectivity(context);
        if (retryIntent != null) {
            startWakefulService(context, retryIntent);
        }

        // TODO: wakeful broadcast?
        SourceManager sm = SourceManager.getInstance(context);
        sm.maybeDispatchNetworkAvailable();
    }
}

From source file:ar.com.iron.android.extensions.connections.InetDataClient.java

/**
 * Invocado cuando hay cambios de conectividad en la plataforma
 * //from w  w  w  . j  ava  2 s  . c o m
 * @param intent
 *            Intent con los datos del cambio
 */
protected void onConnectivityChanged(Intent intent) {
    boolean connectivityLoosed = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
    boolean hadConnectivity = this.hasConnectivity.get();
    this.hasConnectivity.set(!connectivityLoosed);
    if (connectivityListener != null && hadConnectivity == connectivityLoosed) {
        // Es un cambio de estado, tenemos que notificarlo
        NetworkInfo network = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
        connectivityListener.onConnectivityChanged(!connectivityLoosed, network);
    }
}

From source file:com.mZone.epro.EproBaseActivity.java

@Override
public void finish() {
    AppLog.i(LOG_TAG, "[IN]finish()");

    // finish?/*  w  w w .j a  v a 2s. co  m*/
    super.finish();

    // ??
    final Intent intent = getIntent();
    final boolean overridePendingTransition = intent
            .getBooleanExtra(INTENT_EXTRA_KEY_OVERRIDE_PENDING_TRANSITION, false);
    if (overridePendingTransition) {
        AppLog.d(LOG_TAG, "[DEBUG]finish() Override Pending Transition.");
        final int enterAnim = intent.getIntExtra(INTENT_EXTRA_KEY_OVERRIDE_PENDING_TRANSITION_ENTER_ANIM,
                OVERRIDE_PENDING_TRANSITION_NO_ANIM);
        final int exitAnim = intent.getIntExtra(INTENT_EXTRA_KEY_OVERRIDE_PENDING_TRANSITION_EXIT_ANIM,
                OVERRIDE_PENDING_TRANSITION_NO_ANIM);
        overridePendingTransition(enterAnim, exitAnim);
    }

    AppLog.i(LOG_TAG, "[OUT]finish()");
}

From source file:com.toppatch.mv.ui.activities.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    String TAG = "MainActivity.onCreate";
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Intent intent = getIntent();
    intent.getExtras();/*from w  w  w .jav  a  2s  .  c  om*/
    Boolean bool = intent.getBooleanExtra("fromReciever", false);
    IntentFilter filter = new IntentFilter();
    filter.addAction(EnterpriseLicenseManager.ACTION_LICENSE_STATUS);
    samsungReciever = new SamsungReceiver();
    this.registerReceiver(samsungReciever, filter);
    if (bool == true) {
        acceptConditions = (Button) findViewById(R.id.acceptConditionsButton);
        acceptConditions.setText("Sorry you need to accept conditions to proceed....");
        acceptConditions.setClickable(true);
    } else {
        Log.i("see", "oncreate");
        checkConditions();
    }

}

From source file:com.bayapps.android.robophish.ui.MusicPlayerActivity.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);
    }// ww w .j a va  2s .  c  o m
}