List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:com.futureplatforms.kirin.extensions.localnotifications.LocalNotificationsBackend.java
public void showNotification(Bundle settings, Intent intent) { Uri uri = intent.getData(); int uriCode = URI_MATCHER.match(uri); if (uriCode != C.REQUEST_CODE_LOCALNOTIFICATION) { Log.w(C.TAG, "Notification with invalid uri: " + uri); return;// ww w . j av a 2 s .c o m } String idString = uri.getLastPathSegment(); if (idString == null) { Log.w(C.TAG, "Just got a notification with no data"); return; } Log.i(C.TAG, "LocalNotificationsBackend.showNotification: " + settings + " keys: " + settings.keySet()); String key = PREFS_PREFIX + idString; JSONObject obj = getJSONNotificationObject(key); if (obj == null) { // return; obj = new JSONObject(); try { obj.put("vibrate", false); obj.put("sound", false); obj.put("title", "A test notification"); obj.put("body", "New job: fix Mr. Gluck's hazy TV, PDQ!"); obj.put("id", 42); obj.put("timeMillisSince1970", System.currentTimeMillis()); } catch (JSONException e) { Log.e(C.TAG, "Erm not thought possible"); } } Notification n = createNotification(settings, obj); if (n != null) { NotificationManager nm = (NotificationManager) mContext.getSystemService(Service.NOTIFICATION_SERVICE); nm.notify(NOTIFICATION_MASK | obj.optInt("id"), n); } mPrefs.edit().remove(key).commit(); }
From source file:au.id.micolous.frogjump.LoginActivity.java
private boolean resolveIntent(Intent intent) { if (intent.getAction().equals(Intent.ACTION_VIEW)) { final Uri intentUri = intent.getData(); if (intentUri.getHost().endsWith("frjmp.xyz")) { // Known host, figure out our action! List<String> pathSegments = intentUri.getPathSegments(); if (pathSegments.get(0).equalsIgnoreCase("g")) { // Join Group (G) // Parameter 1 is the group number, prefill the box with it. // Make sure it is a number int group_id; try { group_id = Integer.valueOf(pathSegments.get(1)); } catch (NumberFormatException ex) { return false; }// www . ja va 2s . com // Now set the text field txtGroupId.setText(String.format("%1$09d", group_id)); // Make sure futures are set to auto-join auto_join = true; } } } return false; }
From source file:com.gelecekonline.android.uploadornek.MainActivity.java
/** * Secilen resim bu methoda gelir//w w w . ja v a 2 s. c om */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { Uri selectedImageUri = data.getData(); String filePath = null; try { String fileManagerString = selectedImageUri.getPath(); String selectedImagePath = getPath(selectedImageUri); if (selectedImagePath != null) { filePath = selectedImagePath; } else if (fileManagerString != null) { filePath = fileManagerString; } else { Toast.makeText(getApplicationContext(), getString(R.string.unknown_path), Toast.LENGTH_LONG) .show(); } if (filePath != null) { decodeFile(filePath); dosyaAdi = FilenameUtils.getName(filePath); } else { bitmap = null; } } catch (Exception e) { Toast.makeText(getApplicationContext(), getString(R.string.internal_error), Toast.LENGTH_LONG) .show(); Log.e(e.getClass().getName(), e.getMessage(), e); } } }
From source file:com.wodify.cordova.plugin.filepicker.FilePicker.java
/** * Gets and returns data about the picked file. * * @param intent//from w w w . jav a 2 s . c om * An Intent, which can return result data to the caller (various * data can be attached to Intent "extras"). */ private void processResult(Intent intent) { Uri uri = intent.getData(); if (uri == null) { this.failFile("null data from photo library"); return; } String fileLocation = FileHelper.getRealPath(uri, this.cordova); if (fileLocation == null || fileLocation.length() == 0) { if (returnFileWithDetails) { sendOrFailFileDetails(getFileDetails(uri)); } else { this.callbackContext.success(uri.toString()); } } else { if (returnFileWithDetails) { sendOrFailFileDetails(getFileDetails(fileLocation)); } else { this.callbackContext.success(fileLocation); } } }
From source file:net.nym.mutils.ui.test.TestWebViewActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == FILE_CHOOSER_RESULT_CODE) { //webView if (mUploadMessage != null) { Uri result = data == null ? null : data.getData(); mUploadMessage.onReceiveValue(result); mUploadMessage = null;/*from w w w . ja v a 2 s. co m*/ } } }
From source file:at.tomtasche.reader.ui.activity.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ?//ww w . j a v a 2 s . c om if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { if (savedInstanceState != null) { lastPosition = savedInstanceState.getInt(EXTRA_TAB_POSITION); } addLoadingListener(this); Intent intent = getIntent(); if (intent != null) { if (intent.getData() != null) { loadUri(intent.getData()); } } } }
From source file:ca.uwaterloo.magic.goodhikes.ProfileActivity.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_CANCELED) return;//w w w. ja v a 2 s . c o m if (requestCode == FROM_GALLERY) if (resultCode == RESULT_OK) { Uri selectedImage = data.getData(); profile_image.setImageURI(selectedImage); try { /* uri -> bitmap -> encoded string * store string in sharedpreference */ image = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImage); ByteArrayOutputStream byte_out = new ByteArrayOutputStream(); image.compress(Bitmap.CompressFormat.JPEG, 90, byte_out); //image is the bitmap object image = Bitmap.createScaledBitmap(image, 640, 480, false); byte[] byte_arr = byte_out.toByteArray(); String encoded = Base64.encodeToString(byte_arr, Base64.DEFAULT); Log.d(LOG_TAG, "encoded string length: " + encoded.length()); String input = "uid="; input += URLEncoder.encode(user.getId(), "UTF-8"); input += "&image_str="; input += URLEncoder.encode(encoded, "UTF-8"); new SyncImage().execute(input); userManager.setImage(encoded); //Log.d(LOG_TAG, "set image str: " + userManager.getImage()); } catch (Exception e) { Log.d(LOG_TAG, e.getMessage()); } } }
From source file:com.facebook.android.GraphExplorer.java
protected void processIntent(Intent incomingIntent) { Uri intentUri = incomingIntent.getData(); if (intentUri == null) { return;//from www. jav a 2 s .co m } String objectID = intentUri.getHost(); mInputId.setText(objectID); mSubmitButton.performClick(); }
From source file:com.amytech.android.library.views.imagechooser.api.ImageChooserManager.java
@SuppressLint("NewApi") private void processImageFromGallery(Intent data) { if (data != null && data.getDataString() != null) { String uri = data.getData().toString(); sanitizeURI(uri);//from w w w.j a v a 2s .c o m if (filePathOriginal == null || TextUtils.isEmpty(filePathOriginal)) { onError("File path was null"); } else { if (BuildConfig.DEBUG) { Log.i(TAG, "File: " + filePathOriginal); } String path = filePathOriginal; ImageProcessorThread thread = new ImageProcessorThread(path, foldername, shouldCreateThumbnails); thread.setListener(this); thread.setContext(getContext()); thread.start(); } } else { onError("Image Uri was null!"); } }
From source file:com.sip.pwc.sipphone.service.Downloader.java
@Override protected void onHandleIntent(Intent intent) { HttpGet getMethod = new HttpGet(intent.getData().toString()); int result = Activity.RESULT_CANCELED; String outPath = intent.getStringExtra(EXTRA_OUTPATH); boolean checkMd5 = intent.getBooleanExtra(EXTRA_CHECK_MD5, false); int icon = intent.getIntExtra(EXTRA_ICON, 0); String title = intent.getStringExtra(EXTRA_TITLE); boolean showNotif = (icon > 0 && !TextUtils.isEmpty(title)); // Build notification Builder nb = new Builder(this); nb.setWhen(System.currentTimeMillis()); nb.setContentTitle(title);// w ww. j ava 2s. co m nb.setSmallIcon(android.R.drawable.stat_sys_download); nb.setOngoing(true); Intent i = new Intent(this, SipHome.class); nb.setContentIntent(PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT)); RemoteViews contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.download_notif); contentView.setImageViewResource(R.id.status_icon, icon); contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.downloading_text)); contentView.setProgressBar(R.id.status_progress, 50, 0, false); contentView.setViewVisibility(R.id.status_progress_wrapper, View.VISIBLE); nb.setContent(contentView); final Notification notification = showNotif ? nb.build() : null; notification.contentView = contentView; if (!TextUtils.isEmpty(outPath)) { try { File output = new File(outPath); if (output.exists()) { output.delete(); } if (notification != null) { notificationManager.notify(NOTIF_DOWNLOAD, notification); } ResponseHandler<Boolean> responseHandler = new FileStreamResponseHandler(output, new Progress() { private int oldState = 0; @Override public void run(long progress, long total) { //Log.d(THIS_FILE, "Progress is "+progress+" on "+total); int newState = (int) Math.round(progress * 50.0f / total); if (oldState != newState) { notification.contentView.setProgressBar(R.id.status_progress, 50, newState, false); notificationManager.notify(NOTIF_DOWNLOAD, notification); oldState = newState; } } }); boolean hasReply = client.execute(getMethod, responseHandler); if (hasReply) { if (checkMd5) { URL url = new URL(intent.getData().toString().concat(".md5sum")); InputStream content = (InputStream) url.getContent(); if (content != null) { BufferedReader br = new BufferedReader(new InputStreamReader(content)); String downloadedMD5 = ""; try { downloadedMD5 = br.readLine().split(" ")[0]; } catch (NullPointerException e) { throw new IOException("md5_verification : no sum on server"); } if (!MD5.checkMD5(downloadedMD5, output)) { throw new IOException("md5_verification : incorrect"); } } } PendingIntent pendingIntent = (PendingIntent) intent .getParcelableExtra(EXTRA_PENDING_FINISH_INTENT); try { Runtime.getRuntime().exec("chmod 644 " + outPath); } catch (IOException e) { Log.e(THIS_FILE, "Unable to make the apk file readable", e); } Log.d(THIS_FILE, "Download finished of : " + outPath); if (pendingIntent != null) { notification.contentIntent = pendingIntent; notification.flags = Notification.FLAG_AUTO_CANCEL; notification.icon = android.R.drawable.stat_sys_download_done; notification.contentView.setViewVisibility(R.id.status_progress_wrapper, View.GONE); notification.contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.done) // TODO should be a parameter of this class + " - Click to install"); notificationManager.notify(NOTIF_DOWNLOAD, notification); /* try { pendingIntent.send(); notificationManager.cancel(NOTIF_DOWNLOAD); } catch (CanceledException e) { Log.e(THIS_FILE, "Impossible to start pending intent for download finish"); } */ } else { Log.w(THIS_FILE, "Invalid pending intent for finish !!!"); } result = Activity.RESULT_OK; } } catch (IOException e) { Log.e(THIS_FILE, "Exception in download", e); } } if (result == Activity.RESULT_CANCELED) { notificationManager.cancel(NOTIF_DOWNLOAD); } }