Example usage for android.os Bundle putParcelable

List of usage examples for android.os Bundle putParcelable

Introduction

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

Prototype

public void putParcelable(@Nullable String key, @Nullable Parcelable value) 

Source Link

Document

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

Usage

From source file:com.android.settings.users.RestrictedProfileSettings.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (mEditUserInfoDialog != null && mEditUserInfoDialog.isShowing() && mEditUserPhotoController != null) {
        outState.putParcelable(KEY_SAVED_PHOTO, mEditUserPhotoController.getNewUserPhotoBitmap());
    }/*from w w  w .ja  va  2s . c  om*/
    if (mWaitingForActivityResult) {
        outState.putBoolean(KEY_AWAITING_RESULT, mWaitingForActivityResult);
    }
}

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

@Override
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType,
        Bundle options) throws NetworkErrorException {
    Log.v(TAG, "getAuthToken(account: " + account + ", authTokenType: " + authTokenType + ")");

    Bank bank = Bank.fromAccountType(context, account.type);
    if (bank == null) {
        throw new IllegalArgumentException("unsupported account type " + account.type);
    }//from   w  ww  .  j a va 2s  .  co m
    if (!Constants.getAuthorityType(context).equals(authTokenType)) {
        throw new IllegalArgumentException("unsupported authTOkenType " + authTokenType);
    }

    final Intent intent = new Intent(context, LoginActivity.class);
    intent.putExtra(KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    intent.putExtra(KEY_ACCOUNT_NAME, account.name);
    intent.putExtra(KEY_ACCOUNT_TYPE, account.type);

    String password = accountManager.getPassword(account);
    try {
        String authToken = bank.getClient().authenticate(account.name, password);
        Log.v(TAG, "obtained auth token " + authToken);

        if (authToken == null) {
            throw new AuthenticationException("no authToken");
        }

        // store the new auth token and return it
        accountManager.setAuthToken(account, authTokenType, authToken);
        intent.putExtra(KEY_AUTHTOKEN, authToken);
        return intent.getExtras();
    } catch (ParseException e) {
        Log.w(TAG, "ParseException", e);
        Bundle bundle = new Bundle();
        bundle.putInt(KEY_ERROR_CODE, 1);
        bundle.putString(KEY_ERROR_MESSAGE, e.getMessage());
        return bundle;
    } catch (IOException e) {
        Log.w(TAG, "IOException", e);
        throw new NetworkErrorException(e);
    } catch (CaptchaException e) {
        Log.w(TAG, "CaptchaException", e);
        // We need human to verify captcha
        final Bundle bundle = new Bundle();
        bundle.putParcelable(AccountManager.KEY_INTENT, intent);
        intent.putExtra(KEY_CAPTCHA_URI, e.getCaptchaUri());
        return bundle;
    } catch (AuthenticationException e) {
        Log.w(TAG, "AuthenticationException", e);
        // we need new credentials
        final Bundle bundle = new Bundle();
        bundle.putParcelable(AccountManager.KEY_INTENT, intent);
        return bundle;
    }
}

From source file:com.adkdevelopment.earthquakesurvival.ui.DetailFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    final Bundle mapViewSaveState = new Bundle(outState);

    if (mMapView != null) {
        mMapView.onSaveInstanceState(mapViewSaveState);
        outState.putBundle(MAP_STATE, mapViewSaveState);
    }//from w w  w.j  ava 2 s. c  o m

    if (mGoogleMap != null) {
        CameraPosition save = mGoogleMap.getCameraPosition();
        outState.putParcelable(CAMERA_POSITION, save);
    }
}

From source file:com.neusou.bioroid.restful.RestfulClient.java

/**
* Executes HTTP method// w w  w  .j  a va  2  s.  com
* @param <T> Http Request Method class
* @param <V> Restful response class
* @param <M> restful method class
* @param <R> response handler class
* @param httpMethod http request method
* @param rh response handler
* @param data extra invocation data
*/
public <T extends HttpRequestBase, V extends IRestfulResponse<?>, M extends RestfulMethod, R extends RestfulResponseHandler<V, M>> void execute(
        final T httpMethod, R rh, final Bundle data) {
    Logger.l(Logger.DEBUG, LOG_TAG, "execute() " + httpMethod.getRequestLine().toString());

    DefaultHttpClient httpClient = new DefaultHttpClient();
    V response = null;

    String exceptionMessage = null;
    String cachedResponse = null;

    boolean isResponseCached = data.getBoolean(KEY_USE_CACHE, mUseCacheByDefault);

    String requestUrl = httpMethod.getRequestLine().getUri().toString();

    Logger.l(Logger.DEBUG, LOG_TAG, "# # # # #  useCache? " + isResponseCached);

    if (mResponseCacheInitialized && isResponseCached) {
        httpMethod.getParams().setBooleanParameter("param1", true);
        //Log.d(LOG_TAG, "paramstring: "+paramString);
        cachedResponse = mCacheResponseDbHelper.getResponse(requestUrl, httpMethod.getMethod());
        Logger.l(Logger.DEBUG, LOG_TAG, "# # # # # cached response: " + cachedResponse);
        response = rh.createResponse(cachedResponse);
        response.set(new StringReader(cachedResponse));
    }

    if (cachedResponse == null) {
        try {
            response = httpClient.execute(httpMethod, rh);
        } catch (ClientProtocolException e) {
            e.printStackTrace();
            exceptionMessage = e.getMessage();
            httpMethod.abort();
        } catch (UnknownHostException e) {
            e.printStackTrace();
            exceptionMessage = "not connected to the internet";
            httpMethod.abort();
        } catch (IOException e) {
            e.printStackTrace();
            exceptionMessage = "connection error. please try again.";
            httpMethod.abort();
        }

        // cache the response
        if (exceptionMessage == null && mResponseCacheInitialized && isResponseCached) {
            Logger.l(Logger.DEBUG, LOG_TAG, "# # # # # inserting response to cache: " + response);
            M method = data.getParcelable(XTRA_METHOD);
            BufferedReader br = new BufferedReader(response.get());
            StringBuilder sb = new StringBuilder();
            char[] buffer = new char[51200];
            try {
                while (true) {
                    int bytesRead;
                    bytesRead = br.read(buffer);
                    if (bytesRead == -1) {
                        break;
                    }
                    sb.append(buffer, 0, bytesRead);
                }
                mCacheResponseDbHelper.insertResponse(requestUrl, sb.toString(),
                        Calendar.getInstance().getTime().getTime(), httpMethod.getMethod(), method.getCallId());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    // process response                  
    //Logger.l(Logger.DEBUG, LOG_TAG, "starting service with action: "+INTENT_PROCESS_RESPONSE);
    Intent processIntent = new Intent();
    processIntent.setAction(INTENT_PROCESS_RESPONSE);
    processIntent.putExtra(XTRA_RESPONSE, response);
    processIntent.putExtra(XTRA_ERROR, exceptionMessage);
    processIntent.putExtra(XTRA_REQUEST, data);
    mContext.startService(processIntent);

    boolean imcallback = data.getBoolean(KEY_IMMEDIATECALLBACK, false);
    if (imcallback) {
        Bundle callbackData = new Bundle();
        callbackData.putBundle(XTRA_REQUEST, data);
        callbackData.putParcelable(XTRA_RESPONSE, response);
        callbackData.putString(XTRA_ERROR, exceptionMessage);
        broadcastCallback(mContext, callbackData,
                generateKey(mContext.getPackageName(), mName, RestfulClient.KEY_CALLBACK_INTENT));
    }

}

From source file:com.grupohqh.carservices.operator.ManipulateCarActivity.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelable("bm", bm);
}

From source file:android.support.v7.preference.PreferenceDialogFragmentCompat.java

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

    outState.putCharSequence(SAVE_STATE_TITLE, mDialogTitle);
    outState.putCharSequence(SAVE_STATE_POSITIVE_TEXT, mPositiveButtonText);
    outState.putCharSequence(SAVE_STATE_NEGATIVE_TEXT, mNegativeButtonText);
    outState.putCharSequence(SAVE_STATE_MESSAGE, mDialogMessage);
    outState.putInt(SAVE_STATE_LAYOUT, mDialogLayoutRes);
    if (mDialogIcon != null) {
        outState.putParcelable(SAVE_STATE_ICON, mDialogIcon.getBitmap());
    }//ww  w  . j  a  va2  s .c  o m
}

From source file:org.dvbviewer.controller.ui.fragments.ChannelEpg.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelable(Channel.class.getName(), mCHannel);
    outState.putLong(KEY_EPG_DAY, mDateInfo.getEpgDate().getTime());
}

From source file:com.abhijitvalluri.android.fitnotifications.AppChoicesActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putParcelableArrayList(STATE_APP_SELECTIONS, mAppSelections);
    savedInstanceState.putBoolean(STATE_SETUP_COMPLETE, mSetupComplete);
    Parcelable listState = mRecyclerView.getLayoutManager().onSaveInstanceState();
    savedInstanceState.putParcelable(STATE_RECYCLER_VIEW, listState);

    super.onSaveInstanceState(savedInstanceState);
}

From source file:com.android.contacts.detail.ContactDetailLayoutController.java

public void onSaveInstanceState(Bundle outState) {
    outState.putParcelable(KEY_CONTACT_URI, mContactUri);
    outState.putBoolean(KEY_CONTACT_HAS_UPDATES, mContactHasUpdates);
    outState.putInt(KEY_CURRENT_PAGE_INDEX, getCurrentPageIndex());
}

From source file:android.com.example.contactslist.ui.ContactDetailFragment.java

/**
 * When the Fragment is being saved in order to change activity state, save the
 * currently-selected contact.//from   www .  j a  v  a  2  s .c  o  m
 */
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    // Saves the contact Uri
    outState.putParcelable(EXTRA_CONTACT_URI, mContactUri);
}