List of usage examples for android.net Uri toString
public abstract String toString();
From source file:org.quizpoll.net.ImageDownloadHelper.java
@Override public HttpUriRequest createRequest() { Uri url = Uri.parse((String) requestData); return new HttpGet(url.toString()); }
From source file:WebviewFallback.java
@Override public void openUri(Activity activity, Uri uri) { Intent intent = new Intent(activity, WebViewActivity.class); intent.putExtra(WebViewActivity.EXTRA_URL, uri.toString()); activity.startActivity(intent);// w w w.j ava2s.co m }
From source file:Main.java
@SuppressLint("NewApi") public static Bitmap decodeSampledBitmap(Uri uri, int reqWidth, int reqHeight, Activity act) { // First decode with inJustDecodeBounds=true to check dimensions InputStream is;//from w w w . j a v a2s . c o m try { is = act.getApplicationContext().getContentResolver().openInputStream(uri); final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeStream(is, null, options); is.close(); //consider use is.mark and is.reset instead [TODO] // Calculate inSampleSize options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight); // Decode bitmap with inSampleSize set //open input stream again is = act.getApplicationContext().getContentResolver().openInputStream(uri); options.inJustDecodeBounds = false; Bitmap ret = BitmapFactory.decodeStream(is, null, options); is.close(); return ret; } catch (FileNotFoundException e) { Log.v(TAG, "File not found:" + uri.toString()); e.printStackTrace(); } catch (IOException e) { Log.v(TAG, "I/O exception with file:" + uri.toString()); e.printStackTrace(); } return null; }
From source file:com.eyekabob.VenueList.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.adlistactivity); adapter = new VenueListAdapter(getApplicationContext()); Uri uri = this.getIntent().getData(); new RequestTask().execute(uri.toString()); ListView lv = (ListView) findViewById(R.id.adList); lv.setAdapter(adapter);// w w w.j a va 2 s .com lv.setOnItemClickListener(listItemListener); }
From source file:com.remobile.file.Filesystem.java
public static JSONObject makeEntryForURL(LocalFilesystemURL inputURL, Uri nativeURL) { try {/*from ww w . j a v a 2 s . c om*/ String path = inputURL.path; int end = path.endsWith("/") ? 1 : 0; String[] parts = path.substring(0, path.length() - end).split("/+"); String fileName = parts[parts.length - 1]; JSONObject entry = new JSONObject(); entry.put("isFile", !inputURL.isDirectory); entry.put("isDirectory", inputURL.isDirectory); entry.put("name", fileName); entry.put("fullPath", path); // The file system can't be specified, as it would lead to an infinite loop, // but the filesystem name can be. entry.put("filesystemName", inputURL.fsName); // Backwards compatibility entry.put("filesystem", "temporary".equals(inputURL.fsName) ? 0 : 1); String nativeUrlStr = nativeURL.toString(); if (inputURL.isDirectory && !nativeUrlStr.endsWith("/")) { nativeUrlStr += "/"; } entry.put("nativeURL", nativeUrlStr); return entry; } catch (JSONException e) { e.printStackTrace(); throw new RuntimeException(e); } }
From source file:mobisocial.musubi.objects.PictureObj.java
public static MemObj from(Context context, Uri imageUri, boolean referenceOrig, String text) throws IOException { // Query gallery for camera picture via // Android ContentResolver interface ContentResolver cr = context.getContentResolver(); UriImage image = new UriImage(context, imageUri); byte[] data = image.getResizedImageData(MAX_IMAGE_WIDTH, MAX_IMAGE_HEIGHT, MAX_IMAGE_SIZE); JSONObject base = new JSONObject(); // Maintain a reference to original file try {//from w ww . j a v a 2 s.co m String type = cr.getType(imageUri); if (type == null) { type = "image/jpeg"; } if (text != null && !text.isEmpty()) { base.put(TEXT, text); } base.put(CorralDownloadClient.OBJ_MIME_TYPE, type); if (referenceOrig) { base.put(CorralDownloadClient.OBJ_LOCAL_URI, imageUri.toString()); String localIp = ContentCorral.getLocalIpAddress(); // TODO: Share IP if allowed for the given feed if (localIp != null && MusubiBaseActivity.isDeveloperModeEnabled(context)) { base.put(DbContactAttributes.ATTR_LAN_IP, localIp); } } } catch (JSONException e) { Log.e(TAG, "impossible json error possible!"); } return new MemObj(TYPE, base, data); }
From source file:com.tomgibara.android.veecheck.VeecheckThread.java
/** * Constructs a new {@link Thread} that will check the specified URI for application updates on behalf of a * {@link VeecheckService}.// w ww . j a v a 2 s . c o m * * @param service the service requesting the check * @param uri the http URI from which to obtain the versions document */ public VeecheckThread(VeecheckService service, Uri uri) { this.service = service; this.uri = uri.toString(); }
From source file:net.peterkuterna.android.apps.devoxxfrsched.service.TwitterSearchService.java
@Override protected void doSync(Intent intent) throws Exception { Log.d(TAG, "Refreshing twitter results"); final Cursor c = mResolver.query(Tweets.CONTENT_URI, TweetsQuery.PROJECTION, null, null, null); String tweetId = "0"; try {// ww w . j a v a 2 s . c o m if (c.moveToFirst()) { tweetId = c.getString(TweetsQuery.MAX_TWEET_ID); } } finally { c.close(); } final Uri uri = TwitterApiUriUtils.buildTwitterSearchUri("#devoxxfr +exclude:retweets", tweetId); mRemoteExecutor.executeGet(uri.toString(), new TwitterSearchHandler()); }
From source file:com.eyekabob.ArtistList.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.adlistactivity); adapter = new ArtistListAdapter(getApplicationContext()); ListView lv = (ListView) findViewById(R.id.adList); lv.setAdapter(adapter);/*from ww w . j ava 2s.co m*/ lv.setOnItemClickListener(listItemListener); String artist = getIntent().getExtras().getString("artist"); if (artist != null) { artist = artist.trim(); } // Send last.fm request. Map<String, String> lastFMParams = new HashMap<String, String>(); lastFMParams.put("artist", artist); Uri lastFMUri = EyekabobHelper.LastFM.getUri("artist.search", lastFMParams); new LastFMRequestTask().execute(lastFMUri.toString()); }
From source file:net.peterkuterna.android.apps.devoxxfrsched.service.NewsSyncService.java
@Override protected void doSync(Intent intent) throws Exception { Log.d(TAG, "Refreshing DevoxxFr twitter results"); boolean noNotifications = intent.getBooleanExtra(EXTRA_NO_NOTIFICATIONS, false); final Cursor c = mResolver.query(News.CONTENT_URI, NewsQuery.PROJECTION, null, null, null); String newsId = "0"; try {/* w ww . j av a2s . co m*/ if (c.moveToFirst()) { newsId = c.getString(NewsQuery.MAX_NEWS_ID); } } finally { c.close(); } final Uri uri = TwitterApiUriUtils.buildTwitterSearchUri("from:DevoxxFr +exclude:retweets", newsId); mRemoteExecutor.executeGet(uri.toString(), new NewsHandler(noNotifications)); final NotifierManager notifierManager = new NotifierManager(this); notifierManager.notifyNewNewsItems(); Log.d(TAG, "News sync finished"); }