Example usage for android.os Bundle get

List of usage examples for android.os Bundle get

Introduction

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

Prototype

@Nullable
public Object get(String key) 

Source Link

Document

Returns the entry with the given key as an object.

Usage

From source file:com.achep.acdisplay.iab.utils.IabHelper.java

int getResponseCodeFromBundle(Bundle b) {
    Object o = b.get(RESPONSE_CODE);
    if (o == null) {
        logDebug("Bundle with null response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return (Integer) o;
    else if (o instanceof Long)
        return (int) ((Long) o).longValue();
    else {//ww  w . java 2  s  .  c o m
        logError("Unexpected type for bundle response code.");
        logError(o.getClass().getName());
        throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
    }
}

From source file:com.example.jumpnote.android.jsonrpc.AuthenticatedJsonRpcJavaClient.java

public void blockingAuthenticateAccount(final Account account, final int needAuthAction,
        boolean forceReauthenticate) throws AuthenticationException, OperationCanceledException,
        RequestedUserAuthenticationException, InvalidAuthTokenException {

    String existingToken = mTokenStoreHelper.getToken(account);
    if (!forceReauthenticate && existingToken != null) {
        BasicClientCookie c = new BasicClientCookie("ACSID", existingToken);
        try {/*w  ww.jav a2  s  .c  om*/
            c.setDomain(new URI(Config.SERVER_BASE_URL).getHost());
            mHttpClient.getCookieStore().addCookie(c);
            return;
        } catch (URISyntaxException e) {
        }
    }

    // Get an auth token for this account.
    AccountManager am = AccountManager.get(mContext);
    Bundle authBundle = null;
    String authToken = null;

    // Block on getting the auth token result.
    try {
        authBundle = am.getAuthToken(account, APPENGINE_SERVICE_NAME, needAuthAction == NEED_AUTH_NOTIFICATION,
                null, null).getResult();
    } catch (IOException e) {
        throw new AuthenticationException("IOException while getting auth token.", e);
    } catch (AuthenticatorException e) {
        throw new AuthenticationException("AuthenticatorException while getting auth token.", e);
    }

    if (authBundle.containsKey(AccountManager.KEY_INTENT) && needAuthAction == NEED_AUTH_INTENT) {
        Intent authRequestIntent = (Intent) authBundle.get(AccountManager.KEY_INTENT);
        mContext.startActivity(authRequestIntent);
        throw new RequestedUserAuthenticationException();
    } else if (authBundle.containsKey(AccountManager.KEY_AUTHTOKEN)) {
        authToken = authBundle.getString(AccountManager.KEY_AUTHTOKEN);
    }

    if (authToken == null) {
        throw new AuthenticationException("Retrieved auth token was null.");
    }

    try {
        blockingAuthenticateWithToken(account, authToken);
    } catch (InvalidAuthTokenException e) {
        am.invalidateAuthToken(account.type, authToken);
        throw e;
    }
}

From source file:org.apache.cordova.CordovaWebView.java

/**
 * Get string property for activity.//ww w .ja v a2s .  c o  m
 *
 * @param name
 * @param defaultValue
 * @return
 */
public String getProperty(String name, String defaultValue) {
    Bundle bundle = this.cordova.getActivity().getIntent().getExtras();
    if (bundle == null) {
        return defaultValue;
    }
    Object p = bundle.get(name);
    if (p == null) {
        return defaultValue;
    }
    return p.toString();
}

From source file:com.samsung.android.remindme.jsonrpc.AuthenticatedJsonRpcJavaClient.java

public void blockingAuthenticateAccount(final Account account, final int needAuthAction,
        boolean forceReauthenticate) throws AuthenticationException, OperationCanceledException,
        RequestedUserAuthenticationException, InvalidAuthTokenException {

    String existingToken = mTokenStoreHelper.getToken(account);
    if (!forceReauthenticate && existingToken != null) {
        BasicClientCookie c = new BasicClientCookie("ACSID", existingToken);
        try {//from   w  ww  . ja  va2s .  c  o  m
            c.setDomain(new URI(Config.SERVER_BASE_URL).getHost());
            mHttpClient.getCookieStore().addCookie(c);
            return;
        } catch (URISyntaxException e) {
        }
    }

    // Get an auth token for this account.
    AccountManager am = AccountManager.get(mContext);
    Bundle authBundle = null;
    String authToken = null;

    // Block on getting the auth token result.
    try {
        authBundle = am.getAuthToken(account, APPENGINE_SERVICE_NAME, needAuthAction == NEED_AUTH_NOTIFICATION,
                null, null).getResult();
    } catch (IOException e) {
        throw new AuthenticationException("IOException while getting auth token.", e);
    } catch (AuthenticatorException e) {
        throw new AuthenticationException("AuthenticatorException while getting auth token.", e);
    }

    if (authBundle.containsKey(AccountManager.KEY_INTENT) && needAuthAction == NEED_AUTH_INTENT) {
        Intent authRequestIntent = (Intent) authBundle.get(AccountManager.KEY_INTENT);
        mContext.startActivity(authRequestIntent);
        throw new RequestedUserAuthenticationException();
    } else if (authBundle.containsKey(AccountManager.KEY_AUTHTOKEN)) {
        authToken = authBundle.getString(AccountManager.KEY_AUTHTOKEN);
        System.out.println(authToken);
        System.out.println(AccountManager.KEY_AUTHTOKEN);
    }

    if (authToken == null) {
        throw new AuthenticationException("Retrieved auth token was null.");
    }

    try {
        blockingAuthenticateWithToken(account, authToken);
    } catch (InvalidAuthTokenException e) {
        am.invalidateAuthToken(account.type, authToken);
        throw e;
    }
}

From source file:com.deange.marathonapp.billing.IabHelper.java

int getResponseCodeFromBundle(Bundle b) {
    Object o = b.get(RESPONSE_CODE);
    if (o == null) {
        logDebug("Bundle with null response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;

    } else if (o instanceof Number) {
        return ((Number) o).intValue();

    } else {/*  www .j a va  2s .com*/
        logError("Unexpected type for bundle response code.");
        logError(o.getClass().getName());
        throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
    }
}

From source file:org.anoopam.main.anoopamaudio.AudioListActivity.java

private void processIntent() {

    if (getIntent() != null && getIntent().getExtras() != null) {

        Bundle b = getIntent().getExtras();
        if (b.get(AUDIO_LIST) != null) {
            audioDetails = (ContentValues) b.get(AUDIO_LIST);
        }/*from ww w  . j  a va 2s  .c  o  m*/

        if (b.getString(ALBUM_NAME) != null) {
            currentAlbumName = b.getString(ALBUM_NAME);
        }

    }
}

From source file:com.andersson.minesweeper.util.IabHelper.java

private int getResponseCodeFromBundle(Bundle b) {
    Object o = b.get(RESPONSE_CODE);
    if (o == null) {
        logDebug("Bundle with null response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return ((Integer) o).intValue();
    else if (o instanceof Long)
        return (int) ((Long) o).longValue();
    else {/*from  w w  w  . ja  va  2 s .co  m*/
        logError("Unexpected type for bundle response code.");
        logError(o.getClass().getName());
        throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
    }
}

From source file:com.appolis.receiving.AcReceiveOptionMove.java

@SuppressWarnings("unchecked")
@Override/*from www .  j av  a  2s  .c  om*/
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.move_details_layout);
    languagePrefs = new LanguagePreferences(getApplicationContext());
    scanFlag = GlobalParams.FLAG_ACTIVE;

    Bundle bundle = getIntent().getExtras();
    if (bundle.containsKey(GlobalParams.PARAM_EN_PURCHASE_ORDER_INFOS)) {
        enPurchaseOrderInfo = (EnPurchaseOrderInfo) bundle.get(GlobalParams.PARAM_EN_PURCHASE_ORDER_INFOS);
    }

    if (bundle.containsKey(GlobalParams.PARAM_EN_PURCHASE_ORDER_ITEM_INFOS)) {
        enPurchaseOrderItemInfo = (EnPurchaseOrderItemInfo) bundle
                .get(GlobalParams.PARAM_EN_PURCHASE_ORDER_ITEM_INFOS);
    }

    if (bundle.containsKey(GlobalParams.PARAM_LIST_EN_PURCHASE_ORDER_RECEIPT_INFO)) {
        listReceiptInfos = (ArrayList<EnPurchaseOrderReceiptInfo>) bundle
                .get(GlobalParams.PARAM_LIST_EN_PURCHASE_ORDER_RECEIPT_INFO);
    }

    getMultipleLanguage();

    initLayout();
}

From source file:io.v.android.apps.syncslides.NavigateFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Bundle args;
    if (savedInstanceState != null) {
        args = savedInstanceState;/*from   w  w  w .  ja v a  2 s. c o m*/
    } else {
        args = getArguments();
    }
    mDeckId = args.getString(DECK_ID_KEY);
    mPresentationId = args.getString(PRESENTATION_ID_KEY);
    mLoadingCurrentSlide = -1;
    mCurrentSlideNum = mUserSlideNum = args.getInt(SLIDE_NUM_KEY);
    mRole = (Role) args.get(ROLE_KEY);
    final View rootView = inflater.inflate(R.layout.fragment_navigate, container, false);
    mFabSync = rootView.findViewById(R.id.audience_sync_fab);
    if (((PresentationActivity) getActivity()).getSynced() || mRole != Role.AUDIENCE) {
        mFabSync.setVisibility(View.INVISIBLE);
    } else {
        mFabSync.setVisibility(View.VISIBLE);
    }

    mFabSync.setOnClickListener(new NavigateClickListener() {
        @Override
        public void onClick(View v) {
            super.onClick(v);
            sync();
            mFabSync.setVisibility(View.INVISIBLE);
        }
    });
    View.OnClickListener previousSlideListener = new NavigateClickListener() {
        @Override
        public void onClick(View v) {
            super.onClick(v);
            previousSlide();
        }
    };
    View arrowBack = rootView.findViewById(R.id.arrow_back);
    arrowBack.setOnClickListener(previousSlideListener);
    mPrevThumb = (ImageView) rootView.findViewById(R.id.prev_thumb);
    mPrevThumb.setOnClickListener(previousSlideListener);

    View.OnClickListener nextSlideListener = new NavigateClickListener() {
        @Override
        public void onClick(View v) {
            super.onClick(v);
            nextSlide();
        }
    };
    // Show either the arrowForward or the FAB but not both.
    View arrowForward = rootView.findViewById(R.id.arrow_forward);
    View fabForward = rootView.findViewById(R.id.primary_navigation_fab);
    if (mRole == Role.PRESENTER) {
        arrowForward.setVisibility(View.INVISIBLE);
        fabForward.setOnClickListener(nextSlideListener);
    } else {
        fabForward.setVisibility(View.INVISIBLE);
        arrowForward.setOnClickListener(nextSlideListener);
    }
    mNextThumb = (ImageView) rootView.findViewById(R.id.next_thumb);
    mNextThumb.setOnClickListener(nextSlideListener);
    mQuestions = (ImageView) rootView.findViewById(R.id.questions);
    // TODO(kash): Hide the mQuestions button if mRole == BROWSER.
    mQuestions.setOnClickListener(new NavigateClickListener() {
        @Override
        public void onClick(View v) {
            super.onClick(v);
            questionButton();
        }
    });
    mCurrentSlide = (ImageView) rootView.findViewById(R.id.slide_current_medium);
    mCurrentSlide.setOnClickListener(new NavigateClickListener() {
        @Override
        public void onClick(View v) {
            super.onClick(v);
            if (mRole == Role.AUDIENCE || mRole == Role.BROWSER) {
                ((PresentationActivity) getActivity()).showFullscreenSlide(mUserSlideNum);
            }
        }
    });

    mSlideNumText = (TextView) rootView.findViewById(R.id.slide_num_text);
    mNotes = (EditText) rootView.findViewById(R.id.notes);
    mNotes.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            ((PresentationActivity) getActivity()).getSupportActionBar().show();
            mEditing = hasFocus;
            getActivity().invalidateOptionsMenu();
            unsync();
        }
    });

    // The parent of mNotes needs to be focusable in order to clear focus
    // from mNotes when done editing.  We set the attributes in code rather
    // than in XML because it is too easy to add an extra level of layout
    // in XML and forget to add these attributes.
    ViewGroup parent = (ViewGroup) mNotes.getParent();
    parent.setFocusable(true);
    parent.setClickable(true);
    parent.setFocusableInTouchMode(true);

    View slideListIcon = rootView.findViewById(R.id.slide_list);
    slideListIcon.setOnClickListener(new NavigateClickListener() {
        @Override
        public void onClick(View v) {
            super.onClick(v);
            if (mRole == Role.AUDIENCE) {
                ((PresentationActivity) getActivity()).showSlideList();
            } else {
                getActivity().getSupportFragmentManager().popBackStack();
            }
        }
    });
    mQuestionsNum = (TextView) rootView.findViewById(R.id.questions_num);
    // Start off invisible for everyone.  If there are questions, this
    // will be set to visible in the mDB.getQuestionerList() callback.
    mQuestionsNum.setVisibility(View.INVISIBLE);

    mDB = DB.Singleton.get(getActivity().getApplicationContext());
    mDB.getSlides(mDeckId, new DB.Callback<List<Slide>>() {
        @Override
        public void done(List<Slide> slides) {
            mSlides = slides;
            // The CurrentSlideListener could have been notified while we were waiting for
            // the slides to load.
            if (mLoadingCurrentSlide != -1) {
                currentSlideChanged(mLoadingCurrentSlide);
            }
            updateView();
        }
    });
    if (((PresentationActivity) getActivity()).getSynced()) {
        sync();
    } else {
        unsync();
    }

    return rootView;
}

From source file:com.kyleshaver.minuteofangle.util.IabHelper.java

int getResponseCodeFromBundle(Bundle b) {
        Object o = b.get(RESPONSE_CODE);
        if (o == null) {
            logDebug("Bundle with null response code, assuming OK (known issue)");
            return BILLING_RESPONSE_RESULT_OK;
        } else if (o instanceof Integer)
            return ((Integer) o).intValue();
        else if (o instanceof Long)
            return (int) ((Long) o).longValue();
        else {/*ww w . jav a2 s.c  om*/
            logError("Unexpected type for bundle response code.");
            logError(o.getClass().getName());
            throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
        }
    }