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:cn.count.easydrive366.CarRegistrationActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 0 && resultCode == RESULT_OK) {
        Bundle extras = data.getExtras();
        try {/*from   w w w. j a va  2 s . c  o  m*/
            this.processMessage(1, new JSONObject(extras.getString("result")));
        } catch (JSONException e) {

            e.printStackTrace();
        }
    }
}

From source file:it.uniroma2.foundme.studente.CourseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_course);

    context = this;

    course = (TextView) findViewById(R.id.tvNameCoures);
    prof = (TextView) findViewById(R.id.tvNameProf);
    ass1 = (TextView) findViewById(R.id.tvNameAss1);
    ass2 = (TextView) findViewById(R.id.tvNameAss2);
    msg = (Button) findViewById(R.id.btnMsg);

    notifica = (Switch) findViewById(R.id.switch_notif);

    imgUniroma2 = (ImageButton) findViewById(R.id.imageButton);

    Bundle passed = getIntent().getExtras();
    Data = passed.getString(Variables_it.COURSE);
    extractData(Data);//from   ww w  . ja va  2  s .  c o m

    pref = SPEditor.init(CourseActivity.this.getApplicationContext());
    Sid = SPEditor.getID(pref);

    try {
        manageInfo(Title, Prof, Sid);
    } catch (ExecutionException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    imgUniroma2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Variables_it.SITE_TV));
            startActivity(browserIntent);
        }
    });

    msg.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            Intent i = new Intent(CourseActivity.this, ReadMessageActivity.class);
            i.putExtra(Variables_it.COURSE, Title);
            i.putExtra(Variables_it.ID, Sid);
            startActivity(i);
        }
    });
}

From source file:com.chess.genesis.activity.RegisterFrag.java

@Override
public boolean handleMessage(final Message msg) {
    switch (msg.what) {
    case NetworkClient.REGISTER:
        final JSONObject json = (JSONObject) msg.obj;

        try {//w ww.  j av  a 2  s. c  o  m
            if (json.getString("result").equals("error")) {
                progress.remove();
                Toast.makeText(act, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show();
                return true;
            }
            progress.setText("Registration Successfull");
            new RegisterActivation(act, handle).show();
        } catch (final JSONException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
        break;
    case RegisterConfirm.MSG:
        progress.setText("Sending Registration");
        final Bundle data = (Bundle) msg.obj;

        net.register(data.getString("username"), data.getString("password"), data.getString("email"));
        new Thread(net).start();
        break;
    case RegisterActivation.MSG:
        if (isTablet)
            getFragmentManager().popBackStack();
        else
            act.finish();
        break;
    }
    return true;
}

From source file:com.google.appinventor.components.runtime.util.ClientLoginHelper.java

/**
 * Uses Google Account Manager to retrieve auth token that can
 * be used to access various Google APIs -- e.g., the Google Voice api.
 *//*from  w  w w . j a v  a  2s  . c  om*/
public String getAuthToken() throws ClientProtocolException {
    Account account = accountChooser.findAccount();
    if (account != null) {
        AccountManagerFuture<Bundle> future;
        future = accountManager.getAuthToken(account, service, null, activity, null, null);
        Log.i(LOG_TAG, "Have account, auth token: " + future);
        Bundle result;
        try {
            result = future.getResult();
            return result.getString(AccountManager.KEY_AUTHTOKEN);
        } catch (AuthenticatorException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (OperationCanceledException e) {
            e.printStackTrace();
        }
    }
    throw new ClientProtocolException("Can't get valid authentication token");
}

From source file:com.bellman.bible.android.view.activity.search.SearchResults.java

/**
 * do the search query and prepare results in lists ready for display
 *//*from  w  w w . j a v a 2  s  .co  m*/
private boolean fetchSearchResults() {
    Log.d(TAG, "Preparing search results");
    boolean isOk = false;

    try {
        // get search string - passed in using extras so extras cannot be null
        Bundle extras = getIntent().getExtras();
        String searchText = extras.getString(SearchControl.SEARCH_TEXT);
        String searchDocument = extras.getString(SearchControl.SEARCH_DOCUMENT);
        if (StringUtils.isEmpty(searchDocument)) {
            searchDocument = ControlFactory.getInstance().getCurrentPageControl().getCurrentPage()
                    .getCurrentDocument().getInitials();
        }
        mSearchResultsHolder = searchControl.getSearchResults(searchDocument, searchText);

        // tell user how many results were returned
        String msg;
        if (mCurrentlyDisplayedSearchResults.size() >= SearchControl.MAX_SEARCH_RESULTS) {
            msg = getString(R.string.search_showing_first, SearchControl.MAX_SEARCH_RESULTS);
        } else {
            msg = getString(R.string.search_result_count, mSearchResultsHolder.size());
        }
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
        isOk = true;
    } catch (Exception e) {
        Log.e(TAG, "Error processing search query", e);
        isOk = false;
        Dialogs.getInstance().showErrorMsg(R.string.error_executing_search, new Callback() {
            @Override
            public void okay() {
                onBackPressed();
            }
        });
    }
    return isOk;
}

From source file:com.commontime.plugin.notification.notification.AbstractActionClickActivity.java

/**
 * Called when local notification was clicked to launch the main intent.
 *
 * @param state//  w  w w  .j av  a  2s.co  m
 *      Saved instance state
 */
@Override
public void onCreate(Bundle state) {
    super.onCreate(state);

    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();
    Context context = getApplicationContext();

    try {
        JSONObject dataJson = new JSONObject(bundle.getString(Options.EXTRA));
        JSONObject actionDataJson = new JSONObject(bundle.getString(ActionClickActivity.ACTION_PARAM));

        dataJson.put("actionResponseIdentifier", actionDataJson.getString("identifier"));
        dataJson.put("actionResponse", null);

        Builder builder = new Builder(context, dataJson);

        NotificationWrapper notification = buildNotification(builder);

        onActionClick(notification);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:jp.co.ipublishing.esnavi.impl.gcm.GcmIntentService.java

/**
 * ??//from w  w w . j a  v a  2s  . co  m
 *
 * @param extras ?
 */
@Override
protected void onReceivedMessage(Bundle extras) {
    try {
        final String message = extras.getString("message");

        final Alert alert = convertToAlert(message);

        // ?
        sendNotification(alert);

        // 
        EventBus.getDefault().post(new AlertUpdatedAlertEvent(alert));

        mAlertManager.storeAlert(alert).subscribe(new Subscriber<Alert>() {
            @Override
            public void onCompleted() {
                // Nothing to do
            }

            @Override
            public void onError(Throwable e) {
                Log.e(TAG, ExceptionUtils.getStackTrace(e));
            }

            @Override
            public void onNext(Alert alert) {
                // Nothing to do
            }
        });
    } catch (JSONException | ParseException e) {
        Log.e(TAG, ExceptionUtils.getStackTrace(e));
    }
}

From source file:it.uniroma2.foundme.studente.UnFollowCourseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_unfollow_course);
    context = this;
    lvCorsiSeguiti = (ListView) findViewById(R.id.lvCorsiSeguiti);

    swipeUnfollow = (SwipeRefreshLayout) findViewById(R.id.swipe_unfollow);
    swipeUnfollow.setEnabled(false);/*from  w  ww  .  ja  v  a  2  s  . c  o  m*/

    Bundle passed = getIntent().getExtras();
    Sid = passed.getString(Variables_it.ID);

    try {
        getCourse(true);
    } catch (ExecutionException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.search.video.SignSearchVideoActivity.java

@NonNull
private Parcelable getParcelable() {
    final Intent intent = getIntent();
    final Bundle bundle = intent.getBundleExtra(EXTRA);
    Validate.notNull(bundle, "The bundle supplied to the activity is null.");
    this.originalQuery = bundle.getString(SignSearchActivity.QUERY);
    Validate.notNull(this.originalQuery, "Query string supplied to this activity is null.");
    final Parcelable parcelledSign = bundle.getParcelable(SignVideoFragment.SIGN_TO_SHOW);
    Validate.notNull(parcelledSign, "Parcelled sign supplied to this activity is null.");
    return parcelledSign;
}

From source file:com.example.mobileid.GcmIntentService.java

private void sendNotification(Intent intent) {
    mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);

    Bundle extras = intent.getExtras();
    JSONObject gcmObj;/*from   w w w.  j a va2 s . co  m*/
    try {
        gcmObj = new JSONObject(extras.getString("message"));
        String msg = gcmObj.getString("info");

        Intent passIntent = new Intent();
        passIntent.setClass(this, MainActivity.class);
        passIntent.putExtra("gcmMsg", gcmObj.toString());

        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, passIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);

        if (msg.compareToIgnoreCase("websign") != 0) {
            //              NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            mBuilder.setSmallIcon(R.drawable.ic_launcher).setContentTitle("mobileID")
                    .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg);
        } else {
            //            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            mBuilder.setSmallIcon(R.drawable.ic_launcher)
                    .setContentTitle("Web Sign - " + gcmObj.getString("title"))
                    .setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
                    .setContentText(gcmObj.getString("content"));
        }

        //default notification sound
        Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        mBuilder.setSound(alarmSound);

        //cleared after clicking
        mBuilder.setAutoCancel(true);

        mBuilder.setContentIntent(contentIntent);
        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    } catch (Exception e) {
        e.printStackTrace();
    }
}