List of usage examples for android.util Log w
public static int w(String tag, Throwable tr)
From source file:com.fastbootmobile.encore.api.musicbrainz.MusicBrainzClient.java
/** * Retrieves the album information from MusicBrainz. This method is synchronous and must be * called from a Thread!// www .j ava2 s . co m * @param artist The name of the artist. Must be filled. * @param album The name of the album. May be empty. * @return An {@link com.fastbootmobile.encore.api.musicbrainz.AlbumInfo} filled with the information * from musicbrainz, or null in case of error */ public static AlbumInfo[] getAlbum(String artist, String album) throws RateLimitException { if (mAlbumInfoCache.containsKey(Pair.create(artist, album))) { return mAlbumInfoCache.get(Pair.create(artist, album)); } if (artist == null && album == null) { return null; } try { String query = ""; if (artist != null) { query += URLEncoder.encode("artist:\"" + artist + "\"", "UTF-8"); } if (album != null && !album.isEmpty()) { query += URLEncoder.encode(" AND release:\"" + album + "\"", "UTF-8"); } JSONObject object = JsonGet.getObject(MAIN_EP + "/release/", "fmt=json&query=" + query, true); if (object.has("releases")) { JSONArray releases = object.getJSONArray("releases"); final int releasesCount = releases.length(); if (releasesCount > 0) { AlbumInfo[] infoArray = new AlbumInfo[releasesCount]; for (int i = 0; i < releasesCount; i++) { AlbumInfo info = new AlbumInfo(); JSONObject release = releases.getJSONObject(i); info.id = release.getString("id"); try { info.track_count = release.getInt("track-count"); } catch (JSONException e) { // No track count info, too bad info.track_count = 0; } infoArray[i] = info; } mAlbumInfoCache.put(Pair.create(artist, album), infoArray); return infoArray; } } else if (object.has("error")) { Log.w(TAG, "Rate limited by the API, will retry later"); throw new RateLimitException(); } // AlbumArtCache will retry with something else if needed mAlbumInfoCache.put(Pair.create(artist, album), null); return null; } catch (IOException e) { Log.e(TAG, "Unable to get album info (rate limit?)", e); throw new RateLimitException(); } catch (JSONException e) { // May happen due to an API error, e.g. error 502 Log.e(TAG, "JSON error while parsing album info", e); throw new RateLimitException(); } }
From source file:com.riksof.a320.c2dm.common.C2DMReceiver.java
@Override public void onUnregistered(Context context) { Log.w("C2DMReceiver-onUnregistered", "got here!"); }
From source file:org.ambientdynamix.web.WebUtils.java
/** * xports an certificate to a file.// www .j a v a 2 s . c o m * * @param cert * The certificate to export. * @param file * The destination file. * @param binary * True if the cert should be written as a binary file; false to encode using Base64. */ public static void exportCertificate(java.security.cert.Certificate cert, File file, boolean binary) { Log.i(TAG, "Writing cert to: " + file.getAbsolutePath()); try { // Get the encoded form which is suitable for exporting byte[] buf = cert.getEncoded(); FileOutputStream os = new FileOutputStream(file); if (binary) { // Write in binary form os.write(buf); } else { // Write in text form Writer wr = new OutputStreamWriter(os, Charset.forName("UTF-8")); wr.write("-----BEGIN CERTIFICATE-----\n"); Base64.encodeBase64(buf); wr.write("\n-----END CERTIFICATE-----\n"); wr.flush(); } os.close(); } catch (Exception e) { Log.w(TAG, "Error writing cert for " + file); } }
From source file:at.bitfire.davdroid.webdav.WebDavCollection.java
public boolean propfind(HttpPropfind.Mode mode) throws IOException, IncapableResourceException, HttpException { HttpPropfind propfind = new HttpPropfind(location, mode); HttpResponse response = client.execute(propfind); checkResponse(response);/*from w w w . j a v a2s .c o m*/ if (response.getStatusLine().getStatusCode() == HttpStatus.SC_MULTI_STATUS) { DavMultistatus multistatus; try { Serializer serializer = new Persister(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); InputStream is = new TeeInputStream(response.getEntity().getContent(), baos); multistatus = serializer.read(DavMultistatus.class, is); Log.d(TAG, "Received multistatus response: " + baos.toString("UTF-8")); } catch (Exception e) { Log.w(TAG, e); throw new IncapableResourceException(); } processMultiStatus(multistatus); return true; } else return false; }
From source file:com.ChiriChat.DataAccessObject.DAOWebServer.ChiriChatMensajesDAO.java
@Override public Mensajes insert(Mensajes dto) throws Exception { //Enviamos una peticion post al insert del usuario. HttpPost httpPostNewMensaje = new HttpPost("http://chirichatserver.noip.me:85/ws/newMensaje"); //Creo el objeto Jason con los datos del contacto que se registra en la app. JSONObject newUsuario = new JSONObject(); try {//from w w w.ja v a 2 s .c o m newUsuario.put("idConver", dto.getIdConversacion()); newUsuario.put("idUsuario", dto.getIdUsuario()); newUsuario.put("texto", dto.getCadena()); } catch (JSONException e) { e.printStackTrace(); } List parametros = new ArrayList(); //Aade a la peticion post el parametro json, que contiene los datos a insertar.(json) parametros.add(new BasicNameValuePair("json", newUsuario.toString())); //Creamos la entidad con los datos que le hemos pasado httpPostNewMensaje.setEntity(new UrlEncodedFormEntity(parametros)); //Objeto para poder obtener respuesta del server HttpResponse response = httpClient.execute(httpPostNewMensaje); //Obtenemos el codigo de la respuesta int respuesta = response.getStatusLine().getStatusCode(); Log.w("Respueta", "" + respuesta); //Si respuesta 200 devuelvo mi usuario , si no devolvere null if (respuesta == 200) { //Nos conectamos para recibir los datos de respuesta HttpEntity entity = response.getEntity(); //Creamos el InputStream InputStream is = entity.getContent(); //Leemos el inputStream String temp = StreamToString(is); //Creamos el JSON con la cadena del inputStream Log.d("Cadena JSON", temp.toString()); JSONObject jsonRecibido = new JSONObject(temp); Log.d("InputStreamReader", temp.toString()); Log.d("JSON ==>", jsonRecibido.toString()); Mensajes mensaje = new Mensajes(jsonRecibido); return mensaje; } return null; }
From source file:com.android.email.mail.store.imap.ImapTempFileLiteral.java
@Override public String getString() { checkNotDestroyed();// www . j a v a 2 s . c om try { return Utility.fromAscii(IOUtils.toByteArray(getAsStream())); } catch (IOException e) { Log.w(Email.LOG_TAG, "ImapTempFileLiteral: Error while reading temp file"); return ""; } }
From source file:com.goliathonline.android.kegbot.io.RemoteJsonHandler.java
private void considerUpdate(String tableName, int version, Uri targetDir, ContentResolver resolver) throws HandlerException { if (tableName == null) { // Silently ignore missing spreadsheets to allow sync to continue. Log.w(TAG, "Missing '" + tableName + "' table data"); return;/*from w w w . j av a 2 s. c o m*/ // throw new HandlerException("Missing '" + sheetName + "' table data"); } final long localUpdated = ParserUtils.queryDirUpdated(targetDir, resolver); final long serverUpdated = version; Log.d(TAG, "considerUpdate() for " + tableName + " found localUpdated=" + localUpdated + ", server=" + serverUpdated); if (localUpdated >= serverUpdated) return; String url = SyncService.getApiUrl(); if (Tables.DRINKS.equals(tableName)) url = url + "/drinks"; else if (Tables.KEGS.equals(tableName)) url = url + "/kegs"; else if (Tables.TAPS.equals(tableName)) url = url + "/taps"; final HttpGet request = new HttpGet(url); final JsonHandler handler = createRemoteHandler(tableName); mExecutor.execute(request, handler); }
From source file:org.montanafoodhub.base.get.AdHub.java
protected List<Ad> readFromFile(Context context) { List<Ad> myAdArr = new ArrayList<Ad>(); try {//w w w . j a v a 2 s . c om // getItem the time the file was last changed here File myFile = new File(context.getFilesDir() + "/" + fileName); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); String lastRefreshTSStr = sdf.format(myFile.lastModified()); Log.w(HubInit.logTag, "Using file (" + fileName + ") last modified on : " + lastRefreshTSStr); lastRefreshTS = sdf.getCalendar(); // create products from the file here InputStream inputStream = context.openFileInput(fileName); if (inputStream != null) { parseCSV(myAdArr, inputStream); } inputStream.close(); } catch (FileNotFoundException e) { Log.e(HubInit.logTag, "File (" + fileName + ") not found: " + e.toString()); } catch (IOException e) { Log.e(HubInit.logTag, "Can not read file (" + fileName + ") : " + e.toString()); } Log.w(HubInit.logTag, "Number of Ad loaded: " + myAdArr.size()); return myAdArr; }
From source file:com.codecarpet.fbconnect.FBLoginDialog.java
@Override protected void dialogWillDisappear() { // _webView.stringByEvaluatingJavaScriptFromString("email.blur();"); if (_getSessionRequest == null) { Log.w(LOG, "This should not be null, at least on iPhone it is not..."); } else {/*from w w w . j a v a 2s .c om*/ _getSessionRequest.cancel(); } }
From source file:org.mythtv.service.frontends.PlayRecordingOnFrontEndTask.java
@Override protected Boolean doInBackground(String... params) { Log.d(TAG, "doInBackground : enter"); if (null == mContext) { throw new IllegalArgumentException("Context is required"); }//from w ww . ja v a 2 s . co m if (null == mLocationProfile) { throw new IllegalArgumentException("LocationProfile is required"); } if (null == mProgram) { throw new IllegalArgumentException("Program is required"); } boolean started = false; ApiVersion apiVersion = ApiVersion.valueOf(mLocationProfile.getVersion()); switch (apiVersion) { case v025: started = false; break; case v026: started = false; break; case v027: String url = params[0]; if (!NetworkHelper.getInstance().isFrontendConnected(mContext, mLocationProfile, url)) { Log.w(TAG, "process : Frontend @ '" + url + "' is unreachable"); return false; } org.mythtv.services.api.v027.MythServicesTemplate mythServicesTemplateV27 = (org.mythtv.services.api.v027.MythServicesTemplate) MythAccessFactory .getServiceTemplateApiByVersion(apiVersion, url); if (null != mythServicesTemplateV27) { ResponseEntity<org.mythtv.services.api.Bool> responseV27 = mythServicesTemplateV27 .frontendOperations().playRecording(mProgram.getChannelInfo().getChannelId(), mProgram.getRecording().getStartTimestamp(), ETagInfo.createEmptyETag()); if (responseV27.getStatusCode().equals(HttpStatus.OK)) { if (null != responseV27.getBody()) { started = responseV27.getBody().getValue(); } } } break; default: started = false; break; } Log.d(TAG, "doInBackground : exit"); return started; }