List of usage examples for android.util Log w
public static int w(String tag, Throwable tr)
From source file:com.google.firebase.quickstart.analytics.webview.AnalyticsWebInterface.java
private Bundle bundleFromJson(String json) { // [START_EXCLUDE] if (TextUtils.isEmpty(json)) { return new Bundle(); }/* ww w . j a v a2 s . c o m*/ Bundle result = new Bundle(); try { JSONObject jsonObject = new JSONObject(json); Iterator<String> keys = jsonObject.keys(); while (keys.hasNext()) { String key = keys.next(); Object value = jsonObject.get(key); if (value instanceof String) { result.putString(key, (String) value); } else if (value instanceof Integer) { result.putInt(key, (Integer) value); } else if (value instanceof Double) { result.putDouble(key, (Double) value); } else { Log.w(TAG, "Value for key " + key + " not one of [String, Integer, Double]"); } } } catch (JSONException e) { Log.w(TAG, "Failed to parse JSON, returning empty Bundle.", e); return new Bundle(); } return result; // [END_EXCLUDE] }
From source file:com.xinlan.otma.net.CustomHttpResponseHandler.java
public void onSuccess(int statusCode, Header[] headers, String responseString) { Log.w(LOG_TAG, "onSuccess(int, Header[], JSONObject) was not overriden, but callback was received"); }
From source file:de.steveliedtke.gcm.example.gcm.GCMIntentService.java
@Override protected void onMessage(final Context context, final Intent intent) { Log.w("GCM-Message", "Received message"); final String payload = intent.getStringExtra("payload"); Log.d("GCM-Message", "dmControl: payload = " + payload); try {// ww w .jav a2 s. c o m SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); Log.i("GCM-Message", "PAYLOAD: " + payload); if (settings.getBoolean("notification_preference", true)) { this.displayNotification(context, payload, settings.getBoolean("vibration_preference", true), settings.getBoolean("permanent_notification_preference", false)); } } catch (JSONException e) { Log.e("GCM-Message", "JSON-Exception occured!"); } }
From source file:com.tenforwardconsulting.cordova.bgloc.AbstractLocationProvider.java
public void persistLocation(LocationProxy location) { if (dao.persistLocation(location)) { Log.d(TAG, "Persisted Location: " + location.toString()); } else {/* w ww . j ava 2 s . co m*/ Log.w(TAG, "Failed to persist location"); } }
From source file:com.attentec.ServerContact.java
/** * Posts POST request to url with data that from values. * Values are put together to a json object before they are sent to server. * postname = { subvar_1_name => subvar_1_value, * subvar_2_name => subvar_2_value * ...}/* w w w .ja va2 s . com*/ * postname_2 = {...} * ... * @param values hashtable with structure: * @param url path on the server to call * @param ctx calling context * @return JSONObject with data from rails server. * @throws Login.LoginException when login is wrong */ public static JSONObject postJSON(final Hashtable<String, List<NameValuePair>> values, final String url, final Context ctx) throws Login.LoginException { //fetch the urlbase urlbase = PreferencesHelper.getServerUrlbase(ctx); //create a JSONObject of the hashtable List<NameValuePair> pairs = new ArrayList<NameValuePair>(); Enumeration<String> postnames = values.keys(); String postname; List<NameValuePair> postvalues; JSONObject postdata; while (postnames.hasMoreElements()) { postname = (String) postnames.nextElement(); postvalues = values.get(postname); postdata = new JSONObject(); for (int i = 0; i < postvalues.size(); i++) { try { postdata.put(postvalues.get(i).getName(), postvalues.get(i).getValue()); } catch (JSONException e) { Log.w(TAG, "JSON fail"); return null; } } pairs.add(new BasicNameValuePair(postname, postdata.toString())); } //prepare the http call HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, CONNECTION_TIMEOUT); HttpConnectionParams.setSoTimeout(httpParams, CONNECTION_TIMEOUT); HttpClient client = new DefaultHttpClient(httpParams); HttpPost post = new HttpPost(urlbase + url); //Log.d(TAG, "contacting url: " + post.getURI()); try { post.setEntity(new UrlEncodedFormEntity(pairs, "UTF-8")); } catch (UnsupportedEncodingException e) { return null; } //call the server String response = null; ResponseHandler<String> responseHandler = new BasicResponseHandler(); try { response = client.execute(post, responseHandler); } catch (IOException e) { Log.e(TAG, "Failed in HTTP request: " + e.toString()); return null; } //Log.d(TAG, "Have contacted url success: " + post.getURI()); //read response JSONObject jsonresponse; try { jsonresponse = new JSONObject(response); } catch (JSONException e) { Log.e(TAG, "Incorrect response from server" + e.toString()); return null; } String responsestatus; try { responsestatus = jsonresponse.getString("Responsestatus"); } catch (JSONException e1) { return null; } if (!responsestatus.equals("Wrong login")) { return jsonresponse; } else { Log.w(TAG, "Wrong login"); throw new Login.LoginException("Wrong login"); } }
From source file:com.clutch.ClutchStats.java
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { Log.w(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion + ", which will destroy all old data"); db.execSQL("DROP TABLE IF EXISTS stats"); db.execSQL("DROP TABLE IF EXISTS abcache"); db.execSQL("DROP TABLE IF EXISTS ablog"); onCreate(db);//from ww w . j ava 2s. co m }
From source file:com.bandbaaja.c2dm.DeviceRegistrar.java
public static void unregisterWithServer(final Context context, final String deviceRegistrationID) { new Thread(new Runnable() { public void run() { Intent updateUIIntent = new Intent("com.google.ctp.UPDATE_UI"); try { HttpResponse res = makeRequest(context, deviceRegistrationID, UNREGISTER_PATH); if (res.getStatusLine().getStatusCode() != 200) { Log.w(TAG, "Unregistration error " + String.valueOf(res.getStatusLine().getStatusCode())); }/*from w ww .jav a 2 s . c om*/ } catch (Exception e) { Log.w(TAG, "Unregistration error " + e.getMessage()); } finally { SharedPreferences settings = Prefs.get(context); SharedPreferences.Editor editor = settings.edit(); editor.remove("deviceRegistrationID"); editor.remove("accountName"); editor.commit(); updateUIIntent.putExtra(STATUS_EXTRA, UNREGISTERED_STATUS); } // Update dialog activity context.sendBroadcast(updateUIIntent); } }).start(); }
From source file:au.id.micolous.frogjump.Util.java
private static void newVersionAlert(final Activity activity) { // We have a new version available. Prompt. AlertDialog.Builder updateDialog = new AlertDialog.Builder(activity); updateDialog.setTitle(R.string.update_available_title); updateDialog.setMessage(R.string.update_available_message); updateDialog.setPositiveButton(R.string.update_positive, new DialogInterface.OnClickListener() { @Override/*from ww w .j a v a 2s. c o m*/ public void onClick(DialogInterface dialogInterface, int i) { try { activity.startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName()))); } catch (ActivityNotFoundException anfe) { // Hmm, market is not installed Log.w(TAG, "Google Play is not installed; cannot install update"); } } }); updateDialog.setNegativeButton(R.string.update_negative, null); updateDialog.setCancelable(true); updateDialog.show(); }
From source file:at.bitfire.davdroid.webdav.DavRedirectStrategy.java
/** * Gets the destination of a redirection * @return absolute URL of new location; null if not available */// ww w . j a v a2 s . com static URI getLocation(HttpRequest request, HttpResponse response, HttpContext context) { Header locationHdr = response.getFirstHeader("Location"); if (locationHdr == null) { Log.e(TAG, "Received redirection without Location header, ignoring"); return null; } try { URI location = URIUtils.parseURI(locationHdr.getValue(), false); // some servers don't return absolute URLs as required by RFC 2616 if (!location.isAbsolute()) { Log.w(TAG, "Received invalid redirection to relative URL, repairing"); URI originalURI = URIUtils.parseURI(request.getRequestLine().getUri(), false); if (!originalURI.isAbsolute()) { final HttpHost target = HttpClientContext.adapt(context).getTargetHost(); if (target != null) originalURI = org.apache.http.client.utils.URIUtilsHC4.rewriteURI(originalURI, target); else return null; } return originalURI.resolve(location); } return location; } catch (URISyntaxException e) { Log.e(TAG, "Received redirection from/to invalid URI, ignoring", e); } return null; }
From source file:org.mythtv.service.content.v25.FileListHelperV25.java
public List<String> process(final Context context, final LocationProfile locationProfile, String storageGroupName) { Log.v(TAG, "process : enter"); if (!NetworkHelper.getInstance().isMasterBackendConnected(context, locationProfile)) { Log.w(TAG, "process : Master Backend '" + locationProfile.getHostname() + "' is unreachable"); return null; }//from w w w.jav a2 s . c om mMythServicesTemplate = (MythServicesTemplate) MythAccessFactory.getServiceTemplateApiByVersion(mApiVersion, locationProfile.getUrl()); if (null == mMythServicesTemplate) { Log.w(TAG, "process : Master Backend '" + locationProfile.getHostname() + "' is unreachable"); return null; } List<String> files = null; try { files = downloadFiles(storageGroupName); } catch (Exception e) { Log.e(TAG, "process : error", e); files = null; } Log.v(TAG, "process : exit"); return files; }