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.cbtec.eliademy.GCMIntentService.java

@Override
protected void onMessage(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    Log.d(TAG, "Received message" + extras.toString());
    if (extras != null) {
        try {/*from  w  ww. java  2  s. c om*/
            JSONObject json;
            json = new JSONObject().put("event", "notifications");
            json.put("notifications", extras.getString("notifications"));

            Log.v(TAG, json.toString());
            if (GCMPlugin.isActive()) {
                // TODO: Find better way
                JSONObject msgobj = new JSONObject(extras.getString("notifications"));
                String msg = msgobj.getString("author") + " " + msgobj.getString("content") + " for course "
                        + msgobj.getString("coursename");
                generateNotification(context, msg);
                GCMPlugin.sendJavascript(json);
            } else {
                // form message
                JSONObject msgobj = new JSONObject(extras.getString("notifications"));
                String msg = msgobj.getString("author") + " " + msgobj.getString("content") + " for course "
                        + msgobj.getString("coursename");
                generateNotification(context, msg);
            }
        } catch (JSONException e) {
            Log.e(TAG, "JSON exception" + e.getMessage());
        }
    }
}

From source file:com.arantius.tivocommander.Person.java

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

    Bundle bundle = getIntent().getExtras();
    if (bundle == null) {
        Utils.log("Person: null bundle!");
        finish();//from  w ww. j  a  va  2 s.c om
        return;
    }
    MindRpc.init(this, bundle);

    mName = bundle.getString("fName");
    if (bundle.getString("lName") != null) {
        mName += " " + bundle.getString("lName");
    }
    mPersonId = bundle.getString("personId");
    Utils.log(String.format("Person: " + "name:%s personId:%s", mName, mPersonId));

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.list);

    MindRpc.addRequest(new PersonSearch(mPersonId), mPersonListener);
    mOutstandingRequests++;
    MindRpc.addRequest(new PersonCreditsSearch(mPersonId), mPersonCreditsListener);
    mOutstandingRequests++;

    setProgressBarIndeterminateVisibility(true);
}

From source file:com.onesignal.OneSignal.java

static boolean isValidAndNotDuplicated(Context context, Bundle bundle) {
    if (bundle.isEmpty())
        return false;

    try {/*from w  w w. j  ava 2s.c o m*/
        if (bundle.containsKey("custom")) {
            JSONObject customJSON = new JSONObject(bundle.getString("custom"));

            if (customJSON.has("i"))
                return !OneSignal.isDuplicateNotification(customJSON.getString("i"), context);
            else
                Log(LOG_LEVEL.DEBUG, "Not a OneSignal formatted GCM message. No 'i' field in custom.");
        } else
            Log(LOG_LEVEL.DEBUG, "Not a OneSignal formatted GCM message. No 'custom' field in the bundle.");
    } catch (Throwable t) {
        Log(LOG_LEVEL.DEBUG, "Could not parse bundle for duplicate, probably not a OneSignal notification.", t);
    }

    return false;
}

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

@Override
public void onRestoreInstanceState(final Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    boolean keepGoing = true;
    try {/*from ww  w . ja va 2 s  .  c  o m*/
        if (savedInstanceState.containsKey("json")) {
            mJson = new JSONArray(savedInstanceState.getString("json"));
        } else {
            keepGoing = false;
        }
    } catch (final JSONException e) {
        keepGoing = false;
    }

    if (keepGoing == true) {
        mActivityAdapter.loadData(mJson);
        mActivityAdapter.pushData();
    }
}

From source file:com.mercandalli.android.apps.files.file.text.FileTextActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_file_text);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);//from ww  w .  ja  v a 2s. c o  m
        final ActionBar supportActionBar = getSupportActionBar();
        if (supportActionBar != null) {
            supportActionBar.setDisplayHomeAsUpEnabled(true);
        }
    }

    mEditText = (EditText) findViewById(R.id.txt);
    mProgressBar = (ProgressBar) findViewById(R.id.circularProgressBar);

    // Visibility
    mEditText.setVisibility(View.GONE);
    mProgressBar.setVisibility(View.VISIBLE);

    final Bundle extras = getIntent().getExtras();
    if (extras == null) {
        finish();
        overridePendingTransition(R.anim.right_in, R.anim.right_out);
        return;
    }
    if (extras.containsKey(EXTRA_MODEL_FILE_ARTICLE_CONTENT_1)) {
        mInitialText = extras.getString(EXTRA_MODEL_FILE_ARTICLE_CONTENT_1);
        mEditText.setText(mInitialText);
        mEditText.setVisibility(View.VISIBLE);
        mProgressBar.setVisibility(View.GONE);
    } else {
        mUrl = extras.getString(EXTRA_MODEL_FILE_URL);
        mIsOnline = extras.getBoolean(EXTRA_MODEL_FILE_ONLINE);

        if (savedInstanceState == null) {
            new TaskGet(this, this.mUrl, this).execute();
        } else {
            mProgressBar.setVisibility(View.GONE);
        }
    }
}

From source file:com.best.ui.Otpdescdetail.java

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

    if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT)
        TransitionEffect.callOverridePendingTransition(this);

    me = this;/*from  ww  w  .  ja v a2 s.c o  m*/
    m_context = this;
    me.setContentView(com.best.ui.R.layout.routing);
    mInflater = LayoutInflater.from(m_context);

    Bundle bundle = getIntent().getExtras();

    String DESCRIP = bundle.getString("routeName"); //my description string.
    routeNames = DESCRIP.split(",");
    System.out.println("CPlan.plan.size() " + CPlan.plan.size());
    System.out.println("CPlan.plan.get(0).legs.size()" + CPlan.plan.get(0).legs.size());
    System.out.println("CPlan.plan.get(1).legs.size()" + CPlan.plan.get(1).legs.size());
    System.out.println("routeNames.length" + routeNames.length);
    position = bundle.getInt("position"); //CPlan.plan.get(position).legs.get(0).v2.size()
    System.out.println("position " + position); //legs.get(CPlan.i).v2.size()
    System.out.println(" CPlan.plan.size() " + CPlan.plan.size());

    ItineraryObject = CPlan.ItineraryListJsonObject.get(position);
    ItineraryJsonObject = (JSONObject) ItineraryObject;//legs.get(CPlan.i).v2.size()

    ctrip = CPlan.plan.get(position);
    System.out.println("CTrip.legs.size()*  " + ctrip.legs.size());

    legStartTime = new String[routeNames.length];
    legFrom_name = new String[routeNames.length];
    legEndTime = new String[routeNames.length];
    legto_name = new String[routeNames.length]; //no of legs
    for (int j = 0; j < routeNames.length; j++) {
        System.out.println("j " + j);

        legStartTime[j] = ctrip.legs.get(j).legStartTimeObject;//legStartTimeObject

        legFrom_name[j] = ctrip.legs.get(j).From_name.toString(); //From_name

        legEndTime[j] = ctrip.legs.get(j).legEndTime; //legEndTime

        legto_name[j] = ctrip.legs.get(j).To_name.toString();
    }
    System.out.println("busHead.length " + legStartTime.length);
    System.out.println("totalDist.length " + legFrom_name.length);
    System.out.println("busFreq.length " + legto_name.length);
    System.out.println("no_Stops.length " + legEndTime.length);

    init(this);
}

From source file:com.ntsync.android.sync.activities.CreatePwdProgressDialog.java

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

    AccountManager accountManager = AccountManager.get(getActivity());
    Bundle args = getArguments();
    String mUsername = args.getString(KeyPasswordActivity.PARAM_USERNAME);
    byte[] pwdSalt = args.getByteArray(KeyPasswordActivity.PARAM_SALT);
    Account account = new Account(mUsername, Constants.ACCOUNT_TYPE);

    String pwd = args.getString(PARAM_PWD);
    byte[] pwdCheck = args.getByteArray(KeyPasswordActivity.PARAM_CHECK);

    // Retain to keep Task during conf changes
    setRetainInstance(true);//from   w w  w .j  a  v  a  2  s  . c o  m
    setCancelable(false);

    if (pwd == null) {
        createTask = new CreatePwdTask(account, accountManager, pwdSalt);
    } else {
        createTask = new RecreateKeyTask(account, accountManager, pwdSalt, pwdCheck, pwd);
    }
    createTask.execute();
}

From source file:com.att.android.arodatacollector.activities.AROCollectorHomeActivity.java

/**
 * Initializes data members with a saved instance of an AROCollectorHomeActivity object. 
 * Overrides the android.app.Activity#onCreate method. 
 * @param savedInstanceState  A saved instance of an AROCollectorHomeActivity object.
 * @see android.app.Activity#onCreate(android.os.Bundle)
 */// w w w.ja  v  a 2  s.  c  o m
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    AROLogger.d(TAG, "inside onCreate");

    mApp = (ARODataCollector) getApplication();
    //mAroUtils = new AROCollectorUtils();
    setContentView(R.layout.arocollector_home_screen);
    initHomeScreenControls();
    initHomeScreenControlListeners();

    //All code until end of the method is used to maintain the on screen timer.
    stopWatch = (Chronometer) findViewById(R.id.chrono);
    stopWatch.setBase(mApp.getElapsedTimeStartTime());

    timerText = (TextView) findViewById(R.id.timer);

    stopWatch.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
        @Override
        public void onChronometerTick(Chronometer arg0) {
            countUp = (System.currentTimeMillis() - arg0.getBase()) / 1000;
            String asText;
            String minPlace = "";
            String secPlace = "";

            if (((countUp / 60) % 60) < 10) {
                minPlace = "0";
            }
            if (countUp % 60 < 10) {
                secPlace = "0";
            }
            //Display the time in standard "Hours:Minutes:Seconds" | "00:00:00"
            asText = "0" + (countUp / 3600) + ":" + minPlace + ((countUp / 60) % 60) + ":" + secPlace
                    + (countUp % 60);
            timerText.setText(getText(R.string.aro_traceTimer) + " " + asText);
        }
    });
    stopWatch.start();

    final Bundle apkCommandLineParameters = getIntent().getExtras();
    if (apkCommandLineParameters != null) {
        String mAROStopRequestFromAnalyzer = apkCommandLineParameters.getString("StopCollector");
        if (mAROStopRequestFromAnalyzer != null) {
            stopARODataCollector();
        }
    }

    registerAnalyzerCloseCmdReceiver();
}