List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:com.ibuildapp.romanblack.MultiContactsPlugin.MultiContactsActivity.java
@Override public void create() { try {/*from w w w . j av a 2s . c o m*/ setContentView(R.layout.grouped_contacts_main); setTopBarLeftButtonTextAndColor(getResources().getString(R.string.common_back_upper), getResources().getColor(android.R.color.black), true, new View.OnClickListener() { @Override public void onClick(View view) { finish(); return; } }); setTopBarTitleColor(getResources().getColor(android.R.color.black)); setTopBarBackgroundColor(Statics.color1); LinearLayout inputSearchLayout = (LinearLayout) findViewById(R.id.grouped_contacts_search_layout); inputSearchLayout.setVisibility(View.GONE); resources = getResources(); Intent currentIntent = getIntent(); Bundle store = currentIntent.getExtras(); widget = (Widget) store.getSerializable("Widget"); category = store.getString("category"); setTopBarTitle(category); if (widget == null) { handler.sendEmptyMessage(INITIALIZATION_FAILED); return; } cachePath = widget.getCachePath() + "/contacts-" + widget.getOrder(); root = (LinearLayout) findViewById(R.id.grouped_contacts_main_root); listView = (ListView) findViewById(R.id.grouped_contacts_list); separator = findViewById(R.id.gc_head_separator); backSeparator = findViewById(R.id.gc_back_separator); backSeparator.setBackgroundColor(Statics.color1); if (Statics.isLight) { separator.setBackgroundColor(Color.parseColor("#4d000000")); } else { separator.setBackgroundColor(Color.parseColor("#4dFFFFFF")); } handler.sendEmptyMessage(SET_ROOT_BACKGROUND); } catch (Exception e) { } }
From source file:com.mobileobservinglog.support.billing.DonationBillingHandler.java
int getResponseCodeFromIntent(Intent i) { Object o = i.getExtras().get(RESPONSE_CODE); if (o == null) { Log.e("DonationBillingHandler", "Intent with no response code, assuming OK (known issue)"); return BILLING_RESPONSE_RESULT_OK; } else if (o instanceof Integer) return ((Integer) o).intValue(); else if (o instanceof Long) return (int) ((Long) o).longValue(); else {//from www .java 2 s . co m Log.e("DonationBillingHandler", "Unexpected type for intent response code."); Log.e("DonationBillingHandler", o.getClass().getName()); throw new RuntimeException("Unexpected type for intent response code: " + o.getClass().getName()); } }
From source file:fm.smart.r1.activity.CreateExampleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ExceptionHandler.register(this); setContentView(R.layout.create_example); final Intent queryIntent = getIntent(); Bundle extras = queryIntent.getExtras(); item_id = (String) extras.get("item_id"); list_id = (String) extras.get("list_id"); if (list_id == null || list_id.equals("")) { list_id = Main.default_study_list_id; }//from w ww. ja v a 2 s . c o m cue = (String) extras.get("cue"); example = (String) extras.get("example"); translation = (String) extras.get("translation"); example_language = (String) extras.get("example_language"); translation_language = (String) extras.get("translation_language"); example_transliteration = (String) extras.get("example_transliteration"); translation_transliteration = (String) extras.get("translation_transliteration"); TextView example_text = (TextView) findViewById(R.id.create_example_sentence); if (!TextUtils.isEmpty(example)) { example_text.setText(example); } example_text.setHint(example_language + " sentence with " + cue); TextView translation_text = (TextView) findViewById(R.id.create_example_translation); if (!TextUtils.isEmpty(translation)) { translation_text.setText(translation); } translation_text.setHint(translation_language + " translation of example sentence"); Button button = (Button) findViewById(R.id.create_example_submit); button.setOnClickListener(this); TextView translation_text_legend = (TextView) findViewById(R.id.create_example_translation_legend); TextView sentence_transliteration_textView = (TextView) findViewById( R.id.create_example_sentence_transliteration); EditText sentence_transliteration_input_textView = (EditText) findViewById(R.id.sentence_transliteration); if (!Utils.isIdeographicLanguage(Main.search_lang)) { sentence_transliteration_textView.setVisibility(View.GONE); sentence_transliteration_input_textView.setVisibility(View.GONE); } else if (!TextUtils.isEmpty(example_transliteration)) { sentence_transliteration_input_textView.setText(example_transliteration); } TextView translation_transliteration_textView = (TextView) findViewById( R.id.create_example_translation_transliteration); EditText translation_transliteration_input_textView = (EditText) findViewById( R.id.translation_transliteration); if (!Utils.isIdeographicLanguage(Main.result_lang)) { translation_transliteration_textView.setVisibility(View.GONE); translation_transliteration_input_textView.setVisibility(View.GONE); } else if (!TextUtils.isEmpty(translation_transliteration)) { translation_transliteration_input_textView.setText(translation_transliteration); } }
From source file:my.com.nexstream.konnectedpay.KonnectedPayCordova.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == Payment.PAYMENT_RETURN && paymentOngoing && paymentCallbackContext != null) { try {/*w w w. j a v a2 s. c o m*/ if (intent == null) throw new NoResponseException(); Bundle extras = intent.getExtras(); if (extras == null) throw new NoResponseException(); String status = extras.getString("status"); JSONObject resp = new JSONObject(); resp.put("amount", extras.getString("amount")); resp.put("status", status); resp.put("code", extras.getString("code")); resp.put("desc", extras.getString("desc")); resp.put("tranId", extras.getString("tranId")); if (status.equals("S")) paymentCallbackContext.success(resp); else paymentCallbackContext.error(resp); } catch (NoResponseException e) { paymentCallbackContext.error(ERROR_NO_RESPONSE_RECEIVED); } catch (Exception e) { paymentCallbackContext.error("Unexpected failure: " + e.getMessage()); } finally { paymentOngoing = false; paymentCallbackContext = null; } } }
From source file:com.siahmsoft.soundroid.sdk7.services.UploadService.java
@Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); Log.i(TAG, "Starting #" + startId + ": " + intent.getExtras()); Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId;/*from w w w . j a v a 2s.c o m*/ msg.obj = intent.getExtras(); mServiceHandler.sendMessage(msg); Log.i(TAG, "Sending: " + msg); }
From source file:com.irccloud.android.GCMIntentService.java
@Override protected void onHandleIntent(Intent intent) { if (intent != null) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (extras != null && !extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { //Log.d("IRCCloud", "Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { //Log.d("IRCCloud", "Deleted messages on server: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { if (!IRCCloudApplication.getInstance().getApplicationContext().getSharedPreferences("prefs", 0) .getBoolean("gcm_registered", false)) { String regId = IRCCloudApplication.getInstance().getApplicationContext() .getSharedPreferences("prefs", 0).getString("gcm_reg_id", ""); if (regId.length() > 0) { scheduleUnregisterTimer(100, regId, false); }//from ww w . jav a 2 s.co m } else { //Log.d("IRCCloud", "GCM K/V pairs: " + intent.getExtras().toString()); try { String type = intent.getStringExtra("type"); if (type.equalsIgnoreCase("heartbeat_echo")) { NetworkConnection conn = NetworkConnection.getInstance(); ObjectMapper mapper = new ObjectMapper(); JsonParser parser = mapper.getFactory() .createParser(intent.getStringExtra("seenEids")); JsonNode seenEids = mapper.readTree(parser); Iterator<Map.Entry<String, JsonNode>> iterator = seenEids.fields(); while (iterator.hasNext()) { Map.Entry<String, JsonNode> entry = iterator.next(); JsonNode eids = entry.getValue(); Iterator<Map.Entry<String, JsonNode>> j = eids.fields(); while (j.hasNext()) { Map.Entry<String, JsonNode> eidentry = j.next(); String bid = eidentry.getKey(); long eid = eidentry.getValue().asLong(); if (conn.ready && conn.getState() != NetworkConnection.STATE_CONNECTED) BuffersDataSource.getInstance().updateLastSeenEid(Integer.valueOf(bid), eid); Notifications.getInstance().deleteOldNotifications(Integer.valueOf(bid), eid); Notifications.getInstance().updateLastSeenEid(Integer.valueOf(bid), eid); } } parser.close(); } else { int cid = Integer.valueOf(intent.getStringExtra("cid")); int bid = Integer.valueOf(intent.getStringExtra("bid")); long eid = Long.valueOf(intent.getStringExtra("eid")); if (Notifications.getInstance().getNotification(eid) != null) { Log.e("IRCCloud", "GCM got EID that already exists"); return; } String from = intent.getStringExtra("from_nick"); String msg = intent.getStringExtra("msg"); if (msg != null) msg = ColorFormatter .html_to_spanned(ColorFormatter.irc_to_html(TextUtils.htmlEncode(msg))) .toString(); String chan = intent.getStringExtra("chan"); if (chan == null) chan = ""; String buffer_type = intent.getStringExtra("buffer_type"); String server_name = intent.getStringExtra("server_name"); if (server_name == null || server_name.length() == 0) server_name = intent.getStringExtra("server_hostname"); String network = Notifications.getInstance().getNetwork(cid); if (network == null) Notifications.getInstance().addNetwork(cid, server_name); Notifications.getInstance().addNotification(cid, bid, eid, from, msg, chan, buffer_type, type); if (from == null || from.length() == 0) Notifications.getInstance().showNotifications(server_name + ": " + msg); else if (buffer_type.equals("channel")) { if (type.equals("buffer_me_msg")) Notifications.getInstance() .showNotifications(chan + ": " + from + " " + msg); else Notifications.getInstance() .showNotifications(chan + ": <" + from + "> " + msg); } else { if (type.equals("buffer_me_msg")) Notifications.getInstance().showNotifications(" " + from + " " + msg); else Notifications.getInstance().showNotifications(from + ": " + msg); } } } catch (Exception e) { e.printStackTrace(); Log.w("IRCCloud", "Unable to parse GCM message"); } } } } GCMBroadcastReceiver.completeWakefulIntent(intent); } }
From source file:com.authorwjf.bounce.BluetoothChat.java
private void connectDevice(Intent data, boolean secure) { // Get the device MAC address String address = data.getExtras().getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS); // Get the BluetoothDevice object BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); // Attempt to connect to the device mChatService.connect(device, secure); }
From source file:com.baidu.android.voicedemo.ApiActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { onResults(data.getExtras()); }//w w w . j av a 2s .c om }
From source file:com.ibm.mobilefirstplatform.clientsdk.android.push.internal.MFPInternalPushMessage.java
public MFPInternalPushMessage(Intent intent) { Bundle info = intent.getExtras(); MFPPushUtils.dumpIntent(intent);//from ww w . java 2 s .c o m alert = info.getString(GCM_EXTRA_ALERT); url = info.getString(GCM_EXTRA_URL); payload = info.getString(GCM_EXTRA_PAYLOAD); sound = info.getString(GCM_EXTRA_SOUND); bridge = info.getBoolean(GCM_EXTRA_BRIDGE); priority = info.getString(GCM_EXTRA_PRIORITY); visibility = info.getString(GCM_EXTRA_VISIBILITY); redact = info.getString(GCM_EXTRA_REDACT); key = info.getString(GCM_EXTRA_KEY); category = info.getString(GCM_EXTRA_CATEGORY); gcmStyle = info.getString(GCM_EXTRA_STYLE); iconName = info.getString(GCM_EXTRA_ICONNAME); notificationId = info.getInt(GCM_EXTRA_NOTIFICATIONID); try { JSONObject towers = new JSONObject(payload); id = towers.getString(GCM_EXTRA_ID); } catch (JSONException e) { logger.error( "MFPInternalPushMessage: MFPInternalPushMessage() - Exception while parsing JSON, get id. " + e.toString()); } }
From source file:fm.smart.r1.activity.CreateItemActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ExceptionHandler.register(this); setContentView(R.layout.create_item); final Intent queryIntent = getIntent(); Bundle extras = queryIntent.getExtras(); list_id = (String) extras.get("list_id"); cue = (String) extras.get("cue"); response = (String) extras.get("response"); cue_language = (String) extras.get("cue_language"); response_language = (String) extras.get("response_language"); character_cue = (String) extras.get("character_cue"); character_response = (String) extras.get("character_response"); pos = (String) extras.get("pos"); Button button = (Button) findViewById(R.id.create_item_submit); button.setOnClickListener(this); TextView cue_text = (TextView) findViewById(R.id.cue); if (!TextUtils.isEmpty(cue)) { cue_text.setText(cue);/*from w ww.j av a 2 s. co m*/ } TextView response_text = (TextView) findViewById(R.id.response); if (!TextUtils.isEmpty(response)) { response_text.setText(response); } TextView cue_character_text = (TextView) findViewById(R.id.cue_character); if (!TextUtils.isEmpty(character_cue)) { cue_character_text.setText(character_cue); } TextView response_character_text = (TextView) findViewById(R.id.response_character); if (!TextUtils.isEmpty(character_response)) { response_character_text.setText(character_response); } TextView cue_legend = (TextView) findViewById(R.id.create_item_cue_legend); cue_legend.setText(Utils.INV_LANGUAGE_MAP.get(cue_language) + " Term"); TextView response_legend = (TextView) findViewById(R.id.create_item_response_legend); response_legend.setText(Utils.INV_LANGUAGE_MAP.get(response_language) + " Term"); TextView cue_character_textView = (TextView) findViewById(R.id.create_item_cue_character); cue_character_textView.setText(Utils.INV_LANGUAGE_MAP.get(cue_language) + " Character Text"); TextView response_character_textView = (TextView) findViewById(R.id.create_item_response_character); response_character_textView.setText(Utils.INV_LANGUAGE_MAP.get(response_language) + " Character Text"); List<String> pos_list = new Vector<String>(Utils.POS_MAP.keySet()); Collections.sort(pos_list); ArrayAdapter<String> pos_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, pos_list); // .simple_spinner_item Spinner pos_textView = (Spinner) findViewById(R.id.pos); pos_textView.setAdapter(pos_adapter); if (!TextUtils.isEmpty(pos)) { pos_textView.setSelection(pos_list.indexOf(pos)); } else { pos_textView.setSelection(pos_list.indexOf("Noun")); } EditText cue_character_input_textView = (EditText) findViewById(R.id.cue_character); if (!Utils.isIdeographicLanguage(Main.search_lang)) { cue_character_textView.setVisibility(View.GONE); cue_character_input_textView.setVisibility(View.GONE); } else if (!TextUtils.isEmpty(character_cue)) { cue_character_input_textView.setText(character_cue); } EditText response_character_input_textView = (EditText) findViewById(R.id.response_character); if (!Utils.isIdeographicLanguage(Main.result_lang)) { response_character_textView.setVisibility(View.GONE); response_character_input_textView.setVisibility(View.GONE); } else if (!TextUtils.isEmpty(character_response)) { response_character_input_textView.setText(character_response); } }