List of usage examples for android.net Uri toString
public abstract String toString();
From source file:com.MustacheMonitor.MustacheMonitor.StacheCam.java
/** * Cleans up after picture taking. Checking for duplicates and that kind of stuff. * @param newImage/*from w w w. ja v a2 s . c o m*/ */ private void cleanup(int imageType, Uri oldImage, Uri newImage, Bitmap bitmap) { if (bitmap != null) { bitmap.recycle(); } // Clean up initial camera-written image file. (new File(FileUtils.stripFileProtocol(oldImage.toString()))).delete(); checkForDuplicateImage(imageType); // Scan for the gallery to update pic refs in gallery if (this.saveToPhotoAlbum && newImage != null) { this.scanForGallery(newImage); } System.gc(); }
From source file:in.shick.diode.submit.SubmitLinkActivity.java
private boolean lastDitchExtractProperties(Bundle extras, SubmissionProperties properties) { if (extras != null) { // find the most likely submission URL since some // programs share more than the URL // the most likely is considered to be the longest // string token with a URI scheme of http or https StringBuilder titleBuilder = new StringBuilder(); String rawText = extras.getString(Intent.EXTRA_TEXT); StringTokenizer extraTextTokenizer = new StringTokenizer(rawText); Uri bestUri = Uri.parse(""); while (extraTextTokenizer.hasMoreTokens()) { Uri uri = Uri.parse(extraTextTokenizer.nextToken()); if (!"http".equalsIgnoreCase(uri.getScheme()) && !"https".equalsIgnoreCase(uri.getScheme())) { titleBuilder.append(uri.toString()).append(' '); continue; }//from w w w .j av a 2s .com if (uri.toString().length() > bestUri.toString().length()) { bestUri = uri; } } properties = new SubmissionProperties(); properties.url = bestUri.toString(); properties.title = titleBuilder.toString(); return true; } return false; }
From source file:git.egatuts.nxtremotecontroller.fragment.OnlineControllerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { final OnlineControllerFragment self = this; this.progressDialog = this.getShortProgressDialog(); View view;//from w ww . j a va2s . com Button button; if (!this.getWifiManager().isWifiEnabled()) { view = inflater.inflate(R.layout.online_error_layout, parent, false); button = (Button) view.findViewById(R.id.redo_action); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { self.refreshFragment(); } }); return view; } view = inflater.inflate(R.layout.online_layout, parent, false); this.recyclerView = (RecyclerView) view.findViewById(R.id.clients); this.actionsView = (RelativeLayout) view.findViewById(R.id.actions); this.initStreamingView = (Button) view.findViewById(R.id.init_streaming); this.initStreamingView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url = self.getPreferencesEditor().getString("preference_server_peer", self.getString(R.string.preference_value_peer)); Uri uri = Uri.parse(url).buildUpon().appendQueryParameter("from", GlobalUtils.md5(self.token)) .appendQueryParameter("to", self.calling).build(); self.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri.toString()))); self.socket.emit("init_stream", self.calling); } }); this.stopStreamingView = (Button) view.findViewById(R.id.stop_streaming); this.stopStreamingView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { self.socket.emit("stop_stream", self.calling); self.calling = ""; self.controlledBy = null; self.hideActions(); } }); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this.getBaseActivity()); linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); linearLayoutManager.scrollToPosition(0); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator()); this.clientsAdapter = new ClientAdapter(this, new ArrayList<Client>() { { add(new Client(null, null, null, "Ejemplo", "ejemplo@gmail.com", 41.2133293d, 1.5253539d, "El Vendrell, Catalua", "El Vendrell, Tarragona, Catalua, Espaa")); } }); this.clientsAdapter.setOnClickListener(new ClientAdapter.OnClickListener() { @Override public void onClick(ClientViewHolder view, int index) { Client client = self.clientsAdapter.get(index); if (client.getPeerId() != null && !client.getPeerId().equals("")) self.requestCall(client, view, index); } }); recyclerView.setAdapter(this.clientsAdapter); return view; }
From source file:com.cranberrygame.phonegap.plugin.Util.java
private void _getPlayerImage() { Player player = Games.Players.getCurrentPlayer(getGameHelper().getApiClient()); if (player != null) { boolean hasH = player.hasHiResImage(); boolean hasI = player.hasIconImage(); Uri playerImageUrl = null; if (hasH) { playerImageUrl = player.getHiResImageUri(); } else if (hasI) { playerImageUrl = player.getIconImageUri(); }/*from w ww.jav a 2 s.c om*/ PluginResult pr = new PluginResult(PluginResult.Status.OK, playerImageUrl.toString()); //pr.setKeepCallback(true); getPlayerImageCC.sendPluginResult(pr); //PluginResult pr = new PluginResult(PluginResult.Status.ERROR); //pr.setKeepCallback(true); //getPlayerImageCC.sendPluginResult(pr); } else { //PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); //getPlayerImageCC.sendPluginResult(pr); PluginResult pr = new PluginResult(PluginResult.Status.ERROR); //pr.setKeepCallback(true); getPlayerImageCC.sendPluginResult(pr); } }
From source file:com.box.androidlib.BoxSynchronous.java
/** * Executes an Http request and triggers response parsing by the specified parser. * /*w w w . jav a 2 s . co m*/ * @param parser * A BoxResponseParser configured to consume the response and capture data that is of interest * @param uri * The Uri of the request * @throws IOException * Can be thrown if there is no connection, or if some other connection problem exists. */ protected static void saxRequest(final DefaultResponseParser parser, final Uri uri) throws IOException { Uri theUri = uri; List<BasicNameValuePair> customQueryParams = BoxConfig.getInstance().getCustomQueryParameters(); if (customQueryParams != null && customQueryParams.size() > 0) { Uri.Builder builder = theUri.buildUpon(); for (BasicNameValuePair param : customQueryParams) { builder.appendQueryParameter(param.getName(), param.getValue()); } theUri = builder.build(); } try { final XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); xmlReader.setContentHandler(parser); HttpURLConnection conn = (HttpURLConnection) (new URL(theUri.toString())).openConnection(); conn.setRequestProperty("User-Agent", BoxConfig.getInstance().getUserAgent()); conn.setRequestProperty("Accept-Language", BoxConfig.getInstance().getAcceptLanguage()); conn.setConnectTimeout(BoxConfig.getInstance().getConnectionTimeOut()); if (mLoggingEnabled) { DevUtils.logcat("URL: " + theUri.toString()); // Iterator<String> keys = conn.getRequestProperties().keySet().iterator(); // while (keys.hasNext()) { // String key = keys.next(); // DevUtils.logcat("Request Header: " + key + " => " + conn.getRequestProperties().get(key)); // } } int responseCode = -1; try { conn.connect(); responseCode = conn.getResponseCode(); if (mLoggingEnabled) DevUtils.logcat("Response Code: " + responseCode); if (responseCode == HttpURLConnection.HTTP_OK) { InputStream inputStream = conn.getInputStream(); xmlReader.parse(new InputSource(inputStream)); inputStream.close(); } else if (responseCode == -1) { parser.setStatus(ResponseListener.STATUS_UNKNOWN_HTTP_RESPONSE_CODE); } } catch (IOException e) { try { responseCode = conn.getResponseCode(); } catch (NullPointerException ee) { // Honeycomb devices seem to throw a null pointer exception sometimes which traces to HttpURLConnectionImpl. } // Server returned a 503 Service Unavailable. Usually means a temporary unavailability. if (responseCode == HttpURLConnection.HTTP_UNAVAILABLE) { parser.setStatus(ResponseListener.STATUS_SERVICE_UNAVAILABLE); } else { throw e; } } finally { conn.disconnect(); } } catch (final ParserConfigurationException e) { e.printStackTrace(); } catch (final SAXException e) { e.printStackTrace(); } catch (final FactoryConfigurationError e) { e.printStackTrace(); } }
From source file:com.hackensack.umc.activity.ProfileActivity.java
private void setImageToImageView(Uri imageUri) { switch (selectedImageView) { case 1:/*from w w w .ja va 2s .c o m*/ pathDlFront = Base64Converter.createBase64StringFroImage(imageUri.toString(), ProfileActivity.this); uriDlFront = imageUri; CameraFunctionality.storeImagesInFolder(uriDlFront.toString(), ProfileActivity.this); // PhotoList.DlFront=pathDlFront; break; case 2: pathDlBack = Base64Converter.createBase64StringFroImage(imageUri.toString(), ProfileActivity.this); uriDlback = imageUri; break; case 3: pathIcFront = Base64Converter.createBase64StringFroImage(imageUri.toString(), ProfileActivity.this); uriIcFront = imageUri; break; case 4: pathIcBack = Base64Converter.createBase64StringFroImage(imageUri.toString(), ProfileActivity.this); uriIcBack = imageUri; break; case 5: pathSelfie = Base64Converter.createBase64StringFroImage(imageUri.toString(), ProfileActivity.this); uriSelfie = imageUri; break; } setPhotoToImageView(imageUri.toString(), mImageView); }
From source file:com.ximai.savingsmore.save.activity.BusinessMyCenterActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); if (resultCode != RESULT_OK) { return;//from w ww. ja va2s .c o m } else if (requestCode == PICK_FROM_CAMERA || requestCode == PICK_FROM_IMAGE) { Uri uri = null; if (null != intent && intent.getData() != null) { uri = intent.getData(); } else { String fileName = PreferencesUtils.getString(this, "tempName"); uri = Uri.fromFile(new File(FileSystem.getCachesDir(this, true).getAbsolutePath(), fileName)); } if (uri != null) { cropImage(uri, CROP_PHOTO_CODE); } } else if (requestCode == CROP_PHOTO_CODE) { Uri photoUri = intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT); if (isslinece) { MyImageLoader.displayDefaultImage("file://" + photoUri.getPath(), slience_image); zhizhao_path = photoUri.toString(); try { upLoadImage(new File((new URI(photoUri.toString()))), "BusinessLicense"); } catch (URISyntaxException e) { e.printStackTrace(); } } else if (isZhengshu) { MyImageLoader.displayDefaultImage("file://" + photoUri.getPath(), zhengshu_iamge); xukezheng_path = photoUri.toString(); try { upLoadImage(new File((new URI(photoUri.toString()))), "LicenseKey"); } catch (URISyntaxException e) { e.printStackTrace(); } } else if (isheadImage) { MyImageLoader.displayDefaultImage("file://" + photoUri.getPath(), head_image); tuoxiang_path = photoUri.toString(); try { upLoadImage(new File((new URI(photoUri.toString()))), "Photo"); } catch (URISyntaxException e) { e.printStackTrace(); } //upLoadImage(new File((new URI(photoUri.toString()))), "Photo"); } else if (isItem) { if (imagePath.size() + images.size() < 10) { shangpu_path.add(photoUri.toString()); try { upLoadImage(new File((new URI(photoUri.toString()))), "Seller"); } catch (URISyntaxException e) { e.printStackTrace(); } //imagePath.add(photoUri.getPath()); } else { Toast.makeText(BusinessMyCenterActivity.this, "?9", Toast.LENGTH_SHORT).show(); } } //addImage(imagePath); } }
From source file:com.github.gorbin.asne.linkedin.LinkedInSocialNetwork.java
/** * Overrided for LinkedIn support/*from w ww . j a v a2 s . c om*/ * @param requestCode The integer request code originally supplied to startActivityForResult(), allowing you to identify who this result came from. * @param resultCode The integer result code returned by the child activity through its setResult(). * @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras"). */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { int sanitizedRequestCode = requestCode & 0xFFFF; if (sanitizedRequestCode != REQUEST_AUTH) return; super.onActivityResult(requestCode, resultCode, data); Uri uri = data != null ? data.getData() : null; if (uri != null && uri.toString().startsWith(mRedirectURL.toLowerCase())) { String parts[] = uri.toString().split("="); String verifier = parts[1]; verifier = verifier.substring(0, verifier.indexOf("&")); RequestLogin2AsyncTask requestLogin2AsyncTask = new RequestLogin2AsyncTask(); mRequests.put(REQUEST_LOGIN2, requestLogin2AsyncTask); Bundle args = new Bundle(); args.putString(RequestLogin2AsyncTask.PARAM_VERIFIER, verifier); requestLogin2AsyncTask.execute(args); } else { if (mLocalListeners.get(REQUEST_LOGIN) != null) { mLocalListeners.get(REQUEST_LOGIN).onError(getID(), REQUEST_LOGIN, "incorrect URI returned: " + uri, null); mLocalListeners.remove(REQUEST_LOGIN); } } }
From source file:com.jimandreas.popularmovies.FetchMovieListTask.java
@Override protected Void doInBackground(String... params) { // If there's no zip code, there's nothing to look up. Verify size of params. if (params.length == 0) { return null; }// w w w .jav a 2 s . com String whatToDo = params[0]; String arg = params[1]; String fetch_string; if (whatToDo.contains(FETCH_POPULAR)) { fetch_string = "http://api.themoviedb.org/3/movie/popular?page=" + arg; } else if (whatToDo.contains(FETCH_TOP_RATED)) { fetch_string = "http://api.themoviedb.org/3/movie/top_rated?page=" + arg; } else if (whatToDo.contains(FETCH_POPULAR_MOVIE_DETAILS) || whatToDo.contains(FETCH_TOP_RATED_MOVIE_DETAILS)) { fetch_string = "http://api.themoviedb.org/3/movie/" + arg + "?&append_to_response=trailers,reviews"; } else { throw new RuntimeException(LOG_TAG + "Impossible task here"); } final String APPID = "api_key"; final String THE_MOVIE_DATABASE_API_KEY = BuildConfig.THE_MOVIE_DATABASE_API_KEY; Uri builtUri = Uri.parse(fetch_string).buildUpon().appendQueryParameter(APPID, THE_MOVIE_DATABASE_API_KEY) .build(); Timber.i("fetching URL: " + fetch_string); // These two need to be declared outside the try/catch // so that they can be closed in the finally block. HttpURLConnection urlConnection = null; BufferedReader reader = null; // Will contain the raw JSON response as a string. String movieJsonStr = null; try { URL url = new URL(builtUri.toString()); // Create the request to TheMovieDb, and open the connection urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setRequestMethod("GET"); urlConnection.connect(); // Read the input stream into a String InputStream inputStream = urlConnection.getInputStream(); StringBuffer buffer = new StringBuffer(); if (inputStream == null) { // Nothing to do. return null; } reader = new BufferedReader(new InputStreamReader(inputStream)); String line; while ((line = reader.readLine()) != null) { // Since it's JSON, adding a newline isn't necessary (it won't affect parsing) // But it does make debugging a *lot* easier if you print out the completed // buffer for debugging. buffer.append(line + "\n"); } if (buffer.length() == 0) { // Stream was empty. No point in parsing. return null; } movieJsonStr = buffer.toString(); if (whatToDo.contains(FETCH_POPULAR_MOVIE_DETAILS) || whatToDo.contains(FETCH_TOP_RATED_MOVIE_DETAILS)) { getMovieDetailsFromJson(movieJsonStr, whatToDo); } else { getMovieListFromJson(movieJsonStr, whatToDo); } } catch (IOException e) { Timber.i("Error ", e); // If the code didn't successfully get the weather data, there's no point in attempting // to parse it. } catch (JSONException e) { Timber.i(e.getMessage(), e); e.printStackTrace(); } finally { if (urlConnection != null) { urlConnection.disconnect(); } if (reader != null) { try { reader.close(); } catch (final IOException e) { Timber.i("Error closing stream", e); } } } return null; }
From source file:com.cbtec.eliademy.EliademyLms.java
/** * Called when an activity you launched exits, giving you the requestCode * you started it with, the resultCode it returned, and any additional data * from it.//from ww w . j a v a 2 s. c o m * * @param requestCode * The request code originally supplied to * startActivityForResult(), allowing you to identify who this * result came from. * @param resultCode * The integer result code returned by the child activity through * its setResult(). * @param data * An Intent, which can return result data to the caller (various * data can be attached to Intent "extras"). */ @Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { switch (requestCode) { case submitFileCode: if (resultCode == Activity.RESULT_OK) { Uri uri = intent.getData(); if (uri.getScheme().toString().compareTo("content") == 0) { Cursor cursor = cordova.getActivity().getApplicationContext().getContentResolver().query(uri, null, null, null, null); if (cursor.moveToFirst()) { int column_index = cursor.getColumnIndexOrThrow(MediaColumns.DATA); uri = Uri.parse(cursor.getString(column_index)); } } if (this.mCallbackContext != null) { this.mCallbackContext.success(uri.toString()); return; } else { Log.i("HLMS", "callback context is null"); } } break; } if (this.mCallbackContext != null) { this.mCallbackContext.error(resultCode); } else { Log.i("HLMS", "callback context is null"); } }