List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:com.spoiledmilk.ibikecph.favorites.EditFavoriteFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (data != null) { Bundle b = data.getExtras(); if (b.containsKey("address") && b.containsKey("lat") && b.containsKey("lon")) { favoritesData.setAdress(AddressParser.textFromBundle(b).replaceAll("\n", "")); favoritesData.setLatitude(b.getDouble("lat")); favoritesData.setLongitude(b.getDouble("lon")); String txt = favoritesData.getAdress(); textAddress.setText(txt);/* www .j av a2 s . co m*/ if (b.containsKey("poi")) { favoritesData.setName(b.getString("poi")); } } } }
From source file:cz.zcu.kiv.eeg.mobile.base.ui.scenario.ScenarioAddActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { //obtaining file selected in FileChooserActivity case (Values.SELECT_FILE_FLAG): { if (resultCode == Activity.RESULT_OK) { selectedFile = data.getExtras().getString(Values.FILE_PATH); selectedFileLength = data.getExtras().getLong(Values.FILE_LENGTH); TextView selectedFileView = (TextView) findViewById(R.id.fchooserSelectedFile); EditText mimeView = (EditText) findViewById(R.id.scenario_mime_value); TextView fileSizeView = (TextView) findViewById(R.id.scenario_file_size_value); FileSystemResource file = new FileSystemResource(selectedFile); selectedFileView.setText(file.getFilename()); mimeView.setText(FileUtils.getMimeType(selectedFile)); String fileSize = FileUtils.getFileSize(file.getFile().length()); fileSizeView.setText(fileSize); Toast.makeText(this, selectedFile, Toast.LENGTH_SHORT).show(); }/* w w w . ja v a 2s . c om*/ break; } } }
From source file:kookmin.cs.sympathymusiz.VideoListDemoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); receiveUrl = intent.getExtras().getString("url"); setContentView(R.layout.video_list_demo); listFragment = (VideoListFragment) getFragmentManager().findFragmentById(R.id.list_fragment); videoFragment = (VideoFragment) getFragmentManager().findFragmentById(R.id.video_fragment_container); videoBox = findViewById(R.id.video_box); closeButton = findViewById(R.id.close_button); videoBox.setVisibility(View.INVISIBLE); layout();/*from w w w .j a va 2 s.c o m*/ }
From source file:edu.stanford.junction.sample.partyware.ImgurUploadService.java
/** * //from w ww .j av a2s .c om * @return a map that contains objects with the following keys: * * delete - the url used to delete the uploaded image (null if * error). * * original - the url to the uploaded image (null if error) The map * is null if error */ private Map<String, String> handleSendIntent(final Intent intent) { Log.i(this.getClass().getName(), "in handleResponse()"); Log.d(this.getClass().getName(), intent.toString()); final Bundle extras = intent.getExtras(); try { //upload a new image if (Intent.ACTION_SEND.equals(intent.getAction()) && (extras != null) && extras.containsKey(Intent.EXTRA_STREAM)) { final Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM); if (uri != null) { Log.d(this.getClass().getName(), uri.toString()); imageLocation = uri; final String jsonOutput = readPictureDataAndUpload(uri); return parseJSONResponse(jsonOutput); } Log.e(this.getClass().getName(), "URI null"); } } catch (final Exception e) { Log.e(this.getClass().getName(), "Completely unexpected error", e); } return null; }
From source file:most.voip.example.remote_config.LoginActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Check which request we're responding to if (requestCode == REMOTE_ACCOUNT_CONFIG_REQUEST) { // Make sure the request was successful if (resultCode == RESULT_OK) { Intent resultIntent = new Intent(); Bundle b = new Bundle(); b.putString("account_data", data.getExtras().getString("account_data")); b.putString("buddies_data", data.getExtras().getString("buddies_data")); resultIntent.putExtras(b);/*from www. j a v a 2 s. com*/ // TODO Add extras or a data URI to this intent as appropriate. Log.d("VoipConfigDemo", "Configuration accepted"); setResult(Activity.RESULT_OK, resultIntent); finish(); } else { Log.d("VoipConfigDemo", "Account data NOT received from the activity"); } } else { Log.d("VoipConfigDemo", "Received unknown requestCode:" + String.valueOf(requestCode)); } }
From source file:com.antew.redditinpictures.library.service.RESTService.java
@Override protected void onHandleIntent(Intent intent) { Uri action = intent.getData();/*from w w w .ja v a 2 s. c o m*/ Bundle extras = intent.getExtras(); if (extras == null || action == null) { Ln.e("You did not pass extras or data with the Intent."); return; } // We default to GET if no verb was specified. int verb = extras.getInt(EXTRA_HTTP_VERB, GET); RequestCode requestCode = (RequestCode) extras.getSerializable(EXTRA_REQUEST_CODE); Bundle params = extras.getParcelable(EXTRA_PARAMS); String cookie = extras.getString(EXTRA_COOKIE); String userAgent = extras.getString(EXTRA_USER_AGENT); // Items in this bundle are simply passed on in onRequestComplete Bundle passThrough = extras.getBundle(EXTRA_PASS_THROUGH); HttpEntity responseEntity = null; Intent result = new Intent(Constants.Broadcast.BROADCAST_HTTP_FINISHED); result.putExtra(EXTRA_PASS_THROUGH, passThrough); Bundle resultData = new Bundle(); try { // Here we define our base request object which we will // send to our REST service via HttpClient. HttpRequestBase request = null; // Let's build our request based on the HTTP verb we were // given. switch (verb) { case GET: { request = new HttpGet(); attachUriWithQuery(request, action, params); } break; case DELETE: { request = new HttpDelete(); attachUriWithQuery(request, action, params); } break; case POST: { request = new HttpPost(); request.setURI(new URI(action.toString())); // Attach form entity if necessary. Note: some REST APIs // require you to POST JSON. This is easy to do, simply use // postRequest.setHeader('Content-Type', 'application/json') // and StringEntity instead. Same thing for the PUT case // below. HttpPost postRequest = (HttpPost) request; if (params != null) { UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params)); postRequest.setEntity(formEntity); } } break; case PUT: { request = new HttpPut(); request.setURI(new URI(action.toString())); // Attach form entity if necessary. HttpPut putRequest = (HttpPut) request; if (params != null) { UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params)); putRequest.setEntity(formEntity); } } break; } if (request != null) { DefaultHttpClient client = new DefaultHttpClient(); // GZip requests // antew on 3/12/2014 - Disabling GZIP for now, need to figure this CloseGuard error: // 03-12 21:02:09.248 9674-9683/com.antew.redditinpictures.pro E/StrictMode A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. // java.lang.Throwable: Explicit termination method 'end' not called // at dalvik.system.CloseGuard.open(CloseGuard.java:184) // at java.util.zip.Inflater.<init>(Inflater.java:82) // at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:96) // at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:81) // at com.antew.redditinpictures.library.service.RESTService$GzipDecompressingEntity.getContent(RESTService.java:346) client.addRequestInterceptor(getGzipRequestInterceptor()); client.addResponseInterceptor(getGzipResponseInterceptor()); if (cookie != null) { request.addHeader("Cookie", cookie); } if (userAgent != null) { request.addHeader("User-Agent", Constants.Reddit.USER_AGENT); } // Let's send some useful debug information so we can monitor things // in LogCat. Ln.d("Executing request: %s %s ", verbToString(verb), action.toString()); // Finally, we send our request using HTTP. This is the synchronous // long operation that we need to run on this thread. HttpResponse response = client.execute(request); responseEntity = response.getEntity(); StatusLine responseStatus = response.getStatusLine(); int statusCode = responseStatus != null ? responseStatus.getStatusCode() : 0; if (responseEntity != null) { resultData.putString(REST_RESULT, EntityUtils.toString(responseEntity)); resultData.putSerializable(EXTRA_REQUEST_CODE, requestCode); resultData.putInt(EXTRA_STATUS_CODE, statusCode); result.putExtra(EXTRA_BUNDLE, resultData); onRequestComplete(result); } else { onRequestFailed(result, statusCode); } } } catch (URISyntaxException e) { Ln.e(e, "URI syntax was incorrect. %s %s ", verbToString(verb), action.toString()); onRequestFailed(result, 0); } catch (UnsupportedEncodingException e) { Ln.e(e, "A UrlEncodedFormEntity was created with an unsupported encoding."); onRequestFailed(result, 0); } catch (ClientProtocolException e) { Ln.e(e, "There was a problem when sending the request."); onRequestFailed(result, 0); } catch (IOException e) { Ln.e(e, "There was a problem when sending the request."); onRequestFailed(result, 0); } finally { if (responseEntity != null) { try { responseEntity.consumeContent(); } catch (IOException ignored) { } } } }
From source file:com.safecell.AccountFormActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setWindowAnimations(R.anim.null_animation); context = AccountFormActivity.this; this.initUI(); profilesRepository = new ProfilesRepository(context); createAccountButton.setOnClickListener(createAccountButtonOnclickListenr); progressDialog = new ProgressDialog(context); licenseProgressDialog = new ProgressDialog(context); licenseThread = new LicenseThread(); Intent intent = getIntent(); Bundle bundle = intent.getExtras(); callingActivity = bundle.getString("from"); handler = new Handler() { @Override//w ww . j av a2s . c om public void handleMessage(Message msg) { // TODO Auto-generated method stub super.handleMessage(msg); licenseProgressDialog.dismiss(); if (licenseThread.isAlive()) { licenseThread.interrupt(); licenseThread = new LicenseThread(); } if (licensekeyString == null) { message = getLicenseKey.getFailureMessage(); UIUtils.OkDialog(context, message); return; } selectLicenseFromDialog(); } }; PackageManager pm = getPackageManager(); try { //---get the package info--- PackageInfo pi = pm.getPackageInfo("com.safecell", 0); //Log.v("Version Code", "Code = "+pi.versionCode); //Log.v("Version Name", "Name = "+pi.versionName); versionName = pi.versionName; } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } preferences = getSharedPreferences("AccountUniqueID", MODE_WORLD_WRITEABLE); preferences.getString("AccountUID", ""); createAccountUniqueID(SCProfile.newUniqueDeviceKey()); }
From source file:com.cs411.trackallthethings.Scan.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // show that we're doing shit bro gettingItem = ProgressDialog.show(scanContext, "", "Getting item...", true); // the scan string result String result = data.getExtras().getString("la.droid.qr.result"); Log.d("result: ", result); String[] resultSplit = result.split("\\|"); // the case where there is no item_id in the scan result if (resultSplit.length < 1) { gettingItem.dismiss();/* w w w. jav a2 s .c o m*/ return; } // get the item's information for (int i = 0; i < resultSplit.length; i++) { Log.d("resultSplit " + i, resultSplit[i]); } String item_id = resultSplit[resultSplit.length - 1]; Log.d("item_id: ", item_id); String responseString = ""; try { HttpGet httpget = new HttpGet( "http://www.trackallthethings.com/mobile-api/search_item?item_id=" + item_id); HttpResponse response; response = Main.httpclient.execute(httpget); HttpEntity entity = response.getEntity(); InputStream in = entity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuilder sb = new StringBuilder(); String input = null; try { while ((input = reader.readLine()) != null) { sb.append(input + "\n"); } } catch (IOException e) { e.printStackTrace(); } finally { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } //parse the response responseString = sb.toString(); in.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // if the response was bad if (responseString.equals("") || responseString.contains("INVALID QR SCAN")) { gettingItem.dismiss(); return; } // make the item try { JSONObject itemData = new JSONObject(responseString); scannedItem = new Item(itemData); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } // if the item was made properly, let's display its info if (scannedItem != null) { TextView scanItemInfo = (TextView) findViewById(R.id.scaniteminfo); scanItemInfo.setText(scannedItem.toString()); } gettingItem.dismiss(); }
From source file:com.example.parking.ParkingInformationActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (data != null) { switch (requestCode) { case TAKE_PHOTO: //? if (data.getData() != null || data.getExtras() != null) { // Uri uri = data.getData(); if (uri != null) { if (mEnterImage == null) { mEnterImage = BitmapFactory.decodeFile(uri.getPath()); // }//from ww w .ja v a 2 s . com } Bundle bundle = data.getExtras(); if (bundle != null) { if (mEnterImage == null) { mEnterImage = (Bitmap) bundle.get("data"); } } } if (mEnterImage != null) { mEnterImageIV.setImageBitmap(mEnterImage); } break; } } }
From source file:com.firescar96.nom.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()) /*//from ww w. ja v a 2s .co 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)) Log.i(Consts.TAG, "onHandleIntent: message error"); else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) Log.i(Consts.TAG, "onHandleIntent: message deleted"); // If it's a regular GCM message, do some work. else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // Post notification of received message. System.out.println("Received: " + extras.toString()); if (context == null) { System.out.println("null conxtext"); /*Intent needIntent = new Intent(this, MainActivity.class); needIntent.putExtra("purpose", "update"); needIntent.putExtra("mate", (String)extras.get("mate")); needIntent.putExtra("event", (String)extras.get("event")); needIntent.putExtra("chat", (String)extras.get("chat")); needIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(needIntent);*/ System.out.println(getFilesDir().getAbsolutePath()); MainActivity.initAppData(getFilesDir().getAbsolutePath()); } try { if (extras.get("mate") != null) { //context.appData.getJSONArray("mates").put(extras.get("mate")); } if (extras.get("event") != null) { JSONObject eveData = new JSONObject("{\"event\":" + extras.get("event") + "}") .getJSONObject("event"); JSONArray eve = MainActivity.appData.getJSONArray("events"); for (int i = 0; i < eve.length(); i++) { System.out.println(eveData.getString("hash")); System.out.println(eve.getJSONObject(i).getString("hash")); if (eveData.getString("hash").equals(eve.getJSONObject(i).getString("hash"))) return; } eveData.accumulate("member", false); System.out.println(eveData.getLong("date")); System.out.println(Calendar.getInstance().getTimeInMillis()); if (eveData.getLong("date") < Calendar.getInstance().getTimeInMillis()) return; eve.put(eveData); Message msg = new Message(); Bundle data = new Bundle(); data.putString("type", "event." + eveData.getString("privacy")); data.putString("host", eveData.getString("host")); data.putString("date", eveData.getString("date")); msg.setData(data); contextHandler.sendMessage(msg); } if (extras.get("chat") != null) { JSONObject chatData = new JSONObject("{\"chat\":" + extras.get("chat") + "}") .getJSONObject("chat"); JSONArray eve = MainActivity.appData.getJSONArray("events"); for (int i = 0; i < eve.length(); i++) if (chatData.getString("hash").equals(eve.getJSONObject(i).getString("hash"))) { JSONObject msgSon = new JSONObject(); msgSon.accumulate("author", chatData.getString("author")); msgSon.accumulate("message", chatData.getString("message")); eve.getJSONObject(i).getJSONArray("chat").put(msgSon); Message msg = new Message(); Bundle data = new Bundle(); data.putString("type", "chat"); data.putString("author", chatData.getString("author")); data.putString("message", chatData.getString("message")); data.putBoolean("member", eve.getJSONObject(i).getBoolean("member")); data.putString("hash", chatData.getString("hash")); msg.setData(data); contextHandler.sendMessage(msg); return; } } MainActivity.closeAppData(getFilesDir().getAbsolutePath()); } catch (JSONException e1) { e1.printStackTrace(); } } // Release the wake lock provided by the WakefulBroadcastReceiver. MainBroadcastReceiver.completeWakefulIntent(intent); }