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

@Nullable
public String getString(@Nullable String key) 

Source Link

Document

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

Usage

From source file:com.mncomunity1.gcm.MyGcmPushReceiver.java

/**
 * Called when message is received./*from w w  w. j  a  v  a 2s  .c  om*/
 *
 * @param from   SenderID of the sender.
 * @param bundle Data bundle containing message data as key/value pairs.
 *               For Set of keys use data.keySet().
 */

@Override
public void onMessageReceived(String from, Bundle bundle) {
    String title = bundle.getString("title");
    Boolean isBackground = Boolean.valueOf(bundle.getString("is_background"));
    String flag = bundle.getString("flag");
    String data = bundle.getString("data");
    Log.d(TAG, "From: " + from);
    Log.d(TAG, "title: " + title);
    Log.d(TAG, "isBackground: " + isBackground);
    Log.d(TAG, "flag: " + flag);
    Log.d(TAG, "data: " + data);

    if (flag == null)
        return;

    if (IsmartApp.getInstance().getPrefManager().getUser() == null) {
        // user is not logged in, skipping push notification
        Log.e(TAG, "user is not logged in, skipping push notification");
        return;
    }

    if (from.startsWith("/topics/")) {
        // message received from some topic.
    } else {
        // normal downstream message.
    }

    switch (Integer.parseInt(flag)) {
    case Config.PUSH_TYPE_CHATROOM:
        // push notification belongs to a chat room
        processChatRoomPush(title, isBackground, data);
        break;
    case Config.PUSH_TYPE_USER:
        // push notification is specific to user
        processUserMessage(title, isBackground, data);
        break;
    }
}

From source file:net.idlesoft.android.apps.github.activities.BranchTree.java

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.branch_tree_list);

    mPrefs = getSharedPreferences(Hubroid.PREFS_NAME, 0);

    mUsername = mPrefs.getString("username", "");
    mPassword = mPrefs.getString("password", "");

    mGapi.authenticate(mUsername, mPassword);

    ((ImageButton) findViewById(R.id.btn_search)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            startActivity(new Intent(BranchTree.this, Search.class));
        }//from  w  w  w . j  ava  2s .co  m
    });

    final TextView pageTitle = (TextView) findViewById(R.id.tv_page_title);
    pageTitle.setText("Tree Browser");

    mListView = (ListView) findViewById(R.id.lv_branchTreeList_list);
    mListView.setOnItemClickListener(mOnListItemClick);

    mAdapter = new BranchTreeListAdapter(BranchTree.this, mListView);

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mRepositoryName = extras.getString("repo_name");
        mRepositoryOwner = extras.getString("repo_owner");
        mBranchName = extras.getString("branch_name");
        mBranchSha = extras.getString("branch_sha");
    }
}

From source file:com.ymt.demo1.plates.news.FileNoticeFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle bundle = getArguments();
    news_type_id = bundle.getString("news_type_id");
    mQueue = Volley.newRequestQueue(getActivity());
    startPosition = 1;/*from   www  .j ava 2s .com*/
    mQueue.add(summaryRequest(state, start, pagesize));

}

From source file:de.appplant.cordova.plugin.localnotification.Receiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Options options = null;/*  ww  w  .  j a v  a 2  s.  c o m*/
    Bundle bundle = intent.getExtras();
    JSONObject args;

    try {
        args = new JSONObject(bundle.getString(OPTIONS));
        options = new Options(context).parse(args);
    } catch (JSONException e) {
        return;
    }

    this.context = context;
    this.options = options;

    // The context may got lost if the app was not running before
    LocalNotification.setContext(context);

    fireTriggerEvent();

    if (options.getInterval() == 0) {
        LocalNotification.unpersist(options.getId());
    } else if (isFirstAlarmInFuture()) {
        return;
    } else {
        LocalNotification.add(options.moveDate(), false);
    }

    Builder notification = buildNotification();

    showNotification(notification);
}

From source file:com.android.prachat.gcm.MyGcmPushReceiver.java

/**
 * Called when message is received./* www  . jav a2 s .  c  o  m*/
 *
 * @param from   SenderID of the sender.
 * @param bundle Data bundle containing message data as key/value pairs.
 *               For Set of keys use data.keySet().
 */

@Override
public void onMessageReceived(String from, Bundle bundle) {
    String title = bundle.getString("title");
    Boolean isBackground = Boolean.valueOf(bundle.getString("is_background"));
    String flag = bundle.getString("flag");
    String data = bundle.getString("data");
    Log.d(TAG, "From: " + from);
    Log.d(TAG, "title: " + title);
    Log.d(TAG, "isBackground: " + isBackground);
    Log.d(TAG, "flag: " + flag);
    Log.d(TAG, "data: " + data);

    if (flag == null)
        return;

    if (MyApplication.getInstance().getPrefManager().getUser() == null) {
        // user is not logged in, skipping push notification
        Log.e(TAG, "user is not logged in, skipping push notification");
        return;
    }

    if (from.startsWith("/topics/")) {
        // message received from some topic.
    } else {
        // normal downstream message.
    }

    switch (Integer.parseInt(flag)) {
    case Config.PUSH_TYPE_CHATROOM:
        // push notification belongs to a chat room
        processChatRoomPush(title, isBackground, data);
        break;
    case Config.PUSH_TYPE_USER:
        // push notification is specific to user
        processUserMessage(title, isBackground, data);
        break;
    }
}

From source file:com.memetro.android.register.CredentialsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_register_credentials);
    context = getApplicationContext();//ww w .  ja v  a  2  s  . c  o m
    OAuth = new OAuth(context);

    pdialog = new MemetroProgress(this);

    register = (Button) findViewById(R.id.register);
    usernameEt = (EditText) findViewById(R.id.username);
    passwordEt = (EditText) findViewById(R.id.password);
    repeatPasswordEt = (EditText) findViewById(R.id.repeat_password);
    spinnerCity = (Spinner) findViewById(R.id.spinnerCity);
    spinnerCountry = (Spinner) findViewById(R.id.spinnerCountry);

    List<Country> countries = DataUtils.getCountries();
    LayoutUtils.setDefaultSpinnerGrey(context, spinnerCountry, countries);

    spinnerCountry.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            Country country = (Country) adapterView.getAdapter().getItem(i);
            Log.d("PAIS", country.name);
            List<City> cities = DataUtils.getCities(country.countryId);
            LayoutUtils.setDefaultSpinnerGrey(context, spinnerCity, cities);
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        name = extras.getString("name");
        mail = extras.getString("mail");
        twitter = extras.getString("twitter");
        about = extras.getString("about");
    }

    register.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            username = usernameEt.getText().toString();
            password = passwordEt.getText().toString();
            repeatPassword = repeatPasswordEt.getText().toString();
            new AsyncRegister().execute();
        }
    });

}

From source file:de.badaix.snapcast.GroupSettingsFragment.java

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

    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.group_preferences);
    PreferenceScreen screen = this.getPreferenceScreen();

    prefStreams = (ListPreference) findPreference("pref_stream");

    Bundle bundle = getArguments();
    try {//from   w ww . j  av a2  s  . c  om
        group = new Group(new JSONObject(bundle.getString("group")));
        serverStatus = new ServerStatus(new JSONObject(bundle.getString("serverStatus")));
    } catch (JSONException e) {
        e.printStackTrace();
    }

    final ArrayList<Stream> streams = serverStatus.getStreams();
    final CharSequence[] streamNames = new CharSequence[streams.size()];
    final CharSequence[] streamIds = new CharSequence[streams.size()];
    for (int i = 0; i < streams.size(); ++i) {
        streamNames[i] = streams.get(i).getName();
        streamIds[i] = streams.get(i).getId();
    }

    prefStreams.setEntries(streamNames);
    prefStreams.setEntryValues(streamIds);

    for (int i = 0; i < streams.size(); ++i) {
        if (streamIds[i].equals(group.getStreamId())) {
            prefStreams.setTitle(streamNames[i]);
            prefStreams.setValueIndex(i);
            oldStream = prefStreams.getValue();
            break;
        }
    }

    prefStreams.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            for (int i = 0; i < streams.size(); ++i) {
                if (streamIds[i].equals(newValue)) {
                    prefStreams.setTitle(streamNames[i]);
                    //                        client.getConfig().setStream(streamIds[i].toString());
                    prefStreams.setValueIndex(i);
                    break;
                }
            }

            return false;
        }
    });

    prefCatClients = (PreferenceCategory) findPreference("pref_cat_clients");
    ArrayList<CheckBoxPreference> allClients = new ArrayList<>();
    for (Group g : serverStatus.getGroups()) {
        for (Client client : g.getClients()) {
            CheckBoxPreference checkBoxPref = new CheckBoxPreference(screen.getContext());
            checkBoxPref.setKey(client.getId());
            checkBoxPref.setTitle(client.getVisibleName());
            checkBoxPref.setChecked(g.getId().equals(group.getId()));
            checkBoxPref.setPersistent(false);
            allClients.add(checkBoxPref);
        }
    }
    Collections.sort(allClients, new Comparator<CheckBoxPreference>() {
        @Override
        public int compare(CheckBoxPreference lhs, CheckBoxPreference rhs) {
            return lhs.getTitle().toString().compareToIgnoreCase(rhs.getTitle().toString());
        }
    });
    for (CheckBoxPreference pref : allClients)
        prefCatClients.addPreference(pref);

    oldClients = getClients().toString();
}

From source file:net.idlesoft.android.apps.github.activities.DiffFilesList.java

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.diff_file_list);

    mPrefs = getSharedPreferences(Hubroid.PREFS_NAME, 0);

    mUsername = mPrefs.getString("username", "");
    mPassword = mPrefs.getString("password", "");

    mGapi.authenticate(mUsername, mPassword);

    ((ImageButton) findViewById(R.id.btn_search)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            startActivity(new Intent(DiffFilesList.this, Search.class));
        }/* ww w  .j a va2 s  .  co m*/
    });

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mRepositoryName = extras.getString("repo_name");
        mRepositoryOwner = extras.getString("repo_owner");
        mType = extras.getString("type");
        try {
            mJson = new JSONObject(extras.getString("json"));
        } catch (final JSONException e) {
            e.printStackTrace();
        }

        try {
            final TextView title = (TextView) findViewById(R.id.tv_page_title);
            if (mType.equals("added")) {
                title.setText("Added Files");
            } else if (mType.equals("removed")) {
                title.setText("Removed Files");
            } else if (mType.equals("modified")) {
                title.setText("Changed Files");
            } else {
                title.setText("Files");
            }

            /*
             * Split JSONArray into a String array so we can populate the
             * list of files
             */
            final String[] filenames = new String[mJson.getJSONArray(mType).length()];
            for (int i = 0; i < filenames.length; i++) {
                if (mType.equals("modified")) {
                    filenames[i] = mJson.getJSONArray("modified").getJSONObject(i).getString("filename");
                } else {
                    filenames[i] = mJson.getJSONArray(mType).getString(i);
                }
                if (filenames[i].lastIndexOf("/") > -1) {
                    filenames[i] = filenames[i].substring(filenames[i].lastIndexOf("/") + 1);
                }
            }

            mAdapter = new ArrayAdapter<String>(DiffFilesList.this, android.R.layout.simple_list_item_1,
                    android.R.id.text1, filenames);

            final ListView file_list = (ListView) findViewById(R.id.lv_diffFileList_list);
            file_list.setAdapter(mAdapter);
            file_list.setOnItemClickListener(mOnFileListItemClick);
        } catch (final JSONException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.citrus.sdk.fragments.CreditCard.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    returnView = inflater.inflate(R.layout.activity_credit_card, container, false);

    Bundle data = getArguments();

    paymentType = data.getString(Constants.PAY_TYPE);
    initEditText();//ww  w.  ja v a2  s  . c  om

    initSubmitButton();

    return returnView;
}

From source file:jp.alessandro.android.iab.PurchaseGetter.java

/**
 * To retrieve information about purchases made by a user from your app,
 * call the getPurchases method on the In-app Billing Version 3 service.
 * Pass in to the method the In-app Billing API version ("3"), the package name of your calling app,
 * and the purchase type ("inapp" or "subs").
 * See https://developer.android.com/google/play/billing/billing_integrate.html#QueryPurchases
 *
 * @param service  in-app billing service
 * @param itemType "inapp" or "subs"//from   ww w. j  av  a2  s. c om
 * @return
 * @throws BillingException
 */
public Purchases get(IInAppBillingService service, String itemType) throws BillingException {
    Purchases purchases = new Purchases();
    String continueToken = null;
    do {
        Bundle bundle = getPurchasesBundle(service, itemType, continueToken);
        checkResponseAndAddPurchases(bundle, purchases);
        continueToken = bundle.getString(Constants.RESPONSE_INAPP_CONTINUATION_TOKEN);
    } while (!TextUtils.isEmpty(continueToken));
    return purchases;
}