Example usage for android.os Bundle putBoolean

List of usage examples for android.os Bundle putBoolean

Introduction

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

Prototype

public void putBoolean(@Nullable String key, boolean value) 

Source Link

Document

Inserts a Boolean value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.synox.android.ui.activity.FileActivity.java

/**
 * {@inheritDoc}// ww w  .  j  av a  2 s  .  c  o m
 */
@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putParcelable(FileActivity.EXTRA_FILE, mFile);
    outState.putBoolean(FileActivity.EXTRA_FROM_NOTIFICATION, mFromNotification);
    outState.putLong(KEY_WAITING_FOR_OP_ID, mFileOperationsHelper.getOpIdWaitingFor());
    if (getSupportActionBar() != null && getSupportActionBar().getTitle() != null) {
        // Null check in case the actionbar is used in ActionBar.NAVIGATION_MODE_LIST
        // since it doesn't have a title then
        outState.putString(KEY_ACTION_BAR_TITLE, getSupportActionBar().getTitle().toString());
    }
    super.onSaveInstanceState(outState);
}

From source file:com.android.contacts.list.DefaultContactBrowseListFragment.java

/**
 * Request sync for the Google accounts (not include Google+ accounts) specified by the given
 * filter./*ww  w. j a  v a2  s. c o m*/
 */
private void syncContacts(ContactListFilter filter) {
    if (filter == null) {
        return;
    }

    final Bundle bundle = new Bundle();
    bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
    bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);

    final List<AccountWithDataSet> accounts = AccountInfo
            .extractAccounts(Futures.getUnchecked(mWritableAccountsFuture));
    final List<Account> syncableAccounts = filter.getSyncableAccounts(accounts);
    if (syncableAccounts != null && syncableAccounts.size() > 0) {
        for (Account account : syncableAccounts) {
            // We can prioritize Contacts sync if sync is not initialized yet.
            if (!SyncUtil.isSyncStatusPendingOrActive(account) || SyncUtil.isUnsyncableGoogleAccount(account)) {
                ContentResolver.requestSync(account, ContactsContract.AUTHORITY, bundle);
            }
        }
    }
}

From source file:ch.bfh.evoting.alljoyn.BusHandler.java

/**
 * Initialize AllJoyn/*from  ww  w.  ja v  a2  s  . c  o  m*/
 */
private void doInit() {
    PeerGroupListener pgListener = new PeerGroupListener() {

        @Override
        public void foundAdvertisedName(String groupName, short transport) {
            Intent i = new Intent("advertisedGroupChange");
            LocalBroadcastManager.getInstance(context).sendBroadcast(i);
        }

        @Override
        public void lostAdvertisedName(String groupName, short transport) {
            Intent i = new Intent("advertisedGroupChange");
            LocalBroadcastManager.getInstance(context).sendBroadcast(i);
        }

        @Override
        public void groupLost(String groupName) {
            if (mGroupManager.listHostedGroups().contains(groupName)
                    && mGroupManager.getNumPeers(groupName) == 1) {
                //signal was send because admin stays alone in the group
                //not necessary to manage this case for us
                Log.d(TAG, "Group destroyed event ignored");
                return;
            }
            Log.d(TAG, "Group " + groupName + " was destroyed.");
            Intent i = new Intent("groupDestroyed");
            i.putExtra("groupName", groupName);
            LocalBroadcastManager.getInstance(context).sendBroadcast(i);
        }

        @Override
        public void peerAdded(String busId, String groupName, int numParticipants) {
            Log.d(TAG, "peer added");

            if (amIAdmin) {
                Log.d(TAG, "Sending salt " + Base64.encodeToString(messageEncrypter.getSalt(), Base64.DEFAULT));
                Message msg = obtainMessage(BusHandler.PING);
                Bundle data = new Bundle();
                data.putString("groupName", lastJoinedNetwork);
                data.putString("pingString", Base64.encodeToString(messageEncrypter.getSalt(), Base64.DEFAULT));
                data.putBoolean("encrypted", false);
                data.putSerializable("type", Type.SALT);
                msg.setData(data);
                sendMessage(msg);
            }

            //update UI
            LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("participantStateUpdate"));

        }

        @Override
        public void peerRemoved(String peerId, String groupName, int numPeers) {
            //update UI
            Log.d(TAG, "peer left");
            Intent intent = new Intent("participantStateUpdate");
            intent.putExtra("action", "left");
            intent.putExtra("id", peerId);
            LocalBroadcastManager.getInstance(context).sendBroadcast(intent);

            super.peerRemoved(peerId, groupName, numPeers);
        }

    };

    ArrayList<BusObjectData> busObjects = new ArrayList<BusObjectData>();
    Handler mainHandler = new Handler(context.getMainLooper());

    Runnable myRunnable = new Runnable() {

        @Override
        public void run() {
            org.alljoyn.bus.alljoyn.DaemonInit.PrepareDaemon(context);
        }

    };
    mainHandler.post(myRunnable);

    busObjects.add(new BusObjectData(mSimpleService, "/SimpleService"));
    mGroupManager = new PeerGroupManager(SERVICE_NAME, pgListener, busObjects);
    mGroupManager.registerSignalHandlers(this);
}

From source file:br.liveo.navigationliveo.NavigationLiveoAWizard.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    // TODO Auto-generated method stub      
    super.onSaveInstanceState(outState);
    outState.putInt(CURRENT_POSITION, mCurrentPosition);

    //FORM WIZARD
    outState.putBundle("model", mWizardModel.save());
    outState.putBoolean("dataChanged", mDataChanged);
}

From source file:butter.droid.base.fragments.BaseVideoPlayerFragment.java

private void subsTimingSettings() {
    Bundle args = new Bundle();
    args.putString(NumberPickerDialogFragment.TITLE, getString(R.string.subtitle_timing));
    args.putInt(NumberPickerDialogFragment.MAX_VALUE, 3600);
    args.putInt(NumberPickerDialogFragment.MIN_VALUE, -3600);
    args.putInt(NumberPickerDialogFragment.DEFAULT_VALUE, mSubtitleOffset / 60);
    args.putBoolean(NumberPickerDialogFragment.FOCUSABLE, true);

    NumberPickerDialogFragment dialogFragment = new NumberPickerDialogFragment();
    dialogFragment.setArguments(args);/*  w  ww .j  a  v  a2  s. c  o m*/
    dialogFragment.setOnResultListener(new NumberPickerDialogFragment.ResultListener() {
        @Override
        public void onNewValue(int value) {
            mSubtitleOffset = value * 60;
            showTimedCaptionText(null);
        }
    });
    dialogFragment.show(getChildFragmentManager(), "overlay_fragment");
}

From source file:com.zzl.zl_app.cache.Utility.java

public static boolean loadFile(String loadpath, String fileName, String savePath, Context context,
        String broadcastAction) {
    FileOutputStream fos = null; // ?
    FileInputStream fis = null; // ?
    InputStream is = null; // ?
    HttpURLConnection httpConnection = null;
    int readLength = 0; // ??
    int file_length = 0;
    URL url = null;/*  w w w  .  j a v  a  2s .  c  o m*/
    try {
        url = new URL(loadpath);
        httpConnection = (HttpURLConnection) url.openConnection();
        httpConnection.setConnectTimeout(10000);
        httpConnection.setRequestMethod("GET");
        is = httpConnection.getInputStream();
        FileTools.creatDir(savePath);
        String filePath = savePath + fileName;
        FileTools.deleteFile(filePath);
        FileTools.creatFile(filePath);
        File download_file = new File(filePath);
        fos = new FileOutputStream(download_file, true); // ??
        fis = new FileInputStream(download_file); // ??
        int total_read = fis.available(); // ??0
        file_length = httpConnection.getContentLength(); // ?
        if (is == null) { // ?
            Tools.log("Voice", "donload failed...");
            return false;
        }
        byte buf[] = new byte[3072]; // 
        readLength = 0; // 
        Tools.log("Voice", "download start...");
        Intent startIntent = new Intent();
        Bundle b = new Bundle();
        if (broadcastAction != null) {
            // ?????
            b.putInt("fileSize", file_length);
            b.putInt("progress", 0);
            startIntent.putExtras(b);
            startIntent.setAction(broadcastAction);
            context.sendBroadcast(startIntent);
        }
        // ?????
        while (readLength != -1) {
            if ((readLength = is.read(buf)) > 0) {
                fos.write(buf, 0, readLength);
                total_read += readLength; // 
            }
            if (broadcastAction != null) {
                b.putInt("fileSize", file_length);
                b.putInt("progress", total_read);
                startIntent.putExtras(b);
                startIntent.setAction(broadcastAction);
                context.sendBroadcast(startIntent);
            }
            if (total_read == file_length) { // ?
                Tools.log("Voice", "download complete...");
                // ??????
                if (broadcastAction != null) {
                    Intent completeIntent = new Intent();
                    b.putBoolean("isFinish", true);
                    completeIntent.putExtras(b);
                    completeIntent.setAction(broadcastAction);
                    context.sendBroadcast(completeIntent);
                }

            }
            // Thread.sleep(10); // ?10
        }
    } catch (Exception e) {
        if (broadcastAction != null) {
            Intent errorIntent = new Intent();
            errorIntent.setAction(broadcastAction);
            context.sendBroadcast(errorIntent);
            e.printStackTrace();
        }
    } finally {
        try {
            if (fos != null) {
                fos.close();
            }
            if (fis != null) {
                is.close();
            }
            if (fis != null) {
                fis.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return true;
}

From source file:de.sourcestream.movieDB.controller.SearchList.java

/**
 * Called to ask the fragment to save its current dynamic state,
 * so it can later be reconstructed in a new instance of its process is restarted.
 *
 * @param outState Bundle in which to place your saved state.
 *//*from   w ww.ja  v  a 2  s  .  co  m*/
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    // Used to avoid bug where we add item in the back stack
    // and if we change orientation twice the item from the back stack has null values
    if (save != null)
        outState.putBundle("save", save);
    else {
        Bundle send = new Bundle();
        send.putInt("totalPages", totalPages);
        send.putString("title", getTitle());
        if (backState == 1) {
            send.putInt("backState", 1);
            send.putParcelableArrayList("listData", searchList);
            // used to restore the scroll listener variables
            send.putInt("currentPage", endlessScrollListener.getCurrentPage());
            send.putInt("oldCount", endlessScrollListener.getOldCount());
            send.putBoolean("loading", endlessScrollListener.getLoading());
            // Save scroll position
            if (listView != null) {
                Parcelable listState = listView.onSaveInstanceState();
                send.putParcelable("listViewScroll", listState);
            }
        } else {
            send.putInt("backState", 0);
            send.putString("query", query);
        }
        outState.putBundle("save", send);
    }
}

From source file:heartware.com.heartware_master.FriendsFragment.java

@Override
public void onSaveInstanceState(Bundle bundle) {
    super.onSaveInstanceState(bundle);
    for (FB_BaseListElement listElement : listElements) {
        listElement.onSaveInstanceState(bundle);
    }/*from w  w w  .  j  av  a2 s  .  c om*/
    bundle.putBoolean(PENDING_ANNOUNCE_KEY, pendingAnnounce);
}

From source file:se.leap.bitmaskclient.ProviderAPI.java

private Bundle register(String username, String password) {
    LeapSRPSession client = new LeapSRPSession(username, password);
    byte[] salt = client.calculateNewSalt();

    BigInteger password_verifier = client.calculateV(username, password, salt);

    JSONObject api_result = sendNewUserDataToSRPServer(provider_api_url, username,
            new BigInteger(1, salt).toString(16), password_verifier.toString(16));

    Bundle result = new Bundle();
    if (api_result.has(ERRORS))
        result = authFailedNotification(api_result, username);
    else {/*from  w  w  w.  j a v a2 s  .  com*/
        result.putString(SessionDialog.USERNAME, username);
        result.putString(SessionDialog.PASSWORD, password);
        result.putBoolean(RESULT_KEY, true);
    }

    return result;
}

From source file:com.mirasense.scanditsdk.plugin.ScanditSDK.java

private void setOptionsOnBundle(JSONObject options, Bundle bundle) {
    @SuppressWarnings("unchecked")
    Iterator<String> iter = (Iterator<String>) options.keys();
    while (iter.hasNext()) {
        String key = iter.next();
        Object obj = options.opt(key);
        if (obj != null) {
            if (obj instanceof Float) {
                bundle.putFloat(key.toLowerCase(), (Float) obj);
            } else if (obj instanceof Double) {
                bundle.putDouble(key.toLowerCase(), (Double) obj);
            } else if (obj instanceof Integer) {
                bundle.putInt(key.toLowerCase(), (Integer) obj);
            } else if (obj instanceof Boolean) {
                bundle.putBoolean(key.toLowerCase(), (Boolean) obj);
            } else if (obj instanceof String) {
                bundle.putString(key.toLowerCase(), (String) obj);
            }/* w  w w .  j  av a  2 s .c  om*/
        }
    }
}