List of usage examples for android.net Uri toString
public abstract String toString();
From source file:com.denimgroup.android.training.pandemobium.stocktrader.ManageTipsActivity.java
/** Called when the activity is first created. */ @Override//from w w w . ja v a 2s . c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.managetips); etSymbol = (EditText) findViewById(R.id.et_symbol); etTargetPrice = (EditText) findViewById(R.id.et_target_price); etReason = (EditText) findViewById(R.id.et_reason); btnSaveTip = (Button) findViewById(R.id.btn_save_tip); btnSaveTip.setOnClickListener(this); tvTipStatus = (TextView) findViewById(R.id.tv_tip_status); if (Intent.ACTION_MAIN.equals(getIntent().getAction())) { Log.d("ManageTipsActivity", "Action launched manually"); } else { Uri data = getIntent().getData(); if (data == null) { Log.i("ManageTipsActivity", "No data passed with intent"); } else { Uri tradeUri = getIntent().getData(); Log.i("ManageTipsActivity", "Intent launched with data: " + tradeUri.toString()); String symbol = tradeUri.getQueryParameter("symbol").toUpperCase(); // test ... //String target_price = tradeUri.getQueryParameter("target_price"); doSendTipData(symbol); } } }
From source file:de.devmil.muzei.bingimageofthedayartsource.cache.BingImageCache.java
private String getFileNameFromUri(Uri uri) { String fName = uri.toString(); for (Character c : ReservedChars) { fName = fName.replace(c, '_'); }/*from ww w.j a va2 s .c om*/ return fName; }
From source file:eu.alefzero.owncloud.authenticator.ConnectionCheckerRunnable.java
private boolean tryConnection(Uri uri) { WebdavClient wc = new WebdavClient(); wc.allowSelfsignedCertificates();//from w ww.j ava2s .com GetMethod get = new GetMethod(uri.toString()); boolean retval = false; try { int status = wc.executeMethod(get, TRY_CONNECTION_TIMEOUT); switch (status) { case HttpStatus.SC_OK: { String response = get.getResponseBodyAsString(); JSONObject json = new JSONObject(response); if (!json.getBoolean("installed")) { mLatestResult = ResultType.INSTANCE_NOT_CONFIGURED; break; } mOCVersion = new OwnCloudVersion(json.getString("version")); if (!mOCVersion.isVersionValid()) break; retval = true; break; } case HttpStatus.SC_NOT_FOUND: mLatestResult = ResultType.FILE_NOT_FOUND; break; case HttpStatus.SC_INTERNAL_SERVER_ERROR: mLatestResult = ResultType.INSTANCE_NOT_CONFIGURED; break; default: mLatestResult = ResultType.UNKNOWN_ERROR; Log.e(TAG, "Not handled status received from server: " + status); } } catch (Exception e) { if (e instanceof UnknownHostException || e instanceof ConnectException || e instanceof SocketTimeoutException) { mLatestResult = ResultType.HOST_NOT_AVAILABLE; } else if (e instanceof JSONException) { mLatestResult = ResultType.INSTANCE_NOT_CONFIGURED; } else if (e instanceof SSLHandshakeException) { mLatestResult = ResultType.SSL_INIT_ERROR; } else { mLatestResult = ResultType.UNKNOWN_ERROR; } e.printStackTrace(); } return retval; }
From source file:org.quizpoll.net.DocsHelper.java
@Override public HttpUriRequest createRequest() { Uri url; switch (messageType) { case MY_DOCUMENTS: // Own documents url = Uri.parse(PRIVATE_DOCLIST_URL); return addHeaders(new HttpGet(url.toString()), PrefType.AUTH_TOKEN_DOCS); }/*from w w w . j ava2 s .c o m*/ return null; }
From source file:com.xing.android.sdk.network.request.RequestUtilsTest.java
@Test public void appendSegmentToUri() throws Exception { // Assert that null will be returned assertNull(RequestUtils.appendSegmentToUri(null, null)); Uri referenceUri = new Uri.Builder().scheme("test").authority("test").build(); // Assert that uri wont be altered Uri uri = RequestUtils.appendSegmentToUri(referenceUri, null); assertEquals(referenceUri.toString(), uri.toString()); // Assert segment will be added uri = RequestUtils.appendSegmentToUri(referenceUri, "test"); assertEquals(referenceUri + "/test", uri.toString()); }
From source file:org.blanco.techmun.android.cproviders.TechMunContentProvider.java
private Cursor getComentariosCursorForUri(Uri uri, String selection) { String eventoId = extractGroupFromPattern(MESA_CONTENT_COMENTARIOS_PETITION_REG_EXP, uri.toString(), 1); //Extracting the pagina selection part String pagina = "0"; try {//from ww w .jav a 2s . co m pagina = extractGroupFromPattern("pagina=(\\d)", selection, 1); } catch (Exception e) { Log.e("techmun", "Unable to retrieve the pagina number from selection argument. " + "Pagina will be 0", e); } try { Long leId = Long.parseLong(eventoId); Integer lPagina = Integer.parseInt(pagina); FetchComentariosResult fetchResult = comentsFetcher.fetchComentarios(leId, lPagina); List<FetchComentariosResult> resultList = new ArrayList<FetchComentariosResult>(1); resultList.add(fetchResult); ObjectsCursor result = new ObjectsCursor(resultList); return result; } catch (Exception e) { Log.e("techmun", "Error retrieving comentarios", e); } return null; }
From source file:com.eyekabob.EventList.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.adlistactivity); adapter = new EventListAdapter(getApplicationContext()); ListView lv = (ListView) findViewById(R.id.adList); lv.setAdapter(adapter);//from w ww . j a v a2 s . c o m Uri uri = this.getIntent().getData(); if (getIntent().hasExtra("zip")) { // Search by zip. String zip = getIntent().getExtras().getString("zip"); if (zip != null) { zip = zip.trim(); } if (zipToGeoMap.containsKey(zip)) { Log.d(getClass().getName(), "Using cached zip"); String[] latLong = zipToGeoMap.get(zip).split("\\|"); Uri lastFMURI = getLastFMURI(latLong[0], latLong[1]); sendLastFMRequest(lastFMURI.toString()); } else { Log.d(getClass().getName(), "Getting zip from geonames service"); sendJSONRequest(uri.toString()); } } else if (getIntent().hasExtra("city")) { // Search by city/state. String city = getIntent().getExtras().getString("city"); String encodedCity; try { encodedCity = URLEncoder.encode(city, "UTF-8"); } catch (UnsupportedEncodingException e) { Log.e(getClass().getName(), "Problem with city", e); return; } String state = getIntent().getExtras().getString("state"); Map<String, String> params = new HashMap<String, String>(); params.put("address", encodedCity + "," + state); Uri googleURI = EyekabobHelper.GoogleMaps.getURI(params); sendMapsRequest(googleURI.toString()); } else { Log.d(getClass().getName(), "Searching for events using current location"); sendLastFMRequest(uri.toString()); } lv.setOnItemClickListener(listItemListener); }
From source file:com.google.samples.apps.iosched.feedback.FeedbackHelper.java
/** * Saves the session feedback using the appropriate content provider, and dismisses the * feedback notification.//from ww w . ja v a 2 s .c o m */ public void saveSessionFeedback(SessionFeedbackData data) { if (null == data.comments) { data.comments = ""; } String answers = data.sessionId + ", " + data.sessionRating + ", " + data.sessionRelevantAnswer + ", " + data.contentAnswer + ", " + data.speakerAnswer + ", " + data.comments; LOGD(TAG, answers); ContentValues values = new ContentValues(); values.put(ScheduleContract.Feedback.SESSION_ID, data.sessionId); values.put(ScheduleContract.Feedback.UPDATED, System.currentTimeMillis()); values.put(ScheduleContract.Feedback.SESSION_RATING, data.sessionRating); values.put(ScheduleContract.Feedback.ANSWER_RELEVANCE, data.sessionRelevantAnswer); values.put(ScheduleContract.Feedback.ANSWER_CONTENT, data.contentAnswer); values.put(ScheduleContract.Feedback.ANSWER_SPEAKER, data.speakerAnswer); values.put(ScheduleContract.Feedback.COMMENTS, data.comments); Uri uri = mContext.getContentResolver().insert(ScheduleContract.Feedback.buildFeedbackUri(data.sessionId), values); LOGD(TAG, null == uri ? "No feedback was saved" : uri.toString()); dismissFeedbackNotification(data.sessionId); }
From source file:com.appjma.appdeployer.service.DownloadService.java
private void logError(Uri uri, Exception e) { if (!BuildConfig.DEBUG) { return;/*from www .j a v a2 s.c o m*/ } Log.v(TAG, String.format("Eror occure while downloading: %s", uri.toString()), e); }
From source file:com.adobe.phonegap.csdk.ImageEditor.java
/** * Called when the image editor exits./*from w ww.j ava 2s .co 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 intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras"). */ public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case 1: Uri editedImageUri = intent.getParcelableExtra(AdobeImageIntent.EXTRA_OUTPUT_URI); this.callbackContext.success(editedImageUri.toString()); break; } } else if (resultCode == Activity.RESULT_CANCELED) { this.callbackContext.error("Editor Canceled"); } }