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:org.geometerplus.android.fbreader.network.NetworkLibraryActivity.java

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

    AuthenticationActivity.initCredentialsCreator(this);

    SQLiteCookieDatabase.init(this);

    setListAdapter(new NetworkLibraryAdapter(this));
    final Intent intent = getIntent();
    init(intent);/*from   w  ww  .jav  a2  s . com*/
    myDeferredIntent = null;

    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    if (getCurrentTree() instanceof RootTree) {
        mySingleCatalog = intent.getBooleanExtra("SingleCatalog", false);
        if (!NetworkLibrary.Instance().isInitialized()) {
            Util.initLibrary(this, new Runnable() {
                public void run() {
                    NetworkLibrary.Instance().runBackgroundUpdate(false);
                    if (intent != null) {
                        openTreeByIntent(intent);
                    }
                }
            });
        } else {
            NetworkLibrary.Instance().fireModelChangedEvent(NetworkLibrary.ChangeListener.Code.SomeCode);
            openTreeByIntent(intent);
        }
    }

    getListView().setOnScrollListener(this);
}

From source file:com.clearcenter.mobile_demo.mdAuthenticatorActivity.java

public void onCreate(Bundle bundle) {
    Log.i(TAG, "onCreate(" + bundle + ")");
    super.onCreate(bundle);
    setContentView(R.layout.login_activity);

    account_manager = AccountManager.get(this);

    Log.i(TAG, "loading data from Intent");
    final Intent intent = getIntent();

    nickname = intent.getStringExtra(PARAM_NICKNAME);
    username = intent.getStringExtra(PARAM_USERNAME);
    hostname = intent.getStringExtra(PARAM_HOSTNAME);

    request_new_account = nickname == null;
    confirm_credentials = intent.getBooleanExtra(PARAM_CONFIRM_CREDENTIALS, false);
    Log.i(TAG, "new account? " + request_new_account + ", confirm credentials? " + confirm_credentials);

    scroll_view = (ScrollView) findViewById(R.id.scroll_view);

    message = (TextView) findViewById(R.id.message);

    nickname_label = (TextView) findViewById(R.id.nickname_label);
    nickname_edit = (EditText) findViewById(R.id.nickname_edit);
    nickname_label.setVisibility(request_new_account ? View.VISIBLE : View.GONE);
    nickname_edit.setVisibility(request_new_account ? View.VISIBLE : View.GONE);
    if (nickname != null)
        nickname_edit.setText(nickname);

    hostname_label = (TextView) findViewById(R.id.hostname_label);
    hostname_edit = (EditText) findViewById(R.id.hostname_edit);
    hostname_label.setVisibility(request_new_account ? View.VISIBLE : View.GONE);
    hostname_edit.setVisibility(request_new_account ? View.VISIBLE : View.GONE);
    if (hostname != null)
        hostname_edit.setText(hostname);

    username_label = (TextView) findViewById(R.id.username_label);
    username_edit = (EditText) findViewById(R.id.username_edit);
    username_label.setVisibility(request_new_account ? View.VISIBLE : View.GONE);
    username_edit.setVisibility(request_new_account ? View.VISIBLE : View.GONE);
    if (username != null)
        username_edit.setText(username);

    password_edit = (EditText) findViewById(R.id.password_edit);

    if (confirm_credentials) {
        String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager notification_manager;
        notification_manager = (NotificationManager) getApplicationContext().getSystemService(ns);
        notification_manager.cancelAll();
        Log.i(TAG, "TODO: Cancel all notifications?");
    }/* w  ww . j  a  v a  2s .  c  o  m*/

    if (!TextUtils.isEmpty(nickname))
        nickname_edit.setText(nickname);

    if (request_new_account)
        message.setText(getText(R.string.login_activity_new_account));
    else if (confirm_credentials) {
        message.setText(getText(R.string.login_activity_confirm_credentials));
    }

    try {
        mdSSLUtil.DisableSecurity();
    } catch (GeneralSecurityException e) {
        Toast.makeText(getApplicationContext(), e.getMessage(), 4).show();
    }
}

From source file:com.example.android.wearable.runtimepermissions.MainWearActivity.java

@Override
protected void onNewIntent(Intent intent) {
    Log.d(TAG, "onNewIntent()");
    super.onNewIntent(intent);

    // Checks if phone app requested wear permissions (opens up permission request if true).
    mPhoneRequestingWearSensorPermission = intent.getBooleanExtra(EXTRA_PROMPT_PERMISSION_FROM_PHONE, false);

    if (mPhoneRequestingWearSensorPermission) {
        launchPermissionDialogForPhone();
    }//www  .  j a v a  2s .  co m
}

From source file:com.jtechme.apphub.UpdateService.java

@Override
protected void onHandleIntent(Intent intent) {

    final long startTime = System.currentTimeMillis();
    String address = intent.getStringExtra(EXTRA_ADDRESS);
    boolean manualUpdate = intent.getBooleanExtra(EXTRA_MANUAL_UPDATE, false);

    try {// ww w  .  jav a2 s.  c o  m
        // See if it's time to actually do anything yet...
        if (manualUpdate) {
            Utils.debugLog(TAG, "Unscheduled (manually requested) update");
        } else if (!verifyIsTimeForScheduledRun()) {
            return;
        }

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

        // Grab some preliminary information, then we can release the
        // database while we do all the downloading, etc...
        List<Repo> repos = RepoProvider.Helper.all(this);

        //List<Repo> swapRepos = new ArrayList<>();
        int unchangedRepos = 0;
        int updatedRepos = 0;
        int errorRepos = 0;
        ArrayList<CharSequence> repoErrors = new ArrayList<>();
        boolean changes = false;
        boolean singleRepoUpdate = !TextUtils.isEmpty(address);
        for (final Repo repo : repos) {
            if (!repo.inuse) {
                continue;
            }
            if (singleRepoUpdate && !repo.address.equals(address)) {
                unchangedRepos++;
                continue;
            }
            if (!singleRepoUpdate && repo.isSwap) {
                //swapRepos.add(repo);
                continue;
            }

            sendStatus(this, STATUS_INFO, getString(R.string.status_connecting_to_repo, repo.address));
            RepoUpdater updater = new RepoUpdater(getBaseContext(), repo);
            updater.setProgressListener(this);
            try {
                updater.update();
                if (updater.hasChanged()) {
                    updatedRepos++;
                    changes = true;
                } else {
                    unchangedRepos++;
                }
            } catch (RepoUpdater.UpdateException e) {
                errorRepos++;
                repoErrors.add(e.getMessage());
                Log.e(TAG, "Error updating repository " + repo.address, e);
            }
        }

        if (!changes) {
            Utils.debugLog(TAG,
                    "Not checking app details or compatibility, because all repos were up to date.");
        } else {
            notifyContentProviders();

            if (prefs.getBoolean(Preferences.PREF_UPD_NOTIFY, true)) {
                performUpdateNotification();
            }
        }

        SharedPreferences.Editor e = prefs.edit();
        e.putLong(Preferences.PREF_UPD_LAST, System.currentTimeMillis());
        e.commit();

        if (errorRepos == 0) {
            if (changes) {
                sendStatus(this, STATUS_COMPLETE_WITH_CHANGES);
            } else {
                sendStatus(this, STATUS_COMPLETE_AND_SAME);
            }
        } else {
            if (updatedRepos + unchangedRepos == 0) {
                sendRepoErrorStatus(STATUS_ERROR_LOCAL, repoErrors);
            } else {
                sendRepoErrorStatus(STATUS_ERROR_LOCAL_SMALL, repoErrors);
            }
        }
    } catch (Exception e) {
        Log.e(TAG, "Exception during update processing", e);
        sendStatus(this, STATUS_ERROR_GLOBAL, e.getMessage());
    }

    long time = System.currentTimeMillis() - startTime;
    Log.i(TAG, "Updating repo(s) complete, took " + time / 1000 + " seconds to complete.");
}

From source file:com.flowzr.activity.BlotterFragment.java

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

    Bundle args = this.getArguments();

    if (args != null && blotterFilter.isEmpty()) {
        blotterFilter = WhereFilter.fromBundle(args);
        saveFilter = args.getBoolean(SAVE_FILTER, false);
        isAccountBlotter = args.getBoolean(BlotterFilterActivity.IS_ACCOUNT_FILTER, false);
    } else {/* w  ww. j  a  va  2  s . c  o m*/
        Intent intent = getActivity().getIntent();
        if (intent != null) {
            blotterFilter = WhereFilter.fromIntent(intent);
            saveFilter = intent.getBooleanExtra(SAVE_FILTER, false);
            isAccountBlotter = intent.getBooleanExtra(BlotterFilterActivity.IS_ACCOUNT_FILTER, false);
        }
        if (saveFilter) {
            saveFilter();
        }
    }

}

From source file:com.nextgis.metroaccess.ui.activity.SelectStationActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    //update fragments to new data
    switch (requestCode) {
    case PREF_RESULT:
        if (data != null) {
            isCityChanged = isCityChanged ? isCityChanged : data.getBooleanExtra(BUNDLE_CITY_CHANGED, false);

            if (isCityChanged) {
                clearRecent(PreferenceManager.getDefaultSharedPreferences(this));
                mStationId = -1;/*from ww  w.jav a 2s.com*/
                mPortalId = -1;
            }
        }

        if (mAlphaStListFragment != null)
            mAlphaStListFragment.update();
        if (mLinesStListFragment != null)
            mLinesStListFragment.update();
        if (mRecentStListFragment != null)
            mRecentStListFragment.update();
        break;
    case SUBSCREEN_PORTAL_RESULT:
        if (resultCode == RESULT_OK) {
            int stationID = data.getIntExtra(BUNDLE_STATIONID_KEY, 0);
            int portalID = data.getIntExtra(BUNDLE_PORTALID_KEY, 0);
            finish(stationID, portalID);
        }
        break;
    default:
        break;
    }
}

From source file:com.ekumen.tangobot.application.MainActivity.java

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

    // Load raw resources
    for (Pair<Integer, String> ip : mResourcesToLoad) {
        mOpenedResources.add(new ParameterLoaderNode.Resource(
                getResources().openRawResource(ip.first.intValue()), ip.second));
    }/*ww  w  .  j  ava  2  s . com*/

    mSharedPref = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    // UI
    initializeUI();

    // USB handling code
    mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
    mUsbPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);
    mUsbAttachedReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            mLog.info("Received USB Intent");
            if (intent.getAction() == ACTION_USB_PERMISSION
                    && intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
                onDeviceReady((UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE));
            }
        }
    };
    mUsbDetachedReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            mLog.info("Received USB disconnection Intent");
            UsbDevice device = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
            onDeviceDetached(device);
        }
    };
}

From source file:com.frostwire.android.gui.activities.MainActivity2.java

private boolean isShutdown() {
    Intent intent = getIntent();
    boolean result = intent != null
            && intent.getBooleanExtra("shutdown-" + ConfigurationManager.instance().getUUIDString(), false);
    if (result) {
        shutdown();//from  ww  w.j  a  v  a2  s.co  m
    }
    return result;
}

From source file:com.flowzr.budget.holo.activity.BlotterFragment.java

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

    Bundle args = this.getArguments();
    if (args != null && blotterFilter.isEmpty()) {
        blotterFilter = WhereFilter.fromBundle(args);
        saveFilter = args.getBoolean(SAVE_FILTER, false);
        isAccountBlotter = args.getBoolean(BlotterFilterActivity.IS_ACCOUNT_FILTER, false);
    } else {/*from  w w w  .jav a 2 s .c  o  m*/
        Intent intent = getActivity().getIntent();
        if (intent != null) {
            blotterFilter = WhereFilter.fromIntent(intent);
            saveFilter = intent.getBooleanExtra(SAVE_FILTER, false);
            isAccountBlotter = intent.getBooleanExtra(BlotterFilterActivity.IS_ACCOUNT_FILTER, false);
        }
        if (saveFilter) {
            saveFilter();
        }
    }

}

From source file:cn.wyl.superwechat.ui.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (intent.getBooleanExtra(Constant.ACCOUNT_CONFLICT, false) && !isConflictDialogShow) {
        showConflictDialog();//from   w ww .j  a v a 2  s  .  co  m
    } else if (intent.getBooleanExtra(Constant.ACCOUNT_REMOVED, false) && !isAccountRemovedDialogShow) {
        showAccountRemovedDialog();
    }

}