List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:com.nagopy.android.xposed.SettingChangedReceiver.java
@Override public void onReceive(Context context, Intent intent) { Object obj = dataObject.get(); if (!StringUtils.equals(intent.getAction(), action) || obj == null) { context.unregisterReceiver(this); return;/*w ww . j a v a 2 s. com*/ } Bundle extras = intent.getExtras(); if (extras == null || extras.size() != 2) { return; } try { // target?value???????? String target = extras.getString("target"); Object value = extras.get("value"); obj.getClass().getField(target).set(obj, value); onDataChanged(); } catch (Throwable t) { Logger.e(getClass().getSimpleName(), Log.getStackTraceString(t)); } }
From source file:com.app.poke.poke.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { // mGoogleApiClient = ((MainActivityPhone)this.getApplicationContext()).mGoogleApiClient; Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*//from w w w .jav a 2s. c om * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { //SOCKET CODE /* try{ socket = IO.socket("http://192.168.1.69"); }catch(Exception e){ Log.e(TAG, "COnnect error"); } socket.connect(); // Receiving an object socket.on("Poke.poke", new Emitter.Listener() { @Override public void call(Object... args) { JSONObject obj = (JSONObject) args[0]; Log.i(TAG, "Received JSON"); try { if(obj.getString("to").equals(PokeConfig.CLIENT_ID)){ //Take server message and forward to watch (first node FIXME: more nodes? Collection<String> nodes = MainActivityPhone.getNodes(); String nodeid = nodes.iterator().next(); Log.d(TAG, "Node id: "+nodeid); MainActivityPhone.sendPokedMessage(nodeid); } } catch (JSONException e) { e.printStackTrace(); } } });*/ sendNotification("Poke from: " + extras.getString("to")); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:fragments.NewTicket.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case COLOR_PICKER: if (resultCode == Activity.RESULT_OK) { Bundle bundle = data.getExtras(); String color = bundle.getString("color", ""); ticketColor.setText(color);/*from w ww . ja va 2 s. c o m*/ } else if (resultCode == Activity.RESULT_CANCELED) { ticketColor.setText(""); } break; } }
From source file:com.polyvi.xface.extension.uppay.XUPPayExt.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { String payResult = "fail"; if (intent != null) { if (UPPAY_PLUGIN_REQUEST_CODE == requestCode) { payResult = intent.getExtras().getString(KEY_PAY_RESULT).toLowerCase(Locale.ENGLISH); if (null != payResult) { if (payResult.equals(PAY_RESULT_SUCCESS)) { mCallbackCtx.success(PAY_RESULT_SUCCESS); } else { mCallbackCtx.error(payResult); }/*from w w w .ja v a 2s.c o m*/ } else { // ? String balanceAmount = intent.getExtras().getString("balance_amount"); // ?? String balanceAvailableAmount = intent.getExtras().getString("balance_available_amount"); JSONObject jsonObj = null; if (null == balanceAmount && null == balanceAvailableAmount) { XLog.e(CLASS_NAME, "Return params: balanceAmount or balanceAvailableAmount is null"); mCallbackCtx.error(payResult); } else { jsonObj = new JSONObject(); try { jsonObj.put("balance", balanceAmount); jsonObj.put("availableBalance", balanceAvailableAmount); mCallbackCtx.success(jsonObj); } catch (JSONException e) { XLog.e(CLASS_NAME, "onActivityResult put element into jsonObj error!"); e.printStackTrace(); mCallbackCtx.error(payResult); } } } } } }
From source file:com.carpool.dj.carpool.model.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*//from w w w. j a v a 2 s .c o m * Filter messages based on message type. Since it is likely that GCM * will be extended in the future with new message types, just ignore * any message types you're not interested in, or that you don't * recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // This loop represents the service doing some work. /* for (int i=0; i<5; i++) { Log.i("", "Working... " + (i+1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(5000); } catch (InterruptedException e) { } }*/ //Log.i("", "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. //sendNotification("Received: " + extras.toString()); onMessage(Utils.nowActivity, intent); Log.i("", "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.scigames.slidegame.Registration4PhotoActivity.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAMERA_REQUEST) { photo = (Bitmap) data.getExtras().get("data"); //photoUri = data.getExtras().get("data"); imageView.setImageBitmap(photo); }//from ww w. j a v a2 s .c o m }
From source file:com.example.karspoolingapp.RouteByHitchhikerCar.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.routebyhitchhiker); Intent intent = getIntent(); Bundle bundle = intent.getExtras(); new_license_number = bundle.getString("pre_end_point"); //session_username = session.getUsername(); System.out.println("nayaaa licnse number" + new_license_number); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy);// w ww. j ava 2s .c om // code for dynamic radio button generation final RadioButton[] rb = new RadioButton[100]; rl = (RelativeLayout) findViewById(R.id.rl); rg = new RadioGroup(this); // Building Parameters List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("car_number", new_license_number)); System.out.println(params); json = jsonParser.makeHttpRequest(READ_COMMENTS_URL2, "POST", params); params.clear(); System.out.println(json); try { jsonTripDetails = json.getJSONArray("route"); System.out.println(jsonTripDetails); int k = jsonTripDetails.length(); if (k > 0) { for (int i = 0; i < jsonTripDetails.length(); i++) { JSONObject c = jsonTripDetails.getJSONObject(i); String parent_username_str = c.getString("username"); String route = c.getString("route"); String timing = c.getString("timing"); String seating = c.getString("seating_capacity"); rb[i] = new RadioButton(this); rg.addView(rb[i]); rb[i].setText(parent_username_str + "," + route + "," + timing + "," + seating); params.clear(); } rl.addView(rg); rl.setPadding(50, 50, 50, 50); } else { Toast.makeText(RouteByHitchhikerCar.this, "No Trip available on these routes", Toast.LENGTH_LONG) .show(); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } addListenerOnButton(); }
From source file:com.example.office.ui.calendar.EventFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mInflater = inflater;//from w w w . j a v a2 s .com View rootView = inflater.inflate(getFragmentLayoutId(), container, false); try { Activity activity = getActivity(); activity.getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); Intent intent = getActivity().getIntent(); event = (Event) intent.getExtras().get(getActivity().getString(R.string.intent_event_key)); displayEvent(rootView); getActivity().setProgressBarIndeterminateVisibility(false); // Code below will be invoked when we receive system intent holding the path to shared image and this image is transformed into bytes[]. mImagePicker = new ImagePicker(getActivity(), getActivity().getString(R.string.intent_event_key)) { @Override public void processImage(final byte[] imageBytes, final String fileName, final Object intentArg) { try { String itemId = ""; if (intentArg instanceof Event) { itemId = ((Event) intentArg).getId(); } if (!TextUtils.isEmpty(itemId)) { // Getting event by id Futures.addCallback(Me.getEvents().getAsync(itemId), new FutureCallback<IEvent>() { @Override public void onFailure(Throwable t) { if (!onError(t)) { mImagePicker.showStatusToast(Status.UPLOAD_FAILED); } } @Override public void onSuccess(IEvent event) { try { IFileAttachment attachment = event.getAttachments().newFileAttachment(); attachment.setContentBytes(imageBytes).setName(fileName); // Propagating changes to server Me.flush(); mImagePicker.showStatusToast(Status.UPLOAD_SUCCESS); } catch (Exception e) { onFailure(e); } } }); } } catch (Exception e) { if (!onError(e)) { mImagePicker.showStatusToast(Status.UPLOAD_FAILED); } } } }; } catch (Exception e) { Logger.logApplicationException(e, getClass().getSimpleName() + ".onCreateView(): Error."); } return rootView; }
From source file:fm.smart.r1.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"); goal_id = (String) extras.get("goal_id"); if (goal_id == null || goal_id.equals("")) { goal_id = Main.default_study_goal_id; }/*w ww .j a v a2 s.c om*/ 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); } }