Example usage for android.os Bundle getBoolean

List of usage examples for android.os Bundle getBoolean

Introduction

In this page you can find the example usage for android.os Bundle getBoolean.

Prototype

public boolean getBoolean(String key) 

Source Link

Document

Returns the value associated with the given key, or false if no mapping of the desired type exists for the given key.

Usage

From source file:ca.rmen.android.networkmonitor.app.dialog.filechooser.FileChooserDialogFragment.java

/**
 * @return a Dialog to browse files and folders
 *//*from   w w  w  . j a v  a2 s.  com*/
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Log.v(TAG, "onCreateDialog: savedInstanceState = " + savedInstanceState);

    Bundle arguments = getArguments();
    final int actionId = arguments.getInt(DialogFragmentFactory.EXTRA_ACTION_ID);
    boolean foldersOnly = arguments.getBoolean(FileChooserDialogFragment.EXTRA_FILE_CHOOSER_FOLDERS_ONLY);

    mSelectedFile = getInitialFolder(savedInstanceState);

    final Context context = getActivity();
    final FileAdapter adapter = new FileAdapter(context, mSelectedFile, foldersOnly);

    // Save the file the user selected. Reload the dialog with the new folder
    // contents.
    OnClickListener fileSelectionListener = new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            mSelectedFile = adapter.getItem(i);
            if (mSelectedFile.isDirectory()) {
                adapter.load(mSelectedFile);
                AlertDialog dialog = (AlertDialog) dialogInterface;
                dialog.setTitle(FileChooser.getFullDisplayName(context, mSelectedFile));
                dialog.getListView().clearChoices();
                dialog.getListView().setSelectionAfterHeaderView();
            }
        }
    };

    // When the user taps the positive button, notify the listener.
    OnClickListener positiveListener = new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            FileChooserDialogListener activity = (FileChooserDialogListener) getActivity();
            if (activity == null)
                Log.w(TAG, "User clicked on dialog after it was detached from activity. Monkey?");
            else
                activity.onFileSelected(actionId, mSelectedFile);
        }
    };

    // Dismiss/cancel callbacks: Are all of these needed?
    OnClickListener negativeListener = new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            ((FileChooserDialogListener) getActivity()).onDismiss(actionId);
        }
    };
    OnCancelListener cancelListener = new OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialogInterface) {
            ((FileChooserDialogListener) getActivity()).onDismiss(actionId);
        }
    };
    OnDismissListener dismissListener = new OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            ((FileChooserDialogListener) getActivity()).onDismiss(actionId);
        }
    };
    AlertDialog dialog = new AlertDialog.Builder(context)
            .setTitle(FileChooser.getFullDisplayName(context, mSelectedFile))
            .setSingleChoiceItems(adapter, -1, fileSelectionListener)
            .setPositiveButton(R.string.file_chooser_choose, positiveListener)
            .setNegativeButton(android.R.string.cancel, negativeListener).setOnCancelListener(cancelListener)
            .create();
    dialog.setOnDismissListener(dismissListener);
    return dialog;
}

From source file:com.alchemiasoft.book.fragment.BooksFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    switch (id) {
    case ID_LOADER_BOOKS:
        final boolean owned = args.getBoolean(KEY_OWNED);
        if (owned) {
            return new CursorLoader(getActivity(), BookDB.Book.CONTENT_URI, null, SELECTION, SELECT_OWNED,
                    null);/*from  w ww .  j a v a  2s  . co  m*/
        } else {
            return new CursorLoader(getActivity(), BookDB.Book.CONTENT_URI, null, null, null, null);
        }
    default:
        throw new IllegalArgumentException("loader id=" + id + " is not supported!");
    }
}

From source file:com.nextgis.uikobserver.MainActivity.java

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

    mFillDataHandler = new Handler() {
        public void handleMessage(Message msg) {
            Bundle resultData = msg.getData();
            boolean bHaveErr = resultData.getBoolean("error");
            if (bHaveErr) {
                Toast.makeText(MainActivity.this, getResources().getText(R.string.sFailed), Toast.LENGTH_LONG)
                        .show();/*  ww w  .j  av  a 2s.  c  o  m*/
            } else {
                Toast.makeText(MainActivity.this, getResources().getText(R.string.sSuccess), Toast.LENGTH_LONG)
                        .show();
            }
        };
    };

    sendButton = (Button) findViewById(R.id.sendDataBtn);
    sendButton.setEnabled(false);
    sendButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            SendData();
        }
    });

    tvLoc = (TextView) findViewById(R.id.locationString);

    tvUIK = (TextView) findViewById(R.id.uikNo);
    tvEMail = (TextView) findViewById(R.id.userMail);
    tvNote = (TextView) findViewById(R.id.notesString);

    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    currentLocationListener = new CurrentLocationListener();

    dfLon = 200;
    dfLat = 200;

    sN = (String) getResources().getText(R.string.compas_N);
    sS = (String) getResources().getText(R.string.compas_S);
    sW = (String) getResources().getText(R.string.compas_W);
    sE = (String) getResources().getText(R.string.compas_E);

    sCoordLat = (String) getResources().getText(R.string.coord_lat);
    sCoordLon = (String) getResources().getText(R.string.coord_lon);

    //sUIK, sMail, sNote

    requestLocationUpdates();
}

From source file:com.google.android.gms.samples.plus.SignInActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mHasCalledGooglePlusApiEndpoint = savedInstanceState
                .getBoolean(KEY_HAS_CALLED_GOOGLE_PLUS_API_ENDPOINT);
    }/*from www.  j  a  va  2s .  co m*/
    setContentView(R.layout.sign_in_activity);
    mPlusClient = new PlusClient(this, this, this, SCOPES);

    // Spinner progress bar to be displayed if the user clicks the Google+
    // sign-in button before resolving connection errors.
    mConnectionProgressDialog = new ProgressDialog(SignInActivity.this);
    mConnectionProgressDialog.setMessage(getString(R.string.signing_in_status));
    mConnectionProgressDialog.setOwnerActivity(SignInActivity.this);

    findViewById(R.id.sign_in_button).setOnClickListener(this);
    findViewById(R.id.sign_out_button).setOnClickListener(this);
    mSignInStatus = (TextView) findViewById(R.id.sign_in_status);
}

From source file:com.manning.androidhacks.hack023.authenticator.Authenticator.java

@Override
public Bundle getAccountRemovalAllowed(AccountAuthenticatorResponse response, Account account)
        throws NetworkErrorException {
    Bundle result = super.getAccountRemovalAllowed(response, account);

    if (result != null && result.containsKey(AccountManager.KEY_BOOLEAN_RESULT)
            && !result.containsKey(AccountManager.KEY_INTENT)) {
        boolean allowed = result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT);

        if (allowed) {
            for (int i = 0; i < authoritiesToSync.length; i++) {
                ContentResolver.cancelSync(account, authoritiesToSync[i]);
            }//from www  . j  av a 2  s  .c  o m

            mContext.deleteDatabase(DatabaseHelper.DATABASE_NAME);
        }
    }

    return result;
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.SignBrowserFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Log.d(TAG, "onActivityCreated " + hashCode());
    super.onActivityCreated(savedInstanceState);
    if (savedInstanceState != null) {
        this.showStarredOnly = savedInstanceState.getBoolean(KEY_SHOW_STARRED_ONLY);
    }//from   w  w w . ja va 2  s .  c  o m
    this.loadSignsTask = new LoadSignsTask(getActivity());
    this.loadSignsTask.execute(this.showStarredOnly);
}

From source file:cz.muni.fi.japanesedictionary.entity.Translation.java

/**
 *   Creates new instance of Translation from saved instance in given bundle.
 * //from   w w w . j av a  2 s  .  c o m
 * @param bundle bundle with saved Translation
 * @return returns new instance of Translation or null if bundle is null
 */
public static Translation newInstanceFromBundle(Bundle bundle) {
    if (bundle == null) {
        return null;
    }
    Translation translation = new Translation();

    String japaneseKeb = bundle.getString(SAVE_JAPANESE_KEB);
    String japaneseReb = bundle.getString(SAVE_JAPANESE_REB);
    String english = bundle.getString(SAVE_ENGLISH);
    String french = bundle.getString(SAVE_FRENCH);
    String dutch = bundle.getString(SAVE_DUTCH);
    String german = bundle.getString(SAVE_GERMAN);
    String russian = bundle.getString(SAVE_RUSSIAN);

    translation.parseJapaneseKeb(japaneseKeb);
    translation.parseJapaneseReb(japaneseReb);
    translation.parseEnglish(english);
    translation.parseFrench(french);
    translation.parseDutch(dutch);
    translation.parseGerman(german);
    translation.parseRussian(russian);

    translation.setPrioritized(bundle.getBoolean(SAVE_PRIORITIZED));
    translation.setRuby(bundle.getString(SAVE_RUBY));
    return translation.getJapaneseReb() != null && translation.getJapaneseReb().size() > 0 ? translation : null;
}

From source file:com.android2ee.tileprovider.activity.MainActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    boolean type = savedInstanceState.getBoolean(KEY_TYPE_NORMAL);
    if (type != typeNormal) {
        typeNormal = type;// w w  w. j av  a2s  .  c  o  m
    }
    // refresh map and menu
    updateMenu();
    updateMap();
}

From source file:com.microsoft.azure.engagement.cordova.AZME.java

public void initialize(CordovaInterface _cordova, CordovaWebView _webView) {
    CordovaActivity activity = (CordovaActivity) _cordova.getActivity();

    String invokeString = activity.getIntent().getDataString();
    super.initialize(_cordova, _webView);

    cordova = _cordova;//  w w  w.j a  v  a2s .co  m
    webView = _webView;

    try {
        ApplicationInfo ai = activity.getPackageManager().getApplicationInfo(activity.getPackageName(),
                PackageManager.GET_META_DATA);
        Bundle bundle = ai.metaData;

        boolean nativeLog = bundle.getBoolean("engagement:log:test");
        boolean pluginLog = bundle.getBoolean("AZME_ENABLE_PLUGIN_LOG");
        EngagementShared.instance().setPluginLog(pluginLog);
        EngagementShared.instance().initSDK(pluginName, pluginVersion, nativeSDKVersion);

        if (invokeString != null && !invokeString.equals("")) {
            lastRedirect = invokeString;
            EngagementShared.instance().logD("handleOpenURL=" + lastRedirect);
        }

        lazyAreaLocation = bundle.getBoolean("AZME_LAZYAREA_LOCATION");
        realtimeLocation = bundle.getBoolean("AZME_REALTIME_LOCATION");
        fineRealtimeLocation = bundle.getBoolean("AZME_FINEREALTIME_LOCATION");
        backgroundReporting = bundle.getBoolean("AZME_BACKGROUND_REPORTING");
        foregroundReporting = bundle.getBoolean("AZME_FOREGROUND_REPORTING");

        String connectionString = bundle.getString("AZME_ANDROID_CONNECTION_STRING");
        EngagementShared.backgroundReportingType background = EngagementShared.backgroundReportingType.BACKGROUNDREPORTING_NONE;
        EngagementShared.locationReportingType locationReporting = EngagementShared.locationReportingType.LOCATIONREPORTING_NONE;

        if (lazyAreaLocation)
            locationReporting = EngagementShared.locationReportingType.LOCATIONREPORTING_LAZY;
        else if (realtimeLocation)
            locationReporting = EngagementShared.locationReportingType.LOCATIONREPORTING_REALTIME;
        else if (fineRealtimeLocation)
            locationReporting = EngagementShared.locationReportingType.LOCATIONREPORTING_FINEREALTIME;

        if (backgroundReporting)
            background = EngagementShared.backgroundReportingType.BACKGROUNDREPORTING_BACKGROUND;
        else if (foregroundReporting)
            background = EngagementShared.backgroundReportingType.BACKGROUNDREPORTING_FOREGROUND;

        EngagementShared.instance().initialize(activity, connectionString, locationReporting, background);
        EngagementShared.instance().setDelegate(delegate);

    } catch (PackageManager.NameNotFoundException e) {
        EngagementShared.instance().logE("Failed to load meta-data, NameNotFound: " + e.getMessage());
    } catch (NullPointerException e) {
        EngagementShared.instance().logE("Failed to load meta-data, NullPointer: " + e.getMessage());
    }

}

From source file:eu.masconsult.bgbanking.accounts.AccountAuthenticator.java

@Override
public Bundle getAccountRemovalAllowed(AccountAuthenticatorResponse response, Account account)
        throws NetworkErrorException {
    Log.v(TAG, "getAccountRemovalAllowed(account: " + account + ")");
    Bundle result = super.getAccountRemovalAllowed(response, account);

    if (result != null && result.containsKey(AccountManager.KEY_BOOLEAN_RESULT)
            && !result.containsKey(AccountManager.KEY_INTENT)) {
        final boolean removalAllowed = result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT);

        if (removalAllowed) {
            // Do my removal stuff here
            BankAccountManager.removeAccount(context, account);
        }//from w ww  .  j  a  v a  2s  .c  o m
    }

    return result;
}