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:augsburg.se.alltagsguide.utilities.ui.BasePageWebViewLanguageActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putSerializable(PAGE_STATE, mPage);
    outState.putBoolean(TRANSLATED_DISMISSED, mTranslatedDismissed);
    super.onSaveInstanceState(outState);
}

From source file:com.google.android.apps.authenticator.dataexport.Exporter.java

private Bundle getPreferencesBundle(SharedPreferences preferences) {
    Map<String, ?> preferencesMap = preferences.getAll();
    if (preferencesMap == null) {
        preferencesMap = Collections.emptyMap();
    }/*from   www.  j  a v a2 s . com*/
    Bundle result = new Bundle();
    for (String key : preferencesMap.keySet()) {
        Object value = preferencesMap.get(key);
        if (value instanceof Boolean) {
            result.putBoolean(key, (Boolean) value);
        } else if (value instanceof Float) {
            result.putFloat(key, (Float) value);
        } else if (value instanceof Integer) {
            result.putInt(key, (Integer) value);
        } else if (value instanceof Long) {
            result.putLong(key, (Long) value);
        } else if (value instanceof String) {
            result.putString(key, (String) value);
        } else {
            // Can only be Set<String> at the moment (API Level 11+), which we don't use anyway.
            // Ignore this type of preference, since losing preferences on export is not lethal
        }
    }
    return result;
}

From source file:my.home.lehome.service.SendMsgIntentService.java

private void preparePengindCommand(Intent intent) {
    Messenger messenger;/*from w  w  w  . jav  a  2  s.  co m*/
    if (intent.hasExtra("messenger"))
        messenger = (Messenger) intent.getExtras().get("messenger");
    else
        messenger = null;
    Message repMsg = Message.obtain();
    repMsg.what = MSG_BEGIN_SENDING;

    boolean isSysCmd = intent.getBooleanExtra("isSysCmd", false);
    if (isSysCmd) {
        Log.d(TAG, "sys cmd item");
        return;
    }

    ChatItem item = intent.getParcelableExtra("update");
    if (item == null) {
        item = new ChatItem();
        item.setContent(intent.getStringExtra("cmd"));
        item.setType(ChatItemConstants.TYPE_CLIENT);
        item.setState(Constants.CHATITEM_STATE_ERROR); // set ERROR
        item.setDate(new Date());
        DBStaticManager.addChatItem(getApplicationContext(), item);
    }
    item.setState(Constants.CHATITEM_STATE_PENDING);

    Log.d(TAG, "enqueue item: \n" + item);
    Bundle bundle = new Bundle();
    bundle.putBoolean("update", intent.hasExtra("update"));
    bundle.putParcelable("item", item);
    if (messenger != null) {
        repMsg.setData(bundle);
        try {
            messenger.send(repMsg);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    } else {
        Log.d(TAG, "messager is null, send broadcast instead:" + ACTION_SEND_MSG_BEGIN);
        Intent newIntent = new Intent(ACTION_SEND_MSG_BEGIN);
        newIntent.putExtras(bundle);
        sendBroadcast(newIntent);
    }

    intent.putExtra("pass_item", item);
}

From source file:com.github.chenxiaolong.dualbootpatcher.switcher.MbtoolTaskOutputFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBoolean(EXTRA_IS_RUNNING, mIsRunning);
    outState.putInt(EXTRA_TASK_ID, mTaskId);
}

From source file:com.ntsync.android.sync.activities.PaymentVerificationService.java

private void processResult(Context context, AccountManager acm, Account account,
        PayPalConfirmationResult result) {
    boolean removePayment = false;

    int msg = -1;
    Class<? extends Activity> activityClass = ShopActivity.class;

    LogHelper.logI(TAG, "PaymentVerification Result:  " + result);
    switch (result) {
    case SUCCESS:
        removePayment = true;/*from  ww w .jav  a  2 s. c o m*/
        msg = R.string.shop_activity_paymentsuccess;
        Bundle extras = new Bundle();
        extras.putBoolean(Constants.PARAM_GETRESTRICTIONS, true);
        ContentResolver.requestSync(account, Constants.CONTACT_AUTHORITY, extras);
        activityClass = ViewAccountsActivity.class;
        break;
    case INVALID_PRICE:
        removePayment = true;
        msg = R.string.shop_activity_invalidprice;
        break;
    case INVALID_SYNTAX:
        removePayment = true;
        msg = R.string.shop_activity_invalidsyntax;
        break;
    case CANCELED:
        removePayment = true;
        msg = R.string.shop_activity_paymentcanceled;
        break;
    case NOT_APPROVED:
    case SALE_NOT_COMPLETED:
    case VERIFIER_ERROR:
    case NETWORK_ERROR:
    case AUTHENTICATION_FAILED:
        // Don't show message -> try again later
        break;
    case ALREADY_PROCESSED:
        removePayment = true;
        break;
    case UNKNOWN_PAYMENT:
        removePayment = true;
        msg = R.string.shop_activity_verificationfailed;
        break;
    default:
        removePayment = true;
        LogHelper.logE(TAG, "Unknown PaymentVerificationResult:" + result, null);
        // Unknown State
        msg = R.string.shop_activity_verificationfailed;
        break;
    }

    if (removePayment) {
        SyncUtils.savePayment(account, acm, null, null);
    }
    if (msg > 0) {
        sendNotification(context, account, msg, activityClass, true);

    }
}

From source file:com.openerp.services.UserGroupsSyncService.java

/**
 * Perform sync.//from w  w w  .ja  va  2  s  . co  m
 * 
 * @param context
 *            the context
 * @param account
 *            the account
 * @param extras
 *            the extras
 * @param authority
 *            the authority
 * @param provider
 *            the provider
 * @param syncResult
 *            the sync result
 */
public void performSync(Context context, Account account, Bundle extras, String authority,
        ContentProviderClient provider, SyncResult syncResult) {
    // TODO Auto-generated method stub
    try {
        UserGroupsDb usergroups = new UserGroupsDb(context);
        Intent intent = new Intent();
        intent.setAction(SyncFinishReceiver.SYNC_FINISH);
        if (OpenERPServerConnection.isNetworkAvailable(context)) {
            Log.i(TAG + "::performSync()", "Sync with Server Started");
            OEHelper oe = usergroups.getOEInstance();
            if (oe.syncWithServer(usergroups, null, false, false)) {
                MailFollowerDb group_follower = new MailFollowerDb(context);
                OEHelper oe_1 = group_follower.getOEInstance();
                JSONObject domain = new JSONObject();
                int partner_id = Integer.parseInt(OpenERPAccountManager.currentUser(context).getPartner_id());
                domain.accumulate("domain", new JSONArray("[[\"partner_id\", \"=\", " + partner_id
                        + "],[\"res_model\",\"=\", \"" + usergroups.getModelName() + "\"]]"));

                if (oe_1.syncWithServer(group_follower, domain, false, false)) {
                    Log.i(TAG, "UserGroups Sync Finished");
                    MailFollowerDb follower = new MailFollowerDb(context);
                    List<HashMap<String, Object>> user_groups = follower.executeSQL(follower.getModelName(),
                            new String[] { "res_id" },
                            new String[] { "partner_id = ?", "AND", "res_model = ?" },
                            new String[] { partner_id + "", "mail.group" });
                    JSONArray group_ids = new JSONArray();
                    if (user_groups.size() > 0) {
                        for (HashMap<String, Object> row : user_groups) {
                            group_ids.put(Integer.parseInt(row.get("res_id").toString()));
                        }
                    }
                    context.sendBroadcast(intent);
                    Bundle bundle = new Bundle();
                    bundle.putString("group_ids", group_ids.toString());
                    bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
                    bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
                    ContentResolver.requestSync(account, MessageProvider.AUTHORITY, bundle);
                }

            }

        } else {
            Log.e("OpenERPServerConnection", "Unable to Connect with server");
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

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

@Override
protected Void doInBackground(String... urls) {
    if (IsNetworkAvailible(mContext)) {
        String sPostBody = urls[0];

        // Create a new HttpClient and Post Header
        HttpClient httpclient = new DefaultHttpClient();

        HttpPost httppost = new HttpPost("http://gis-lab.info:8090/");

        HttpParams params = httppost.getParams();
        params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE);

        HttpContext localContext = new BasicHttpContext();

        try {/*ww  w  .  j a va2  s .c  o m*/
            StringEntity se = new StringEntity(sPostBody, "UTF8");
            se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
            httppost.setEntity(se);
            httppost.setHeader("Content-type", "application/json");

            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost, localContext);

            Bundle bundle = new Bundle();
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                bundle.putBoolean("error", false);
            } else {
                bundle.putBoolean("error", true);
            }

            bundle.putInt("src", mnType);
            Message msg = new Message();
            msg.setData(bundle);
            if (mEventReceiver != null) {
                mEventReceiver.sendMessage(msg);
            }

        } catch (ClientProtocolException e) {
            mError = e.getMessage();
            cancel(true);
        } catch (IOException e) {
            mError = e.getMessage();
            cancel(true);
        }
    } else {
        Bundle bundle = new Bundle();
        bundle.putBoolean("error", true);
        bundle.putString("err_msq", mContext.getString(R.string.sNetworkUnreach));
        bundle.putInt("src", mnType);

        Message msg = new Message();
        msg.setData(bundle);
        if (mEventReceiver != null) {
            mEventReceiver.sendMessage(msg);
        }
    }
    return null;
}

From source file:com.google.android.apps.muzei.api.internal.SourceState.java

public Bundle toBundle() {
    Bundle bundle = new Bundle();
    if (mCurrentArtwork != null) {
        bundle.putBundle("currentArtwork", mCurrentArtwork.toBundle());
    }//  w w  w . jav  a2s . c om
    bundle.putString("description", mDescription);
    bundle.putBoolean("wantsNetworkAvailable", mWantsNetworkAvailable);
    String[] commandsSerialized = new String[mUserCommands.size()];
    for (int i = 0; i < commandsSerialized.length; i++) {
        commandsSerialized[i] = mUserCommands.get(i).serialize();
    }
    bundle.putStringArray("userCommands", commandsSerialized);
    return bundle;
}

From source file:es.uniovi.imovil.fcrtrainer.TwosComplementExerciseFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    outState.putBoolean("modeToDecimal", modeToDecimal);
    outState.putString("numbToConvert", numbToConvert);

}

From source file:com.normalexception.app.rx8club.task.AdminTask.java

@Override
protected void onPostExecute(Void result) {
    try {//ww w  .ja va  2 s  . c o m
        mProgressDialog.dismiss();
        mProgressDialog = null;
    } catch (Exception e) {
        Log.w(TAG, e.getMessage());
    }

    if (doType == LOCK_THREAD) {
        Bundle args = sourceFragment.getArguments();
        boolean isLocked = args.getBoolean("locked");
        Log.d(TAG, "Setting Thread Lock To: " + !isLocked);
        args.putBoolean("locked", !isLocked);

        // Create new fragment and transaction
        Fragment newFragment = ThreadFragment.newInstance();

        FragmentUtils.fragmentTransaction(sourceFragment.getActivity(), newFragment, true, true, args);
    } else if (doType == MOVE_THREAD) {
        MoveThreadDialog mtd = new MoveThreadDialog(sourceFragment, token, thread, threadTitle, selectOptions);
        mtd.show();
    } else {
        //this.sourceFragment.finish();
        sourceFragment.getFragmentManager().popBackStack();
    }
}