List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:com.example.research.whatis.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (resultCode) { case 0:/*from w w w . ja v a 2 s . c om*/ finish(); break; case -1: try { Log.d("API", "data.getExtras().get(\"data\")" + data.getExtras().get("outPutURI")); Log.d("API", "sdImageDir" + sdImageMainDirectory); Bitmap photo = (Bitmap) data.getExtras().get("data"); StoreImage(this, photo); try { invokeOCRAPI(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } // Toast.makeText(this, "Response: " + OCRedText, Toast.LENGTH_LONG).show(); Log.d("API", "Response: " + OCRedText); } catch (Exception e) { e.printStackTrace(); } //finish(); //startActivity(new Intent(CameraCapture.this, Home.class)); } }
From source file:es.rczone.tutoriales.gmaps.MainActivity.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { /**//from ww w .j ava 2 s . com * Result for Address activity */ if (requestCode == 1) { if (resultCode == RESULT_OK) { Address current_location = data.getExtras().getParcelable("result"); LatLng addressLocation = new LatLng(current_location.getLatitude(), current_location.getLongitude()); CameraPosition camPos = new CameraPosition.Builder().target(addressLocation) //Center camera in 'Plaza Maestro Villa' .zoom(16) //Set 16 level zoom .build(); CameraUpdate camUpd3 = CameraUpdateFactory.newCameraPosition(camPos); map.animateCamera(camUpd3); String description = current_location.getThoroughfare() + " " + current_location.getSubThoroughfare() + ", " + current_location.getLocality() + ", " + current_location.getCountryName(); Marker m = map.addMarker(new MarkerOptions().position(addressLocation)); markersList.add(m); Toast.makeText(this, description, Toast.LENGTH_LONG).show(); } if (resultCode == RESULT_CANCELED) { // Write your code if there's no result } } }
From source file:org.mrquiz.android.tinyurl.SendTinyUrlActivity.java
private void send() { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); Intent originalIntent = getIntent(); if (Intent.ACTION_SEND.equals(originalIntent.getAction())) { // Copy extras from the original intent because they miht contain // additional information about the URL (e.g., the title of a // YouTube video). Do this before setting Intent.EXTRA_TEXT to avoid // overwriting the TinyShare. intent.putExtras(originalIntent.getExtras()); }/*w w w . java2s . com*/ intent.putExtra(Intent.EXTRA_TEXT, mTinyUrl); try { CharSequence template = getText(R.string.title_send); String title = String.format(String.valueOf(template), mTinyUrl); startActivity(Intent.createChooser(intent, title)); } catch (ActivityNotFoundException e) { handleError(e); } }
From source file:eu.thecoder4.gpl.pleftdroid.HandleLinksActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Verifying Link..."); setContentView(tv);// w w w . j a va 2s. c o m Intent intent = getIntent(); if (intent.getAction().equals("android.intent.action.VIEW")) { try { Uri uri = getIntent().getData(); theurl = uri.toString(); } catch (Exception e) { Toast.makeText(this, R.string.toast_couldnotopenurl, Toast.LENGTH_LONG).show(); } } else if (Intent.ACTION_SEND.equals(intent.getAction())) { Bundle extras = intent.getExtras(); theurl = extras.getCharSequence(Intent.EXTRA_TEXT).toString(); } else { theurl = ""; } //Toast.makeText(this, "The URL = "+theurl, Toast.LENGTH_LONG).show(); // Parse the URL // VERIFICATION: verify?id=&u=&p= // INVITATION: a?id=&u=&p= if (theurl.indexOf("?") < 0 && theurl.indexOf("/verify?") < 0 && theurl.indexOf("/a?") < 0) { Toast.makeText(this, R.string.toast_linknotsupp, Toast.LENGTH_LONG).show(); finish(); } else { Map<String, String> arr = PleftBroker.getParamsFromURL(theurl); pserver = arr.get("pserver"); if (arr.get("id") != null) { aid = Integer.parseInt(arr.get("id")); } else { aid = 0; } vcode = arr.get("p"); user = arr.get("u"); if (aid == 0 || vcode == null || user == null) { Toast.makeText(this, R.string.toast_shlinknotvalid, Toast.LENGTH_LONG).show(); finish(); } else { // we have a valid Link handleLnk = new Runnable() { @Override public void run() { handleLink(); } }; Thread thread = new Thread(null, handleLnk, "Handlethrd"); thread.start(); } // End - if Link is Valid } }
From source file:com.polyvi.xface.extension.messaging.XMessagingExt.java
private void genMsgReceiveBroadcastReceiver() { if (null == mMsgReceiveBroadcaseReceiver) { mMsgReceiveBroadcaseReceiver = new BroadcastReceiver() { @Override/*from www . j a v a2 s .c om*/ public void onReceive(Context context, Intent intent) { if (INTENT_ACTION.equals(intent.getAction())) { Bundle bundle = intent.getExtras(); if (null != bundle) { // pdus?? Object[] pdus = (Object[]) bundle.get("pdus"); // SmsMessage[] msgs = new SmsMessage[pdus.length]; for (int i = 0; i < pdus.length; i++) { // ???pdu?,? msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]); } JSONArray receivedMsgs = buildSmsList(msgs); XEvent evt = XEvent.createEvent(XEventType.MSG_RECEIVED, receivedMsgs.toString()); ((XFaceMainActivity) mContext).getEventCenter().sendEventAsync(evt); } } } }; } }
From source file:io.coldstart.android.GCMIntentService.java
@Override protected void onMessage(Context arg0, Intent intent) { String ns = Context.NOTIFICATION_SERVICE; mNM = (NotificationManager) arg0.getSystemService(ns); //Log.e("GCMIntentService","onMessageonMessageonMessageonMessage"); //GCM Payload String alertCount = intent.getExtras().getString("alertCount"); String maxSeverity = intent.getExtras().getString("alertSeverity"); String alertTime = intent.getExtras().getString("alertTime"); String alertType = intent.getExtras().getString("alertType"); String payloadJSON = intent.getExtras().getString("payload"); //Stuff from the payload String hostname = "---", TrapDetails = "---", IP = "", Date = "", Uptime = "", payloadDetails = "Unknown payload"; //0 = a single alert if (alertType.equals(API.MSG_TRAP)) { if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("allowBundling", false)) { //Log.i("TRAP","Received a trap notification but I'm bundling"); return; }/* w ww. ja va 2 s.com*/ try { JSONObject payload = new JSONObject(payloadJSON); //Log.i("payload",payload.toString(3)); try { hostname = payload.getJSONObject("source").getString("hostname"); } catch (Exception e) { hostname = "Unknown host"; } try { //payloadDetails = payload.getJSONArray("trapdetails"); payloadDetails = payload.getString("trapdetails"); } catch (Exception e) { //e.printStackTrace(); payloadDetails = "Unknown Trap payload"; } try { IP = payload.getJSONObject("source").getString("ip"); } catch (Exception e) { IP = "127.0.0.1"; } try { Date = payload.getString("date"); } catch (Exception e) { Date = "01/01/1970"; } try { Uptime = payload.getString("uptime"); } catch (Exception e) { Uptime = ""; } } catch (Exception e) { //e.printStackTrace(); } Trap trap = new Trap(hostname, IP); trap.date = Date; trap.uptime = Uptime; trap.trap = payloadDetails; if (Build.VERSION.SDK_INT >= 16) { SendInboxStyleNotification(alertCount, alertTime, hostname, trap.getPayloadAsString()); } else { SendCombinedNotification(alertCount); } datasource = new TrapsDataSource(this); datasource.open(); datasource.addRecentTrap(trap); datasource.close(); //If the app is in the foreground we should instruct it to refresh Intent broadcast = new Intent(); broadcast.setAction(API.BROADCAST_ACTION); sendBroadcast(broadcast); } //1 = an generic notification //TODO Create generic handler //2 = batch (a bit like rate limit but on user choice) else if (alertType.equals(API.MSG_BATCH)) { //Check we are ones after a bundled alert (many people share this GCM ID) if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("allowBundling", false)) { sendBatchNotification(intent.getExtras().getString("alertCount")); } else { //Log.i("BATCHING","Batching isn't enabled at the moment"); } } //3 = Zenoss (for use with Rhybudd / coldstart HTTP API) else if (alertType.equals(API.MSG_ZENOSS)) { Intent broadcast = new Intent(); broadcast.setAction(API.ZENOSS_BROADCAST_ACTION); sendBroadcast(broadcast); } //4 = rate limit hit else if (alertType.equals(API.MSG_RATELIMIT)) { sendRateLimitNotification(intent.getExtras().getString("ratelimit")); } else { //Do nothing //TODO Log an error / inform the user they need to update? } }
From source file:com.example.bluetooth_faster_connection.MainActivity.java
private void connectDevice(Intent data, boolean secure) { // Get the device MAC address String address = data.getExtras().getString(DeviceDicoverService.EXTRA_DEVICE_ADDRESS); // Get the BLuetoothDevice object BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); // Attempt to connect to the device mMessageService.connect(device);//from w w w .j av a 2 s . co m }
From source file:fi.iki.murgo.irssinotifier.SettingsActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode != ICB_HOST_REQUEST_CODE) { return;/*w ww . ja va 2 s . c o m*/ } Preferences prefs = new Preferences(this); if (data == null || resultCode != Activity.RESULT_OK) { prefs.setIcbHost(null, null); } else { String hostName = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); Intent intent = (Intent) data.getExtras().get(Intent.EXTRA_SHORTCUT_INTENT); if (intent != null) { String intentUri = intent.toUri(0); prefs.setIcbHost(hostName, intentUri); } else { prefs.setIcbHost(null, null); } } handleIcb(); }
From source file:com.example.android.naradaonline.DatagramFragment.java
/** * Establish connection with other divice * * @param data An {@link Intent} with {@link DeviceListActivity#EXTRA_DEVICE_ADDRESS} extra. * @param secure Socket Security type - Secure (true) , Insecure (false) */// www .ja v a2 s.c om 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:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticatorActivity.java
/** * Called when response is received from the server for confirm credentials request. See * onAuthenticationResult(). Sets the AccountAuthenticatorResult which is sent back to the * caller./*from w w w.j av a 2 s . c o m*/ * * @param the * confirmCredentials result. */ protected void finishConfirmCredentials(boolean result) { if (BuildConfig.DEBUG) { Log.i(TAG, "finishConfirmCredentials()"); } final Account account = createAccount(mUsername); mAccountManager.setPassword(account, mPassword); final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_BOOLEAN_RESULT, result); setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); finish(); }