List of usage examples for android.util Log i
public static int i(String tag, String msg)
From source file:com.arellomobile.android.push.PushGCMIntentService.java
@Override protected void onRegistered(Context context, String registrationId) { Log.i(TAG, "Device registered: regId = " + registrationId); DeviceRegistrar.registerWithServer(context, registrationId); }
From source file:com.granita.icloudcalsync.webdav.DavHttpClient.java
@SuppressLint("LogTagMismatch") public static CloseableHttpClient create() { PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager( socketFactoryRegistry);/* w ww . ja va 2s. c om*/ // limits per DavHttpClient (= per DavSyncAdapter extends AbstractThreadedSyncAdapter) connectionManager.setMaxTotal(3); // max. 3 connections in total connectionManager.setDefaultMaxPerRoute(2); // max. 2 connections per host HttpClientBuilder builder = HttpClients.custom().useSystemProperties() .setConnectionManager(connectionManager).setDefaultRequestConfig(defaultRqConfig) .setRetryHandler(DavHttpRequestRetryHandler.INSTANCE) .setRedirectStrategy(DavRedirectStrategy.INSTANCE) .setUserAgent("DAVdroid/" + Constants.APP_VERSION); if (Log.isLoggable("Wire", Log.DEBUG)) { Log.i(TAG, "Wire logging active, disabling HTTP compression"); builder = builder.disableContentCompression(); } return builder.build(); }
From source file:de.itomig.itoplib.GetItopJSON.java
/** * request data from itop server in json format * //from ww w .jav a2 s. c o m * @param operation * @param itopClass * @param key * @param output_fields * @return */ public static String postJsonToItopServer(String operation, String itopClass, String key, String output_fields) { AndroidHttpClient client = AndroidHttpClient.newInstance("Android"); String result = ""; try { HttpPost request = new HttpPost(); String url = ItopConfig.getItopUrl(); String req = url + "/webservices/rest.php?version=1.0"; if (debug) Log.i(TAG, "req.=" + req); request.setURI(new URI(req)); ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); postParameters.add(ItopConfig.getItopUserNameValuePair()); postParameters.add(ItopConfig.getItopPwdNameValuePair()); JSONObject jsd = new JSONObject(); jsd.put("operation", operation); jsd.put("class", itopClass); jsd.put("key", key); jsd.put("output_fields", output_fields); postParameters.add(new BasicNameValuePair("json_data", jsd.toString())); UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters); request.setEntity(formEntity); // request.addHeader(HTTP.CONTENT_TYPE, "application/json"); HttpResponse response = client.execute(request); String status = response.getStatusLine().toString(); if (debug) Log.i(TAG, "status: " + status); if (status.contains("200") && status.contains("OK")) { // request worked fine, retrieved some data InputStream instream = response.getEntity().getContent(); result = convertStreamToString(instream); Log.d(TAG, "result is: " + result); } else // some error in http response { Log.e(TAG, "Get data - http-ERROR: " + status); result = "ERROR: http status " + status; } } catch (Exception e) { // Toast does not work in background task Log.e(TAG, "Get data - " + e.toString()); result = "ERROR: " + e.toString(); } finally { client.close(); // needs to be done for androidhttpclient if (debug) Log.i(TAG, "...finally.. get data finished"); } return result; }
From source file:Main.java
public static Point findBestPreviewSizeValue(Camera.Parameters parameters, Point screenResolution) { List<Camera.Size> rawSupportedSizes = parameters.getSupportedPreviewSizes(); if (rawSupportedSizes == null) { Log.w(TAG, "Device returned no supported preview sizes; using default"); Camera.Size defaultSize = parameters.getPreviewSize(); return new Point(defaultSize.width, defaultSize.height); }/* ww w . j a v a 2s .c om*/ // Sort by size, descending List<Camera.Size> supportedPreviewSizes = new ArrayList<Camera.Size>(rawSupportedSizes); Collections.sort(supportedPreviewSizes, new Comparator<Camera.Size>() { @Override public int compare(Camera.Size a, Camera.Size b) { int aPixels = a.height * a.width; int bPixels = b.height * b.width; if (bPixels < aPixels) { return -1; } if (bPixels > aPixels) { return 1; } return 0; } }); if (Log.isLoggable(TAG, Log.INFO)) { StringBuilder previewSizesString = new StringBuilder(); for (Camera.Size supportedPreviewSize : supportedPreviewSizes) { previewSizesString.append(supportedPreviewSize.width).append('x') .append(supportedPreviewSize.height).append(' '); } Log.i(TAG, "Supported preview sizes: " + previewSizesString); } double screenAspectRatio = (double) screenResolution.x / (double) screenResolution.y; // Remove sizes that are unsuitable Iterator<Camera.Size> it = supportedPreviewSizes.iterator(); while (it.hasNext()) { Camera.Size supportedPreviewSize = it.next(); int realWidth = supportedPreviewSize.width; int realHeight = supportedPreviewSize.height; if (realWidth * realHeight < MIN_PREVIEW_PIXELS) { it.remove(); continue; } boolean isCandidatePortrait = realWidth < realHeight; int maybeFlippedWidth = isCandidatePortrait ? realHeight : realWidth; int maybeFlippedHeight = isCandidatePortrait ? realWidth : realHeight; double aspectRatio = (double) maybeFlippedWidth / (double) maybeFlippedHeight; double distortion = Math.abs(aspectRatio - screenAspectRatio); if (distortion > MAX_ASPECT_DISTORTION) { it.remove(); continue; } if (maybeFlippedWidth == screenResolution.x && maybeFlippedHeight == screenResolution.y) { Point exactPoint = new Point(realWidth, realHeight); Log.i(TAG, "Found preview size exactly matching screen size: " + exactPoint); return exactPoint; } } // If no exact match, use largest preview size. This was not a great // idea on older devices because // of the additional computation needed. We're likely to get here on // newer Android 4+ devices, where // the CPU is much more powerful. if (!supportedPreviewSizes.isEmpty()) { Camera.Size largestPreview = supportedPreviewSizes.get(0); Point largestSize = new Point(largestPreview.width, largestPreview.height); Log.i(TAG, "Using largest suitable preview size: " + largestSize); return largestSize; } // If there is nothing at all suitable, return current preview size Camera.Size defaultPreview = parameters.getPreviewSize(); Point defaultSize = new Point(defaultPreview.width, defaultPreview.height); Log.i(TAG, "No suitable preview sizes, using default: " + defaultSize); return defaultSize; }
From source file:net.benmoran.affectsampler.Synchronizer.java
private boolean syncObject(JSONObject object) throws SyncException { Log.i(TAG, "Sending: " + object.toString()); HttpResponse response = mClient.postJSON(getCreateSampleUri(), object.toString()); Log.i(TAG, response.getStatusLine().toString()); switch (response.getStatusLine().getStatusCode()) { case 201://from ww w. j a v a 2s . com return true; case 302: return false; default: throw new SyncException("Unexpected response to sync: " + response.getStatusLine().toString()); } }
From source file:net.bible.android.view.activity.references.NotesActivity.java
/** Called when the activity is first created. */ @Override// w w w . jav a 2 s .co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.i(TAG, "Displaying notes"); setContentView(R.layout.notes); mTitle = (TextView) findViewById(R.id.title); mWarning = (TextView) findViewById(R.id.warningText); mVerseNo = CurrentPageManager.getInstance().getCurrentBible().getCurrentVerseNo(); mChapterNotesList = DataPipe.getInstance().popNotes(); initialiseView(); Log.d(TAG, "Finished displaying Search view"); }
From source file:com.jeffthefate.stacktrace.ExceptionHandler.java
/** * Register handler for unhandled exceptions. * @param context//from w ww. j a v a2 s . c om */ public static boolean register(Application app) { mCallback = (OnStacktraceListener) app; Log.i(TAG, "Registering default exceptions handler"); // Get information about the Package PackageManager pm = app.getPackageManager(); try { PackageInfo pi; // Version pi = pm.getPackageInfo(app.getPackageName(), 0); G.APP_VERSION = pi.versionName; // Package name G.APP_PACKAGE = pi.packageName; // Files dir for storing the stack traces G.FILES_PATH = app.getFilesDir().getAbsolutePath(); // Device model G.PHONE_MODEL = android.os.Build.MODEL; // Android version G.ANDROID_VERSION = android.os.Build.VERSION.RELEASE; } catch (NameNotFoundException e) { e.printStackTrace(); } Log.d(TAG, "APP_VERSION: " + G.APP_VERSION); Log.d(TAG, "APP_PACKAGE: " + G.APP_PACKAGE); Log.d(TAG, "FILES_PATH: " + G.FILES_PATH); boolean stackTracesFound = false; // We'll return true if any stack traces were found if (searchForStackTraces().length > 0) stackTracesFound = true; new Thread() { @Override public void run() { // First of all transmit any stack traces that may be lying around submitStackTraces(); UncaughtExceptionHandler currentHandler = Thread.getDefaultUncaughtExceptionHandler(); if (currentHandler != null) { Log.d(TAG, "current handler class=" + currentHandler.getClass().getName()); } // don't register again if already registered if (!(currentHandler instanceof DefaultExceptionHandler)) { // Register default exceptions handler Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler(currentHandler)); } } }.start(); return stackTracesFound; }
From source file:Main.java
private static void copyAsset(AssetManager am, File rep, boolean force) { try {//from w ww . j a v a 2s.co m String assets[] = am.list(""); for (int i = 0; i < assets.length; i++) { boolean hp48 = assets[i].equals("hp48"); boolean hp48s = assets[i].equals("hp48s"); boolean ram = assets[i].equals("ram"); boolean rom = assets[i].equals("rom"); boolean rams = assets[i].equals("rams"); boolean roms = assets[i].equals("roms"); int required = 0; if (ram) required = 131072; else if (rams) required = 32768; else if (rom) required = 524288; else if (roms) required = 262144; //boolean SKUNK = assets[i].equals("SKUNK"); if (hp48 || rom || ram || hp48s || roms || rams) { File fout = new File(rep, assets[i]); if (!fout.exists() || fout.length() == 0 || (required > 0 && fout.length() != required) || force) { Log.i("x48", "Overwriting " + assets[i]); FileOutputStream out = new FileOutputStream(fout); InputStream in = am.open(assets[i]); byte buffer[] = new byte[8192]; int n = -1; while ((n = in.read(buffer)) > -1) { out.write(buffer, 0, n); } out.close(); in.close(); } } } } catch (IOException e) { e.printStackTrace(); } }
From source file:angel.zhuoxiu.library.pusher.PusherCallback.java
public void onEvent(PusherEvent event) { Log.i(tag, event.toString()); }
From source file:org.guohai.android.cta.utility.HttpRest.java
/** * HTTPPost?//from w w w . j a v a 2s. c om * @param url POST? * @param pairs ? * @return ?JOSN?null */ public static ResultInfo HttpPostClient(String url, List<NameValuePair> pairs) { //create http client HttpClient client = new DefaultHttpClient(); //create post request HttpPost httpPost = new HttpPost(url); //return value ResultInfo result = new ResultInfo(); //init eroor value result.State = -1000; result.Message = "posterror"; HttpEntity entity; try { entity = new UrlEncodedFormEntity(pairs, HTTP.UTF_8); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); Log.e(TAG, e.getMessage()); return result; } httpPost.setEntity(entity); //??POST? try { HttpResponse response = client.execute(httpPost); if (response.getStatusLine().getStatusCode() == 200) { HttpEntity entityHtml = response.getEntity(); BufferedReader reader = new BufferedReader(new InputStreamReader(entityHtml.getContent(), "UTF-8")); String line = null; String reString = ""; while ((line = reader.readLine()) != null) { reString += line; } if (entityHtml != null) { entityHtml.consumeContent(); } Log.i(TAG, reString); JSONObject jsonObj; try { jsonObj = new JSONObject(reString); result.State = jsonObj.getInt("state"); result.Message = jsonObj.getString("message"); return result; } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); Log.e(TAG, e.getMessage()); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); Log.e(TAG, e.getMessage()); } return result; } } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); Log.e(TAG, e.getMessage()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); Log.e(TAG, e.getMessage()); } return result; }