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.ibm.mil.readyapps.telco.termsconditions.TermsConditionsActivity.java

private void setupUI() {
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        String offerTitleText = (String) extras.get(OFFER_TITLE);
        offerTitle.setText(offerTitleText);

        String offerTerms = (String) extras.get(OFFER_TERMS_CONDITIONS);
        if (offerTerms != null) {
            if (!offerTerms.equals("")) {
                termsText.setText(offerTerms);
            } else {
                setFakeTermsText();/*from  w  w w.j  av a 2s  .  c  om*/
            }
        } else {
            setFakeTermsText();
        }
    }
}

From source file:com.kklop.ghostmode.HighScore.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.highscore);/*from   www .j a va2s  .c  om*/
    Bundle extras = this.getIntent().getExtras();

    if (extras != null) {
        score = (Integer) extras.get("score");
        extras.remove("score");
        //Toast toast = Toast.makeText(getApplicationContext(), getString(R.string.score_info).concat(Integer.toString(score)), Toast.LENGTH_SHORT);
        //toast.show();
        if (HighScoreDbHelper.isHighScore(getApplicationContext(), score)) {
            openDialog();
        }
    }
    final ListView listview = (ListView) findViewById(R.id.listview);
    list = new ArrayList<String>();
    addTitle();
    updateHighScores();

    adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
    listview.setAdapter(adapter);

}

From source file:com.browsertophone.C2DMReceiver.java

@Override
public void onMessage(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras != null) {
        String url = (String) extras.get("url");
        String title = (String) extras.get("title");
        String sel = (String) extras.get("sel");
        String debug = (String) extras.get("debug");

        if (debug != null) {
            // server-controlled debug - the server wants to know
            // we received the message, and when. This is not user-controllable,
            // we don't want extra traffic on the server or phone. Server may
            // turn this on for a small percentage of requests or for users
            // who report issues.
            DefaultHttpClient client = new DefaultHttpClient();
            HttpGet get = new HttpGet(AppEngineClient.BASE_URL + "/debug?id=" + extras.get("collapse_key"));
            // No auth - the purpose is only to generate a log/confirm delivery
            // (to avoid overhead of getting the token)
            try {
                client.execute(get);//from w  w  w.  j ava  2 s .c  o m
            } catch (ClientProtocolException e) {
                // ignore
            } catch (IOException e) {
                // ignore
            }
        }

        if (title != null && url != null && url.startsWith("http")) {
            SharedPreferences settings = Prefs.get(context);
            Intent launchIntent = LauncherUtils.getLaunchIntent(context, title, url, sel);

            // Notify and optionally start activity
            if (settings.getBoolean("launchBrowserOrMaps", true) && launchIntent != null) {
                LauncherUtils.playNotificationSound(context);
                context.startActivity(launchIntent);
            } else {
                if (sel != null && sel.length() > 0) { // have selection
                    LauncherUtils.generateNotification(context, sel,
                            context.getString(R.string.copied_desktop_clipboard), launchIntent);
                } else {
                    LauncherUtils.generateNotification(context, url, title, launchIntent);
                }
            }

            // Record history (for link/maps only)
            if (launchIntent != null && launchIntent.getAction().equals(Intent.ACTION_VIEW)) {
                HistoryDatabase.get(context).insertHistory(title, url);
            }
        }
    }
}

From source file:com.menumomma.chrome2phone.C2DMReceiver.java

@Override
public void onMessage(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras != null) {
        String url = (String) extras.get("url");
        String title = (String) extras.get("title");
        String sel = (String) extras.get("sel");
        String debug = (String) extras.get("debug");

        if (debug != null) {
            // server-controlled debug - the server wants to know
            // we received the message, and when. This is not user-controllable,
            // we don't want extra traffic on the server or phone. Server may
            // turn this on for a small percentage of requests or for users
            // who report issues.
            DefaultHttpClient client = new DefaultHttpClient();
            HttpGet get = new HttpGet(Config.BASE_URL + "/debug?id=" + extras.get("collapse_key"));
            // No auth - the purpose is only to generate a log/confirm delivery
            // (to avoid overhead of getting the token)
            try {
                client.execute(get);//  w ww  .  ja  v a 2 s .c  om
            } catch (ClientProtocolException e) {
                // ignore
            } catch (IOException e) {
                // ignore
            }
        }

        if (title != null && url != null && url.startsWith("http")) {
            SharedPreferences settings = Prefs.get(context);
            Intent launchIntent = LauncherUtils.getLaunchIntent(context, title, url, sel);

            // Notify and optionally start activity
            if (settings.getBoolean("launchBrowserOrMaps", true) && launchIntent != null) {
                try {
                    context.startActivity(launchIntent);
                    LauncherUtils.playNotificationSound(context);
                } catch (ActivityNotFoundException e) {
                    return;
                }
            } else {
                LauncherUtils.generateNotification(context, url, title, launchIntent);
            }

            // Record history (for link/maps only)
            if (launchIntent != null && launchIntent.getAction().equals(Intent.ACTION_VIEW)) {
                HistoryDatabase.get(context).insertHistory(title, url);
            }
        }
    }
}

From source file:com.yozio.demo.implementations.facebook.PostPhotoActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {

    if (intent != null) {
        Bundle extras = intent.getExtras();
        mImageBitmap = (Bitmap) extras.get("data");

        if (mImageBitmap != null) {
            mImageView.setImageBitmap(mImageBitmap);
            btnPostPhoto.setVisibility(View.VISIBLE);
        } else {// w  ww .  j a v a 2 s . co m
            btnPostPhoto.setVisibility(View.GONE);
        }
    }

}

From source file:activity.CoursActivity.java

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

    Bundle extras = getIntent().getExtras();

    if (extras != null) {
        mCurrentCours = new Select().from(Cours.class).where("Id = ?", extras.get("coursID")).executeSingle();
    }/*from   ww  w . java 2s.c o  m*/
    if (mCurrentCours == null) {
        finish();
    }
    setTitle(String.format("[%s] %s", mCurrentCours.getOfficialCode(), mCurrentCours.getName()),
            mCurrentCours.getTitular());

    mFragment = new ToolViewPagerFragment();
    mFragment.setArguments(extras);

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(android.R.id.content, mFragment);
    ft.commit();
}

From source file:com.example.austin.test.TextActivity.java

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

    Thread thread = new Thread(new Runnable() {
        @Override/*from  www .  ja v  a  2s  .  c  o m*/
        public void run() {
            try {
                Bundle bundle = getIntent().getExtras();
                Bitmap photo = (Bitmap) bundle.get("photo");
                ByteArrayOutputStream stream1 = new ByteArrayOutputStream();
                photo.compress(Bitmap.CompressFormat.PNG, 100, stream1);
                byte[] fileContent = stream1.toByteArray();

                String license_code = "59D1D7B4-61FD-49EB-A549-C77E08B7103A";
                String user_name = "austincheng16";

                String ocrURL = "http://www.ocrwebservice.com/restservices/processDocument?gettext=true";
                URL url = new URL(ocrURL);

                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                connection.setDoOutput(true);
                connection.setDoInput(true);
                connection.setRequestMethod("POST");

                connection.setRequestProperty("Authorization", "Basic "
                        + new String(Base64.encodeBase64((user_name + ":" + license_code).getBytes())));

                connection.setRequestProperty("Content-Type", "application/json");

                connection.setRequestProperty("Content-Length", Integer.toString(fileContent.length));

                try {
                    OutputStream stream = connection.getOutputStream();

                    stream.write(fileContent);
                    stream.close();

                    int httpCode = connection.getResponseCode();

                    if (httpCode == HttpURLConnection.HTTP_OK) {
                        String jsonResponse = GetResponseToString(connection.getInputStream());
                        PrintOCRResponse(jsonResponse);
                    } else {
                        String jsonResponse = GetResponseToString(connection.getErrorStream());
                        JSONParser parser = new JSONParser();
                        JSONObject jsonObj = (JSONObject) parser.parse(jsonResponse);
                        Log.i("austin", "Error Message: " + jsonObj.get("ErrorMessage"));
                    }
                    connection.disconnect();
                } catch (IOException e) {
                    Log.i("austin", "IOException");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    thread.start();
}

From source file:com.github.yuukis.businessmap.app.ContactsItemsDialogFragment.java

@SuppressWarnings("unchecked")
@Override/*from  ww w  .  j  ava 2s  .co m*/
public void onAttach(Activity activity) {
    super.onAttach(activity);
    if (activity instanceof OnSelectListener) {
        mListener = (OnSelectListener) activity;
    }
    Bundle args = getArguments();
    if (args != null && args.containsKey(KEY_CONTACTS_ITEMS)) {
        mContactsItems = (List<ContactsItem>) args.get(KEY_CONTACTS_ITEMS);
    }
}

From source file:com.demo.push.GcmListener.java

/**
 * Called when message is received./*  ww w .  j  ava 2 s .c o  m*/
 *
 * @param from SenderID of the sender.
 * @param data Data bundle containing message data as key/value pairs.
 *             For Set of keys use data.keySet().
 */
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {

    String message = data.getString("text");

    for (String key : data.keySet()) {
        Timber.v(" key " + key + "\n value: " + data.get(key));
    }

    if (pushRecieveListener != null) {
        pushRecieveListener.onPushRecieve();
    }

    sendNotification(message);
}

From source file:com.secbro.qark.exportedcomponent.exportedactivity.IntentSenderActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case REQUEST_CODE: {
        if (resultCode == Activity.RESULT_OK) {
            if (data != null) {
                Map resultMap = new HashMap<Object, Object>();
                Bundle bundle = data.getExtras();
                for (String key : bundle.keySet()) {
                    Object value = bundle.get(key);
                    Log.d("key", key);
                    Log.d("value", value.toString());
                    resultMap.put(key, value);
                }//from w w  w.  j  a  va 2  s  .com
                showResultFromExploit(resultMap);
            }
        } else {
            Log.d("INFO", "No data received");
        }
    }
    }
}