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.rickendirk.rsgwijzigingen.MainActivity.java

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

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from w w  w .j a  va2  s  .  c  om*/

    viewPager = (ViewPager) findViewById(R.id.viewPager);
    setupViewPager();

    animDuration = getResources().getInteger(android.R.integer.config_longAnimTime);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);
    tabLayout.setupWithViewPager(viewPager);

    setTitle("Roosterwijzigingen");

    final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    final ViewPagerAdapter adapter = (ViewPagerAdapter) viewPager.getAdapter();
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int itemID = viewPager.getCurrentItem();

            if (itemID == 0) {
                //Persoonlijke pagina, dus checken
                MainFragment mainFragment = (MainFragment) adapter.getItem(itemID);
                mainFragment.checker();
            }
            if (itemID == 1) {
                //Algemeen, dus pagina vernieuwen
                WebFragment webFragment = (WebFragment) adapter.getItem(itemID);
                webFragment.refresh();
            }

        }
    });

    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            if (position == 1) {//webview fragment
                WebFragment webFragment = (WebFragment) adapter.getItem(position);
                boolean isFinished = webFragment.isFinished();
                boolean isLoading = webFragment.isLoading();
                if (!isLoading && !isFinished) {
                    webFragment.refresh();
                }
                fab.hide();
                tracker.send(new HitBuilders.EventBuilder().setCategory("Navigatie")
                        .setAction("naar_webFragment").build());

            } else {
                //Gewone fragment, dus toolbar moet weer bovenaan gaan staan
                AppBarLayout appbar = (AppBarLayout) findViewById(R.id.appBarLayout);
                appbar.setExpanded(true, true);

                fab.show();
                tracker.send(new HitBuilders.EventBuilder().setCategory("Navigatie")
                        .setAction("naar_mainFragment").build());
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    check1ekeer();
    OwnApplication application = (OwnApplication) getApplication();
    tracker = application.getDefaultTracker();
    tracker.setScreenName("onCreate_MainAcitivity");
    tracker.send(new HitBuilders.ScreenViewBuilder().build());

    Intent ownIntent = getIntent();
    boolean isVanNotificatie = ownIntent.getBooleanExtra("isVanNotificatie", false);
    if (isVanNotificatie) {
        NotificationManagerCompat manager = NotificationManagerCompat.from(this);
        manager.cancel(ZoekService.notifID);
    }
    prepareWarmCustomTab();
}

From source file:com.google.android.apps.santatracker.cast.DataCastNotificationService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    LOGD(TAG, "onStartCommand");
    if (intent != null) {

        String action = intent.getAction();
        if (ACTION_VISIBILITY.equals(action)) {
            mVisible = intent.getBooleanExtra(NOTIFICATION_VISIBILITY, false);
            LOGD(TAG, "onStartCommand(): Action: ACTION_VISIBILITY " + mVisible);
            if (mNotification == null) {
                setUpNotification();/*from   w ww  .jav  a  2  s  .co m*/
            }
            if (mVisible && mNotification != null) {
                startForeground(NOTIFICATION_ID, mNotification);
            } else {
                stopForeground(true);
            }
        } else {
            LOGD(TAG, "onStartCommand(): Action: none");
        }

    } else {
        LOGD(TAG, "onStartCommand(): Intent was null");
    }

    return Service.START_STICKY;
}

From source file:cmput301.f13t01.editstory.EditStoryActivity.java

@Override
/**/*from   w ww  .jav  a2s  .  c om*/
 * Override onCreate function
 */
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_story);
    getActionBar().setDisplayHomeAsUpEnabled(false);

    final Button button = (Button) findViewById(R.id.edit_set_first_page);
    button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            buttonPressed = true;
            showFragmentSelection();
        }
    });

    // Get the story manager
    GlobalManager app = (GlobalManager) getApplication();
    manager = GlobalManager.getStoryManager();

    if (savedInstanceState != null) {
        isNew = savedInstanceState.getBoolean(getResources().getString(R.string.story_is_new));
        storyId = (UUID) savedInstanceState.getSerializable(getResources().getString(R.string.story_id));

        app.setStoryManager(storyId);
    } else {
        Intent intent = getIntent();

        isNew = (boolean) intent.getBooleanExtra(getResources().getString(R.string.story_is_new), false);

        if (isNew == false) {
            storyId = (UUID) intent.getSerializableExtra(getResources().getString(R.string.story_id));
            app.setStoryManager(storyId);

            EditText title = (EditText) findViewById(R.id.edit_story_title);
            EditText author = (EditText) findViewById(R.id.edit_story_author);
            EditText desc = (EditText) findViewById(R.id.edit_story_description);

            title.setText(manager.getTitle());
            author.setText(manager.getAuthor());
            desc.setText(manager.getDescription());

        } else {
            storyId = app.createAndSetStory();
        }
    }

    TextView firstPage = (TextView) findViewById(R.id.edit_first_page);
    StoryFragment firstPageFragment = manager.getFirstPage();

    if (firstPageFragment == null) {
        firstPage.setText(getResources().getString(R.string.first_page) + " "
                + getResources().getString(R.string.first_page_empty));
    } else {
        firstPage.setText(
                getResources().getString(R.string.first_page) + " " + manager.getFirstPage().getTitle());
    }

}

From source file:com.android.cts.intent.sender.ContentTest.java

/**
 * The intent receiver will try to read uriNotGranted.
 * Inside the same user, this uri can be read if the receiver has the
 * com.android.cts.managedprofile.permission.SAMPLE permission. But since we cross
 * user-boundaries, it should not be able to (only uri grants work accross users for apps
 * without special permission)./*  w w  w  . j ava  2s . c  o m*/
 * We also grant uriGranted to the receiver (this uri belongs to the same content provider as
 * uriNotGranted), to enforce that even if an app has permission to one uri of a
 * ContentProvider, it still cannot access a uri it does not have access to.
 */
public void testAppPermissionsDontWorkAcrossProfiles() throws Exception {
    // The FileProvider does not allow to use app permissions. So we need to use another
    // ContentProvider.
    Uri uriGranted = getBasicContentProviderUri("uri_granted");
    Uri uriNotGranted = getBasicContentProviderUri("uri_not_granted");

    // Granting uriGranted to the receiver
    // Using a persistable permission so that it is kept even after we restart the receiver
    // activity with another intent.
    grantPersistableReadPermission(uriGranted);

    Intent notGrant = new Intent(ACTION_READ_FROM_URI);
    notGrant.setClipData(ClipData.newRawUri("", uriNotGranted));

    final Intent result = mActivity.getCrossProfileResult(notGrant);
    assertNotNull(result);
    // The receiver did not have permission to read the uri. So it should have caught a security
    // exception.
    assertTrue(result.getBooleanExtra("extra_caught_security_exception", false));
}

From source file:com.cloudmine.api.db.RequestPerformerService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    super.onStartCommand(intent, flags, startId);
    LOG.debug("onStartCommand");
    boolean forceRun = intent.getBooleanExtra(FORCE_RUN_KEY, false);
    if (forceRun) {
        forceRun();/*from  w  w w .  j av  a 2 s .co m*/
    }
    return START_STICKY;
}

From source file:com.google.android.gms.location.sample.locationupdatesforegroundservice.LocationUpdatesService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i(TAG, "Service started");
    boolean startedFromNotification = intent.getBooleanExtra(EXTRA_STARTED_FROM_NOTIFICATION, false);

    // We got here because the user decided to remove location updates from the notification.
    if (startedFromNotification) {
        removeLocationUpdates();/*from  ww  w  . j av  a 2 s. c  o  m*/
        stopSelf();
    }
    // Tells the system to not try to recreate the service after it has been killed.
    return START_NOT_STICKY;
}

From source file:net.networksaremadeofstring.rhybudd.ZenossPoller.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null && intent.getBooleanExtra("events", false)) {
        //Log.i("onStartCommand","Received an intent to check for events");
        CheckForEvents();/*from  w ww  .j  a  v a 2 s.c  om*/
    }
    /*else if(intent != null && intent.getBooleanExtra("refreshCache", false))
    {
       //Log.i("onStartCommand","Received an intent to refresh the cache");
       RefreshCache();
    }*/
    else if (intent != null && intent.getBooleanExtra("settingsUpdate", false)) {
        //Refresh our reference to the settings just in case something changed
        settings = PreferenceManager.getDefaultSharedPreferences(this);
        //Log.i("onStartCommand","Received an intent from the settings Activity");
        PollerCheck();
    } else {
        //Log.i("onStartCommand","I got started for no particular reason. I should probably do a refresh (but I'm not going too");
        //PollerCheck();
    }

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

From source file:com.anenn.photopick.ImagePagerActivity.java

private void initValue() {
    Intent intent = getIntent();
    mShowUris = intent.getStringArrayListExtra(SHOW_URIS);
    mPagerPosition = intent.getIntExtra(PAGER_POSITION, -1);
    mEditable = intent.getBooleanExtra(EDITABLE, false);
    String mSingleUri = intent.getStringExtra(SINGLE_URI);

    if (mSingleUri != null) {
        mShowUris = new ArrayList<>();
        mShowUris.add(mSingleUri);/*  ww  w .j  av a 2  s  .c o m*/
        mPagerPosition = 0;
    }

    View customActionBar = getLayoutInflater().inflate(R.layout.layout_image_pager_actionbar, null);
    tvImagePos = (TextView) customActionBar.findViewById(R.id.imagePos);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        if (mEditable) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayShowTitleEnabled(false);
            actionBar.setIcon(android.R.color.transparent);
            actionBar.setCustomView(customActionBar);
            actionBar.setDisplayShowCustomEnabled(true);
            viewPager.setBackgroundColor(getResources().getColor(R.color.bg_grep));
            viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
                @Override
                public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                }

                @Override
                public void onPageSelected(int position) {
                    setPosDisplay(position);
                }

                @Override
                public void onPageScrollStateChanged(int state) {
                }
            });
            setPosDisplay(0);
        } else {
            actionBar.hide();
            viewPager.setBackgroundColor(getResources().getColor(android.R.color.black));
        }
    }

    initPager();
}

From source file:com.tassadar.multirommgr.MainActivity.java

@Override
protected void onNewIntent(Intent i) {
    super.onNewIntent(i);
    if (i.hasExtra(INTENT_EXTRA_SHOW_ROM_LIST) && i.getBooleanExtra(INTENT_EXTRA_SHOW_ROM_LIST, false)) {
        selectItem(1);//from   w w  w . ja v a2s .  c o m
    }
}

From source file:com.morlunk.leeroy.LeeroyUpdateService.java

@Override
protected void onHandleIntent(Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_RECEIVER);
        if (ACTION_CHECK_UPDATES.equals(action)) {
            final boolean notify = intent.getBooleanExtra(EXTRA_NOTIFY, false);
            handleCheckUpdates(intent, notify, receiver);
        }/*from   ww w . ja  v a2s .c  o m*/
    }
}