List of usage examples for android.util Log v
public static int v(String tag, String msg)
From source file:com.jeffreyawest.http.HTTPAdapterImpl.java
@Override public String GET(String pURL, String pUsername, String pPassword, String pAccept, HashMap<String, String> pAdditionalHeaders) { Log.v(LOG_TAG, "GET()"); // Making HTTP request HttpGet httpGet = new HttpGet(pURL); httpGet.setHeader(ACCEPT_HEADER_KEY, "application/json"); if (pUsername != null || pPassword != null) { String authorizationString = "Basic " + Base64.encodeToString((pUsername + ":" + pPassword).getBytes(), Base64.NO_WRAP); httpGet.setHeader("Authorization", authorizationString); Log.v(LOG_TAG, "Setting AUTH header: " + authorizationString); }/*from ww w . j a v a 2 s .com*/ String result = null; try { result = doHTTPMethod(httpGet); } catch (Exception e) { e.printStackTrace(); } return result; }
From source file:com.android.feedmeandroid.HTTPClient.java
public static ArrayList<JSONObject> SendHttpPost(String URL, JSONObject jsonObjSend) { try {/*from w ww . j a v a2 s.c o m*/ ArrayList<JSONObject> retArray = new ArrayList<JSONObject>(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpPostRequest = new HttpPost(URL); StringEntity se; se = new StringEntity(jsonObjSend.toString()); // Set HTTP parameters httpPostRequest.setEntity(se); httpPostRequest.setHeader("Accepts", "application/json"); httpPostRequest.setHeader("Content-Type", "application/json"); // httpPostRequest.setHeader("Accept-Encoding", "gzip"); // only set // this parameter if you would like to use gzip compression long t = System.currentTimeMillis(); HttpResponse response = (HttpResponse) httpclient.execute(httpPostRequest); Log.v(TAG, "HTTPResponse received in [" + (System.currentTimeMillis() - t) + "ms]"); // Get hold of the response entity (-> the data): HttpEntity entity = response.getEntity(); if (entity != null) { // Read the content stream InputStream instream = entity.getContent(); Header contentEncoding = response.getFirstHeader("Content-Encoding"); if (contentEncoding != null && contentEncoding.getValue().equalsIgnoreCase("gzip")) { instream = new GZIPInputStream(instream); } // convert content stream to a String String resultString = convertStreamToString(instream); Log.i(TAG, resultString); instream.close(); resultString = resultString.substring(1, resultString.length() - 2); // remove wrapping "[" and // "]" String[] results = resultString.split("\\},\\{"); for (int i = 0; i < results.length; i++) { JSONObject jsonObjRecv; String res = results[i]; // Transform the String into a JSONObject if (i == 0 && results.length > 1) { jsonObjRecv = new JSONObject(res + "}"); } else if (i == results.length - 1 && results.length > 1) { jsonObjRecv = new JSONObject("{" + res); } else { jsonObjRecv = new JSONObject("{" + res + "}"); } retArray.add(jsonObjRecv); // Raw DEBUG output of our received JSON object: Log.i(TAG, "<JSONObject>\n" + jsonObjRecv.toString() + "\n</JSONObject>"); } return retArray; } } catch (Exception e) { // More about HTTP exception handling in another tutorial. // For now we just print the stack trace. e.printStackTrace(); } return null; }
From source file:Main.java
/** * decide use XLOG or android default log * @param tag log tag/*ww w . j a v a 2 s. c o m*/ * @param msg log info message * @return log level */ public static int v(String tag, String msg) { return /*XLOG_ON ? Xlog.v(tag, msg) : */Log.v(tag, msg); }
From source file:co.uk.gauntface.cordova.plugin.gcmbrowserlaunch.PushNotificationReceiver.java
@Override public void onReceive(Context context, Intent intent) { Log.v(C.TAG, "PushNotificationReceiver: Received Notification"); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String messageType = gcm.getMessageType(intent); if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { //sendNotification("Send error: " + intent.getExtras().toString()); Log.e(C.TAG, "PushNotificationReceiver: MESSAGE_TYPE_SEND_ERROR"); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.e(C.TAG, "PushNotificationReceiver: MESSAGE_TYPE_DELETED"); } else {//www . j a v a 2 s . co m Bundle data = intent.getExtras(); if (data != null) { String url = validateUrl(data.getString("url")); String packageName = data.getString("pkg"); String session = data.getString("session"); SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0); String lastSession = settings.getString("lastsession", null); String lastReceivedUrl = settings.getString("lastreceivedurl", null); if (session != null && session.equals(lastSession) && url.equals(lastReceivedUrl)) { setResultCode(Activity.RESULT_OK); return; } //Log.v(C.TAG, "PushNotificationReceiver: url = "+url); //Log.v(C.TAG, "PushNotificationReceiver: lastsession = "+lastSession); //Log.v(C.TAG, "PushNotificationReceiver: lastReceivedUrl = "+lastReceivedUrl); if (url != null) { launchBrowserTask(context, url, packageName); // We need an Editor object to make preference changes. // All objects are from android.context.Context SharedPreferences.Editor editor = settings.edit(); editor.putString("lastreceivedurl", url); editor.putString("lastsession", session); // Commit the edits! editor.commit(); } } } setResultCode(Activity.RESULT_OK); }
From source file:Main.java
public static Date getDateTimeFrom(Date time, Date date) { Date iTime, iDate;/*w w w .ja v a2 s . com*/ Calendar calendar = Calendar.getInstance(); if (date == null) { iTime = time; iDate = new Date(); } else { iTime = time; iDate = date; } Calendar calendarDate = Calendar.getInstance(); calendarDate.setTime(iDate); Calendar calendarTime = Calendar.getInstance(); if (iTime != null) calendarTime.setTime(iTime); if (iTime != null) { calendar.set(Calendar.MINUTE, calendarTime.get(Calendar.MINUTE)); calendar.set(Calendar.HOUR_OF_DAY, calendarTime.get(Calendar.HOUR_OF_DAY)); } else { calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); } //calendar.set(Calendar.AM_PM, calendarTime.get(Calendar.AM_PM) ); calendar.set(Calendar.DAY_OF_MONTH, calendarDate.get(Calendar.DAY_OF_MONTH)); calendar.set(Calendar.MONTH, calendarDate.get(Calendar.MONTH)); calendar.set(Calendar.YEAR, calendarDate.get(Calendar.YEAR)); Date ret = calendar.getTime(); Log.v("!!!!!!!!!! calendar=", "" + ret); return ret; }
From source file:com.shinylife.smalltools.api.ApiImpl.java
public HashMap getPigInfo(String no) { try {//from w w w. j a v a 2s .co m Log.v("vv", "starting............."); //String response = HttpRequest(String.format(Constants.API_URL,"pig", URLEncoder.encode(no))); //HttpHelp httphelp=new HttpHelp("http://10.0.2.2:8080/test.jsp"); HttpHelp httphelp = new HttpHelp("http://119.60.2.40:8080/esale/admin/farm.jsp"); String response = httphelp.httpGet(); Log.v("test...", response); if (response != null && response.length() > 0) { HashMap ai = new HashMap(); JSONObject jb = new JSONObject(response); ai.put("code", jb.getString("code")); ai.put("dealer", jb.getString("dealer")); ai.put("dealeraddress", jb.getString("dealeraddress")); ai.put("wholesaler", jb.getString("wholesaler")); ai.put("slaughtercom", jb.getString("slaughtercom")); ai.put("slaughterdate", jb.getString("slaughterdate")); ai.put("mealinspect", jb.getString("mealinspect")); ai.put("animalspect", jb.getString("animalspect")); ai.put("pigsuppliers", jb.getString("pigsuppliers")); ai.put("pigorigin", jb.getString("pigorigin")); ai.put("pigorigin_id", jb.getString("pigorigin_id")); ai.put("transportcom", jb.getString("transportcom")); ai.put("transportlicense", jb.getString("transportlicense")); return ai; } } catch (Exception e) { // TODO: handle exception e.printStackTrace(); Log.v("error", e.toString()); } return null; }
From source file:com.loftcat.utils.log.LogCenter.java
public void verbose(String tag, String msg) { if (logCenter != null) Log.v(tag, msg); }
From source file:com.tcs.base64.Base64ImagePlugin.java
@Override public boolean execute(String action, JSONArray data, CallbackContext callbackContext) { boolean result = false; Log.v(TAG, "execute: action=" + action); // Context context = getContext(); if (!action.equals("saveImage")) { callbackContext.error("Invalid action : " + action); result = false;//from w ww . j a va 2 s . c o m } try { Log.v(TAG, data.getString(0)); Log.v(TAG, data.getJSONObject(1).toString()); String b64String = data.getString(0); if (b64String.startsWith("data:image")) { b64String = b64String.substring(22); } else { b64String = data.getString(0); } JSONObject params = data.getJSONObject(1); //Optional parameter String filename = params.has("filename") ? params.getString("filename") + ".png" : "b64Image_" + System.currentTimeMillis() + ".png"; String storagetype = params.has("externalStorage") ? Environment.getExternalStorageDirectory() + "" : getApplicationContext().getFilesDir().getAbsolutePath(); callbackContext.error("external ==" + Environment.getExternalStorageDirectory()); String folder = params.has("folder") ? params.getString("folder") : storagetype + "/Pictures"; Boolean overwrite = params.has("overwrite") ? params.getBoolean("overwrite") : false; result = this.saveImage(b64String, filename, folder, overwrite, callbackContext); } catch (JSONException e) { Log.v(TAG, e.getMessage()); callbackContext.error("Exception :" + e.getMessage()); result = false; } return result; }
From source file:com.varoid.exoplanethunter.JSONParser.java
public String getJSONArray(int i, String json_text) { try {/*from w w w. ja va2s . com*/ j_arr = new JSONArray(json_text); JSONObject json_data = j_arr.getJSONObject(i); try { return json_data.toString(); } catch (Exception e) { Log.v("error1", e.getMessage().toString()); return ""; } } catch (Exception e) { Log.v("error2", e.getMessage().toString()); return ""; } }
From source file:at.bitfire.davdroid.log.LogcatHandler.java
@Override public void publish(LogRecord r) { String text = getFormatter().format(r); int level = r.getLevel().intValue(); int end = text.length(); for (int pos = 0; pos < end; pos += MAX_LINE_LENGTH) { String line = text.substring(pos, NumberUtils.min(pos + MAX_LINE_LENGTH, end)); if (level >= Level.SEVERE.intValue()) Log.e(r.getLoggerName(), line); else if (level >= Level.WARNING.intValue()) Log.w(r.getLoggerName(), line); else if (level >= Level.CONFIG.intValue()) Log.i(r.getLoggerName(), line); else if (level >= Level.FINER.intValue()) Log.d(r.getLoggerName(), line); else//www .j a v a 2 s . c om Log.v(r.getLoggerName(), line); } }