List of usage examples for android.util Log v
public static int v(String tag, String msg)
From source file:com.example.soumya.feedthepanda.RegistrationIntentService.java
@Override protected void onHandleIntent(Intent intent) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); Log.v("Extra", "intent started"); try {/*from w ww .j ava 2 s. c o m*/ // [START register_for_gcm] // Initially this call goes out to the network to retrieve the token, subsequent calls // are local. // R.string.gcm_defaultSenderId (the Sender ID) is typically derived from google-services.json. // See https://developers.google.com/cloud-messaging/android/start for details on this file. // [START get_token] InstanceID instanceID = InstanceID.getInstance(this); String token = instanceID.getToken("647059769887", GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); // [END get_token] Log.i(TAG, "GCM Registration Token: " + token); // TODO: Implement this method to send any registration to your app's servers. sendRegistrationToServer(token, sharedPreferences.getString("api_key", "nope")); // Subscribe to topic channels subscribeTopics(token); // You should store a boolean that indicates whether the generated token has been // sent to your server. If the boolean is false, send the token to your server, // otherwise your server should have already received the token. sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, true).apply(); // [END register_for_gcm] } catch (Exception e) { Log.d(TAG, "Failed to complete token refresh", e); // If an exception happens while fetching the new token or updating our registration data // on a third-party server, this ensures that we'll attempt the update at a later time. sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false).apply(); } // Notify UI that registration has completed, so the progress indicator can be hidden. Intent registrationComplete = new Intent(QuickstartPreferences.REGISTRATION_COMPLETE); LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete); }
From source file:com.jeffreyawest.weblogic.rest.WebLogicHTTPRestAdapter.java
@Override public <T extends WebLogicEntity> List<T> getResourcesList(Class<T> theClass) { Log.v(LOG_TAG, "Getting Resource Summary for class: " + theClass); String url = getSummaryURL(theClass.getSimpleName().toLowerCase()); Log.v(LOG_TAG, "Getting Resource Summary from URL: " + url); List<T> returnMe = new ArrayList<T>(); String json = httpAdapter.GET(url, username, password, "json", null); JSONObject jsonMessage = null;//from w w w.j a va2 s. c o m ObjectMapper om = new ObjectMapper(); try { jsonMessage = new JSONObject(json); Log.v(LOG_TAG, "Class: " + theClass + " JSON: " + jsonMessage.toString(2)); JSONArray array = jsonMessage.getJSONObject("body").getJSONArray("items"); for (int i = 0; i < array.length(); i++) { T theType = om.readValue(array.getString(i), theClass); theType.setOriginalJSON(jsonMessage.toString(2)); returnMe.add(theType); } } catch (JSONException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return returnMe; }
From source file:com.client.capturephoto.util.FileOperationHelper.java
public static boolean deleteFile(ImageInfo f) { if (f == null) { Log.e(LOG_TAG, "DeleteFile: null parameter"); return false; }//from w ww .j a v a 2 s. c om File file = new File(f.fullName); // boolean directory = file.isDirectory(); // if (directory) // { // do nothing // for (File child : file.listFiles(mFilter)) { // if (Util.isNormalFile(child.getAbsolutePath())) { // DeleteFile(Util.GetImageInfo(child, mFilter, true)); // } // } // } boolean result = file.delete(); if (f.imageCode != null) { file = new File(f.imageCode); file.delete(); } Log.v(LOG_TAG, "DeleteFile >>> " + f.fullName + " >>> " + result); return result; }
From source file:com.updater.ota.GCMIntentService.java
@Override protected void onRegistered(Context ctx, String regID) { Log.v("OTAUpdater::GCMRegister", "GCM registered - ID=" + regID); ArrayList<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(); params.add(new BasicNameValuePair("do", "register")); params.add(new BasicNameValuePair("reg_id", regID)); params.add(new BasicNameValuePair("device", android.os.Build.DEVICE.toLowerCase())); params.add(new BasicNameValuePair("rom_id", Utils.getRomID())); params.add(new BasicNameValuePair("device_id", ((TelephonyManager) getSystemService(TELEPHONY_SERVICE)).getDeviceId())); try {/*from w w w. j av a2 s .c o m*/ HttpClient http = new DefaultHttpClient(); HttpPost req = new HttpPost(Config.GCM_REGISTER_URL); req.setEntity(new UrlEncodedFormEntity(params)); HttpResponse r = http.execute(req); int status = r.getStatusLine().getStatusCode(); HttpEntity e = r.getEntity(); if (status == 200) { String data = EntityUtils.toString(e); if (data.length() == 0) { Log.w("OTA::GCMRegister", "No response to registration"); return; } JSONObject json = new JSONObject(data); if (json.length() == 0) { Log.w("OTA::GCMRegister", "Empty response to registration"); return; } if (json.has("error")) { Log.e("OTA::GCMRegister", json.getString("error")); return; } RomInfo info = new RomInfo(json.getString("rom"), json.getString("version"), json.getString("changelog"), json.getString("url"), json.getString("md5"), Utils.parseDate(json.getString("date"))); if (Utils.isUpdate(info)) { Config.getInstance(getApplicationContext()).storeUpdate(info); Utils.showUpdateNotif(getApplicationContext(), info); } else { Config.getInstance(getApplicationContext()).clearStoredUpdate(); } } else { if (e != null) e.consumeContent(); Log.w("OTA::GCMRegistr", "registration response " + status); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.udacity.sunshine.FetchWeatherTask.java
private long addLocation(String locationSetting, String cityName, double lat, double lon) { Log.v(LOG_TAG, "inserting " + cityName + ", with coord: " + lat + ", " + lon); String[] projection = { LocationEntry._ID }; // whichever column doesn't matter, but don't need to return all String[] selectionArgs = { locationSetting }; String selection = LocationEntry.COLUMN_LOCATION_SETTING + " = ? "; // Check to see if location setting exists in db Cursor cursor = mContext.getContentResolver().query(LocationEntry.CONTENT_URI, projection, selection, selectionArgs, null);/*from w ww .jav a 2 s . c o m*/ long locationRowId; if (cursor.moveToFirst()) { Log.v(LOG_TAG, "Found it in the database!"); int locationIdIndex = cursor.getColumnIndex(LocationEntry._ID); locationRowId = cursor.getLong(locationIdIndex); } else { Log.v(LOG_TAG, "Didn't find it in the database, inserting now!"); ContentValues locationValues = new ContentValues(); locationValues.put(LocationEntry.COLUMN_LOCATION_SETTING, locationSetting); locationValues.put(LocationEntry.COLUMN_CITY_NAME, cityName); locationValues.put(LocationEntry.COLUMN_COORD_LAT, lat); locationValues.put(LocationEntry.COLUMN_COORD_LONG, lon); Uri locationUri = mContext.getContentResolver().insert(LocationEntry.CONTENT_URI, locationValues); locationRowId = ContentUris.parseId(locationUri); } cursor.close(); return locationRowId; }
From source file:dtu.ds.warnme.app.ws.client.https.GsonHttpResponseHandler.java
@Override @Deprecated//from ww w .j a va 2 s . com public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { try { String response = responseBody != null ? new String(responseBody, getCharset()) : StringUtils.EMPTY; T object = gson.fromJson(response, type); onSuccess(statusCode, headers, object); } catch (UnsupportedEncodingException e) { Log.v(TAG, "String encoding failed, calling onFailure(int, Header[], String, Throwable)"); onFailure(0, headers, (String) null, e); } }
From source file:br.com.cams7.siscom.member.MemberEdit.java
/** * Called when the activity is first created. Responsible for initializing * the UI.//w w w . j a v a 2 s .co m */ @Override public void onCreate(Bundle savedInstanceState) { Log.v(TAG, "Activity State: onCreate()"); super.onCreate(savedInstanceState); setContentView(R.layout.member_edit); etName = (EditText) findViewById(R.id.etName); etPhone = (EditText) findViewById(R.id.etPhone); etEmail = (EditText) findViewById(R.id.etEmail); addListenerOnSave(); }
From source file:com.pocketsoap.convodroid.loaders.JsonLoader.java
@Override public ReturnType loadInBackground() { Log.v("Convodroid", "JsonLoader::loadInBackground " + request.getMethod() + " " + request.getPath()); try {//w w w . ja v a 2 s.c o m RestResponse res = client.sendSync(request); Log.v("Convodroid", "JsonLoader:: got http response " + res.getStatusCode() + " for " + request.getPath()); if (res.getStatusCode() == HttpStatus.SC_NO_CONTENT) return null; ObjectMapper mapper = new ObjectMapper(); mapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); return mapper.readValue(res.getHttpResponse().getEntity().getContent(), typeReference); } catch (JsonParseException e) { Log.w("Convodroid", "JsonLoader error", e); } catch (JsonMappingException e) { Log.w("Convodroid", "JsonLoader error", e); } catch (IllegalStateException e) { Log.w("Convodroid", "JsonLoader error", e); } catch (IOException e) { Log.w("Convodroid", "JsonLoader error", e); } return null; }
From source file:br.com.hotforms.usewaze.UseWaze.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback id used when calling back into JavaScript. * @return True if the action was valid, false otherwise. *//* w ww . j av a2 s . c o m*/ @Override public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException { Log.v(TAG, "Executing action: " + action); if ("search".equals(action)) { callWaze("waze://?q=" + args.getString(0)); return true; } else if ("centerOnMap".equals(action)) { callWaze("waze://?ll=" + args.getString(0) + "," + args.getString(1) + "&z=" + args.getString(2)); return true; } else if ("navigateTo".equals(action)) { callWaze("waze://?ll=" + args.getString(0) + "," + args.getString(1) + "&navigate=yes"); return true; } return false; }
From source file:com.twotoasters.android.hoot.HootTransportHttpUrlConnection.java
@Override public HootResult synchronousExecute(HootRequest request) { if (request.isCancelled()) { return request.getResult(); }//from w w w. j a v a2s . c o m mStreamingMode = (request.getQueryParameters() == null && request.getData() == null && request.getMultipartEntity() == null) ? StreamingMode.CHUNKED : StreamingMode.FIXED; if (request.getStreamingMode() == HootRequest.STREAMING_MODE_FIXED) { mStreamingMode = StreamingMode.FIXED; } HttpURLConnection connection = null; try { String url = request.buildUri().toString(); Log.v(TAG, "Executing [" + url + "]"); connection = (HttpURLConnection) new URL(url).openConnection(); if (connection instanceof HttpsURLConnection) { HttpsURLConnection httpsConnection = (HttpsURLConnection) connection; httpsConnection.setHostnameVerifier(mSSLHostNameVerifier); } connection.setConnectTimeout(mTimeout); connection.setReadTimeout(mTimeout); synchronized (mConnectionMap) { mConnectionMap.put(request, connection); } setRequestMethod(request, connection); setRequestHeaders(request, connection); if (request.getMultipartEntity() != null) { setMultipartEntity(request, connection); } else if (request.getData() != null) { setRequestData(request, connection); } HootResult hootResult = request.getResult(); hootResult.setResponseCode(connection.getResponseCode()); Log.d(TAG, " - received response code [" + connection.getResponseCode() + "]"); if (request.getResult().isSuccess()) { hootResult.setHeaders(connection.getHeaderFields()); hootResult.setResponseStream(new BufferedInputStream(connection.getInputStream())); } else { hootResult.setResponseStream(new BufferedInputStream(connection.getErrorStream())); } request.deserializeResult(); } catch (Exception e) { request.getResult().setException(e); e.printStackTrace(); } finally { if (connection != null) { synchronized (mConnectionMap) { mConnectionMap.remove(request); } connection.disconnect(); connection = null; } } return request.getResult(); }