List of usage examples for android.util Log i
public static int i(String tag, String msg)
From source file:uk.bcu.services.MusicDetailsService.java
public void run() { String api_key = "f06e41f0aad377a1aebfe76927318181"; String url = "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=" + api_key + "&mbid=" + movieId + "&format=json"; Log.i("URL", url); boolean error = false; HttpClient httpclient = null;/*from w w w . j a v a 2s . co m*/ try { httpclient = new DefaultHttpClient(); HttpResponse data = httpclient.execute(new HttpGet(url)); HttpEntity entity = data.getEntity(); String result = EntityUtils.toString(entity, "UTF8"); JSONresult = new JSONObject(result); //if (Integer.valueOf(json.getJSONObject("track").getString("opensearch)) > 0) { // results = json.getJSONObject("results").getJSONObject("trackmatches").getJSONArray("track"); } catch (Exception e) { System.out.println(e.toString()); movie = null; error = true; } finally { httpclient.getConnectionManager().shutdown(); } super.serviceComplete(error); }
From source file:com.cssweb.android.connect.ConnPool.java
public static JSONObject servicePasswordLogin(String custno, String password) { StringBuffer sb = new StringBuffer(); sb.append("https://jy.njzq.cn/service/login/Login/mobileClientServLogin.do"); sb.append("?clientNo="); sb.append(custno);//from w w w . ja v a 2 s.co m sb.append("&password="); sb.append(password); sb.append("&ram="); sb.append(Math.random()); Log.i("?>>>>>url>>>>>>>", sb.toString()); return Conn.execute(sb.toString()); }
From source file:mc.lib.network.NetworkHelper.java
public static boolean hasConnection(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni != null && ni.isAvailable() && ni.isConnected()) { if (testConnection(TEST_SERVER1) || testConnection(TEST_SERVER2) || testConnection(TEST_SERVER3)) { Log.i(LOGTAG, "Internet connection detected"); return true; }// w ww . j a v a2 s . c o m } Log.i(LOGTAG, "No internet connection detected"); return false; }
From source file:com.fsck.k9.mail.store.webdav.WebDavHttpClient.java
public static InputStream getUngzippedContent(HttpEntity entity) throws IOException { InputStream responseStream = entity.getContent(); if (responseStream == null) return null; Header header = entity.getContentEncoding(); if (header == null) return responseStream; String contentEncoding = header.getValue(); if (contentEncoding == null) return responseStream; if (contentEncoding.contains("gzip")) { Log.i(LOG_TAG, "Response is gzipped"); responseStream = new GZIPInputStream(responseStream); }//from w ww . j a v a2s . c om return responseStream; }
From source file:com.musevisions.android.SudokuSolver.SudokuRetriever.java
/** * Loads pictures data. This method may take long, so be sure to call it asynchronously without * blocking the main thread./* w ww . j ava 2 s .c o m*/ */ public synchronized void prepare() { // Clear in case images need to be updated long startTime = System.nanoTime(); mContents = loadFromURL(); long deltaTime = System.nanoTime() - startTime; double timeMs = (double) deltaTime / 1E6; Log.i(TAG, "Done querying URL in, " + timeMs + " ms. " + mContents.length() + " elements found."); }
From source file:com.socioffice.grabmenu.model.JSONRequest.java
public static JSONObject SendHttpPost(String URL, JSONObject jsonObjSend) { try {//from w w w . ja v a2 s .co m DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpPostRequest = new HttpPost(URL); StringEntity se; se = new StringEntity(jsonObjSend.toString()); // Set HTTP parameters httpPostRequest.setEntity(se); httpPostRequest.setHeader("Accept", "application/json"); httpPostRequest.setHeader("Content-type", "application/json"); // only set this parameter if you would like to use gzip compression httpPostRequest.setHeader("Accept-Encoding", "gzip"); long t = System.currentTimeMillis(); HttpResponse response = (HttpResponse) httpclient.execute(httpPostRequest); Log.i(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); instream.close(); resultString = resultString.substring(1, resultString.length() - 1); // remove wrapping "[" and // "]" // Transform the String into a JSONObject JSONObject jsonObjRecv = new JSONObject(resultString); // Raw DEBUG output of our received JSON object: Log.i(TAG, "<jsonobject>\n" + jsonObjRecv.toString() + "\n</jsonobject>"); return jsonObjRecv; } } 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:ca.dal.cs.csci4126.quizboard.library.HttpClient.java
public static JSONObject SendHttpPost(String URL, JSONObject jsonObjSend) { try {/*ww w .j av a2 s. co m*/ DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpPostRequest = new HttpPost(URL); StringEntity se; se = new StringEntity(jsonObjSend.toString()); // Set HTTP parameters httpPostRequest.setEntity(se); httpPostRequest.setHeader("Accept", "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.i(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); instream.close(); resultString = resultString.substring(1, resultString.length() - 1); // remove wrapping "[" and "]" // Transform the String into a JSONObject JSONObject jsonObjRecv = new JSONObject(resultString); // Raw DEBUG output of our received JSON object: Log.i(TAG, "<JSONObject>\n" + jsonObjRecv.toString() + "\n</JSONObject>"); return jsonObjRecv; } } 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:com.microsoft.azure.engagement.unity.EngagementWrapper.java
public static void processOpenUrl() { if (openURL == null) return;/*from w w w . j av a 2 s .c o m*/ Log.i(EngagementShared.LOG_TAG, "onHandleOpenURL: " + openURL); UnitySendMessage(unityMethod_onHandleUrl, openURL); openURL = null; }
From source file:com.example.montxu.magik_repair.HttpClient.java
public static JSONObject SendHttpPost(String URL, JSONObject jsonObjSend) { try {/*from w ww .jav a2 s . co m*/ DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpPostRequest = new HttpPost(URL); StringEntity se; se = new StringEntity(jsonObjSend.toString()); // Set HTTP parameters httpPostRequest.setEntity(se); httpPostRequest.setHeader("Accept", "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.i(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); instream.close(); //resultString = resultString.substring(1,resultString.length()-1); // remove wrapping "[" and "]" // Transform the String into a JSONObject JSONObject jsonObjRecv = new JSONObject(resultString); // Raw DEBUG output of our received JSON object: Log.i(TAG, "<JSONObject>\n" + jsonObjRecv.toString() + "\n</JSONObject>"); return jsonObjRecv; } } 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
static public boolean copyAllAssertToCacheFolder(Context c) throws IOException { String[] files = c.getAssets().list("Devices"); String filefolder = c.getFilesDir().toString(); File devicefile = new File(filefolder + "/Devices/"); devicefile.mkdirs();// ww w .ja v a2s .c om for (int i = 0; i < files.length; i++) { File devfile = new File(filefolder + "/Devices/" + files[i]); if (!devfile.exists()) { copyFileTo(c, "Devices/" + files[i], filefolder + "/Devices/" + files[i]); } } String[] filestr = devicefile.list(); for (int i = 0; i < filestr.length; i++) { Log.i("file", filestr[i]); } return true; }