Example usage for android.os Bundle getString

List of usage examples for android.os Bundle getString

Introduction

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

Prototype

public String getString(@Nullable String key, String defaultValue) 

Source Link

Document

Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key or if a null value is explicitly associated with the given key.

Usage

From source file:Main.java

private static String getString(final Bundle bundle, final String key) {
    if (bundle != null) {
        return bundle.getString(key, null);
    }//from   www  .j a  va2 s . c o m

    return null;
}

From source file:fragments.NewTicket.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case COLOR_PICKER:

        if (resultCode == Activity.RESULT_OK) {
            Bundle bundle = data.getExtras();
            String color = bundle.getString("color", "");
            ticketColor.setText(color);/*  w w w  .j av  a  2 s . com*/

        } else if (resultCode == Activity.RESULT_CANCELED) {
            ticketColor.setText("");
        }
        break;
    }
}

From source file:am.roadpolice.roadpolice.DecisionDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View decisionView = getActivity().getLayoutInflater().inflate(R.layout.dialog_watcher, null);
    // Get Web View and Progress Bar.
    mWebView = (WebView) decisionView.findViewById(R.id.webView);
    mProgressBar = (ProgressBar) decisionView.findViewById(R.id.progressBar);

    Bundle bundle = getArguments();
    final DecisionDownloader d = new DecisionDownloader(bundle.getString(ActionDialogFragment.EXTRA_PIN, ""));
    d.execute();//from   w ww  .ja  v a  2  s. c  o  m

    return new AlertDialog.Builder(getActivity())
            .setNeutralButton(R.string.txtClose, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    d.cancel(true);
                }
            }).setView(decisionView).create();
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.activities.LevelOneActivity.java

private void setupVideoFragment() {
    final Intent intent = getIntent();
    final Bundle bundle = intent.getBundleExtra(EXTRA);
    Validate.notNull(bundle, "The bundle supplied to the activity is null.");
    final String fragmentToShow = bundle.getString(FRAGMENT_TO_SHOW, StringUtils.EMPTY);
    if (SignVideoFragment.class.getSimpleName().equals(fragmentToShow)) {
        final Parcelable sign = bundle.getParcelable(SignVideoFragment.SIGN_TO_SHOW);
        SignVideoFragment signVideoFragment = new SignVideoFragment();
        final Bundle args = new Bundle();
        args.putParcelable(SignVideoFragment.SIGN_TO_SHOW, sign);
        signVideoFragment.setArguments(args);
        setFragment(signVideoFragment, SIGN_VIDEO_TAG);
    } else {// w w  w  .j  a  v  a2s  .  c om
        throw new IllegalArgumentException("Cannot show the fragment with name: " + fragmentToShow);
    }
}

From source file:com.liferay.mobile.push.util.GoogleServices.java

public JSONObject getPushNotification(Context context, Intent intent) throws PushNotificationReceiverException {

    String messageType = getMessageType(context, intent);

    if (!GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
        throw new PushNotificationReceiverException("Unknown message type" + messageType);
    }//from   ww w . j a v a  2  s .  c  o m

    Bundle extras = intent.getExtras();

    if ((extras == null) || extras.isEmpty()) {
        throw new PushNotificationReceiverException("Push notification body is empty.");
    }

    String payload = extras.getString("payload", null);

    if (payload == null) {
        throw new PushNotificationReceiverException("Push notification without payload.");
    }

    try {
        JSONObject pushNotification = new JSONObject(payload);

        return pushNotification;
    } catch (JSONException je) {
        throw new PushNotificationReceiverException(je);
    }
}

From source file:net.oremland.rss.reader.fragments.BaseListFragment.java

private TreeMap<String, TModel> getSavedModels(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        String s = savedInstanceState.getString(MODELS_KEY, "");
        if (!TextUtils.isEmpty(s)) {
            return ObjectSerializer.fromString(s);
        }/*from w w w .ja v a2s  .c  o m*/
    }
    return this.models;
}

From source file:com.fastbootmobile.twofactorauthdemo.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.info_layout);

    Button regButton = (Button) findViewById(R.id.register);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        if (extras.getString("otp", null) != null) {
            TextView txt = (TextView) findViewById(R.id.txt);
            regButton.setVisibility(View.GONE);
            txt.setText("One Time Password :  " + extras.getString("otp", null));
            return;
        }//from  w  w  w  . j  a v a  2  s.  co m
    }

    mReg = new OwnPushRegistrant(this);
    mHandler = new Handler();
    receiver = new RegisterReceiver(new Handler());

    IntentFilter filter = new IntentFilter(OwnPushClient.INTENT_REGISTER);
    filter.addCategory(BuildConfig.APP_PUBLIC_KEY);

    registerReceiver(receiver, filter);

    final SharedPreferences prefs = this.getApplicationContext().getSharedPreferences(OwnPushClient.PREF_PUSH,
            Context.MODE_PRIVATE);

    if (!prefs.getBoolean(OwnPushClient.PREF_REG_DONE, false)) {

        regButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                OwnPushCrypto fp = new OwnPushCrypto();
                OwnPushCrypto.AppKeyPair keys = fp.generateInstallKey();

                boolean ret = mReg.register(BuildConfig.APP_PUBLIC_KEY, keys.getPublicKey());

                if (ret) {
                    //STORE THEM
                    prefs.edit().putString(OwnPushClient.PREF_PUBLIC_KEY, keys.getPublicKey()).commit();
                    prefs.edit().putString(OwnPushClient.PREF_PRIVATE_KEY, keys.getPrivateKey()).commit();
                }
            }
        });
    } else {
        regButton.setVisibility(View.GONE);

        updateUI();

        if (prefs.getString("device_uid", null) == null) {
            registerWithBackend();
        }
    }

}

From source file:com.achie.tv.ContestantImageGrid.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;

    mImageManager = ImageManager.getInstance(mContext);
    try {//from  w  ww .j  a v a  2s  .  c  o  m
        handleIntent(getIntent());
    } catch (final IOException e) {
        e.printStackTrace();
    } catch (final URISyntaxException e) {
        e.printStackTrace();
    } catch (final JSONException e) {
        e.printStackTrace();
    }

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        String tvShowString = extras.getString("show", "");
        Log.v(tag, "show string " + tvShowString);
        query = tvShowString;
    }

    if (!isSplashShown) {
        setContentView(R.layout.splash_screen_c);
        isSplashShown = true;
        CountDownTimer timer = new CountDownTimer(3000, 1000) {
            public void onTick(long millisUntilFinished) {
            }

            public void onFinish() {
                initGridView();
            }
        }.start();
    } else {
        initGridView();
    }
}