List of usage examples for android.util Log isLoggable
public static native boolean isLoggable(String tag, int level);
From source file:com.samsung.spen.SpenPlugin.java
private void init() { if (isStatic == null || pluginMetadata == null) { mActivity = cordova.getActivity(); String mPackageName = mActivity.getPackageName(); PackageManager pm = mActivity.getPackageManager(); try {/*from w ww .ja va 2 s . c om*/ ApplicationInfo ai = pm.getApplicationInfo(mPackageName, PackageManager.GET_META_DATA); if (ai.metaData != null) { pluginMetadata = ai.metaData.getBoolean(META_DATA); } else { pluginMetadata = false; } } catch (NameNotFoundException e) { pluginMetadata = false; } isStatic = false; int resId = mActivity.getResources().getIdentifier("spen_static", "bool", mActivity.getPackageName()); try { if (resId != 0) { isStatic = mActivity.getResources().getBoolean(resId); } } catch (Resources.NotFoundException re) { isStatic = false; } if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) { Log.d(TAG, "Static is " + isStatic); } } }
From source file:com.example.android.elizachat.ResponderService.java
@Override public void onDestroy() { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Chat Service stopped"); }/*from ww w. j av a2s . c o m*/ NotificationManagerCompat.from(this).cancel(0); mBroadcastManager = null; super.onDestroy(); }
From source file:com.google.android.mms.transaction.HttpUtils.java
/** * A helper method to send or retrieve data through HTTP protocol. * * @param token The token to identify the sending progress. * @param url The URL used in a GET request. Null when the method is * HTTP_POST_METHOD.//from ww w .j av a 2 s .c o m * @param pdu The data to be POST. Null when the method is HTTP_GET_METHOD. * @param method HTTP_POST_METHOD or HTTP_GET_METHOD. * @return A byte array which contains the response data. * If an HTTP error code is returned, an IOException will be thrown. * @throws IOException if any error occurred on network interface or * an HTTP error code(>=400) returned from the server. */ public static byte[] httpConnection(Context context, long token, String url, byte[] pdu, int method, boolean isProxySet, String proxyHost, int proxyPort) throws IOException { if (url == null) { throw new IllegalArgumentException("URL must not be null."); } if (LOCAL_LOGV) { Log.v(TAG, "httpConnection: params list"); Log.v(TAG, "\ttoken\t\t= " + token); Log.v(TAG, "\turl\t\t= " + url); Log.v(TAG, "\tmethod\t\t= " + ((method == HTTP_POST_METHOD) ? "POST" : ((method == HTTP_GET_METHOD) ? "GET" : "UNKNOWN"))); Log.v(TAG, "\tisProxySet\t= " + isProxySet); Log.v(TAG, "\tproxyHost\t= " + proxyHost); Log.v(TAG, "\tproxyPort\t= " + proxyPort); // TODO Print out binary data more readable. //Log.v(TAG, "\tpdu\t\t= " + Arrays.toString(pdu)); } AndroidHttpClient client = null; try { // Make sure to use a proxy which supports CONNECT. URI hostUrl = new URI(url); HttpHost target = new HttpHost(hostUrl.getHost(), hostUrl.getPort(), HttpHost.DEFAULT_SCHEME_NAME); client = createHttpClient(context); HttpRequest req = null; switch (method) { case HTTP_POST_METHOD: ProgressCallbackEntity entity = new ProgressCallbackEntity(context, token, pdu); // Set request content type. entity.setContentType("application/vnd.wap.mms-message"); HttpPost post = new HttpPost(url); post.setEntity(entity); req = post; break; case HTTP_GET_METHOD: req = new HttpGet(url); break; default: Log.e(TAG, "Unknown HTTP method: " + method + ". Must be one of POST[" + HTTP_POST_METHOD + "] or GET[" + HTTP_GET_METHOD + "]."); return null; } // Set route parameters for the request. HttpParams params = client.getParams(); if (isProxySet) { ConnRouteParams.setDefaultProxy(params, new HttpHost(proxyHost, proxyPort)); } req.setParams(params); // Set necessary HTTP headers for MMS transmission. req.addHeader(HDR_KEY_ACCEPT, HDR_VALUE_ACCEPT); { String xWapProfileTagName = MmsConfig.getUaProfTagName(); String xWapProfileUrl = MmsConfig.getUaProfUrl(); if (xWapProfileUrl != null) { if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) { Log.d(LogTag.TRANSACTION, "[HttpUtils] httpConn: xWapProfUrl=" + xWapProfileUrl); } req.addHeader(xWapProfileTagName, xWapProfileUrl); } } // Extra http parameters. Split by '|' to get a list of value pairs. // Separate each pair by the first occurrence of ':' to obtain a name and // value. Replace the occurrence of the string returned by // MmsConfig.getHttpParamsLine1Key() with the users telephone number inside // the value. String extraHttpParams = MmsConfig.getHttpParams(); if (extraHttpParams != null) { String line1Number = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)) .getLine1Number(); String line1Key = MmsConfig.getHttpParamsLine1Key(); String paramList[] = extraHttpParams.split("\\|"); for (String paramPair : paramList) { String splitPair[] = paramPair.split(":", 2); if (splitPair.length == 2) { String name = splitPair[0].trim(); String value = splitPair[1].trim(); if (line1Key != null) { value = value.replace(line1Key, line1Number); } if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(value)) { req.addHeader(name, value); } } } } req.addHeader(HDR_KEY_ACCEPT_LANGUAGE, HDR_VALUE_ACCEPT_LANGUAGE); HttpResponse response = client.execute(target, req); StatusLine status = response.getStatusLine(); if (status.getStatusCode() != 200) { // HTTP 200 is success. throw new IOException("HTTP error: " + status.getReasonPhrase()); } HttpEntity entity = response.getEntity(); byte[] body = null; if (entity != null) { try { if (entity.getContentLength() > 0) { body = new byte[(int) entity.getContentLength()]; DataInputStream dis = new DataInputStream(entity.getContent()); try { dis.readFully(body); } finally { try { dis.close(); } catch (IOException e) { Log.e(TAG, "Error closing input stream: " + e.getMessage()); } } } } finally { if (entity != null) { entity.consumeContent(); } } } return body; } catch (URISyntaxException e) { handleHttpConnectionException(e, url); } catch (IllegalStateException e) { handleHttpConnectionException(e, url); } catch (IllegalArgumentException e) { handleHttpConnectionException(e, url); } catch (SocketException e) { handleHttpConnectionException(e, url); } catch (Exception e) { handleHttpConnectionException(e, url); } finally { if (client != null) { client.close(); } } return null; }
From source file:com.royclarkson.springagram.PhotoAddFragment.java
private File createImageFile() throws IOException { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM); File image = File.createTempFile(imageFileName, ".jpg", storageDir); this.photoPath = image.getAbsolutePath(); if (Log.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "PhotoPath: " + this.photoPath); }//w w w. j a va 2 s .co m return image; }
From source file:com.example.android.jumpingjack.MainActivity.java
@Override protected void onPause() { super.onPause(); mSensorManager.unregisterListener(this); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Unregistered for sensor events"); }//from ww w .j a va 2s .c o m }
From source file:com.samsung.richnotification.RichNotification.java
/** * Checks if the device supports RichNotification feature. * * @param callbackContext//ww w .j av a 2 s . c o m * The callback id used when calling back into JavaScript. * @return true if the RichNotification is supported or false if not supported. * */ private boolean isRichNotificationSupported(CallbackContext callbackContext) { if (mIsRichSupported) return true; if (Log.isLoggable(RICHNOTI, Log.DEBUG)) Log.d(TAG, "Checking RichNotification support..."); Srn srn = new Srn(); try { // Initialize an instance of Srn. srn.initialize(mContext); } catch (SsdkUnsupportedException e) { // Error handling if (e.getType() == SsdkUnsupportedException.VENDOR_NOT_SUPPORTED) { Log.e(TAG, "Initialization error. Vendor is not Samsung."); callbackContext.error(RichNotificationHelper.VENDOR_NOT_SUPPORTED); } else if (e.getType() == SsdkUnsupportedException.DEVICE_NOT_SUPPORTED) { Log.e(TAG, "Initialization error. Device not supported."); callbackContext.error(RichNotificationHelper.DEVICE_NOT_SUPPORTED); } else if (e.getType() == SsdkUnsupportedException.LIBRARY_NOT_INSTALLED) { Log.e(TAG, "Initialization error. Device not supported."); callbackContext.error(RichNotificationHelper.LIBRARY_NOT_INSTALLED); } else if (e.getType() == SsdkUnsupportedException.LIBRARY_UPDATE_IS_RECOMMENDED) { Log.e(TAG, "Initialization error. Device not supported."); callbackContext.error(RichNotificationHelper.LIBRARY_UPDATE_IS_RECOMMENDED); } else if (e.getType() == SsdkUnsupportedException.LIBRARY_UPDATE_IS_REQUIRED) { Log.e(TAG, "Initialization error. Device not supported."); callbackContext.error(RichNotificationHelper.LIBRARY_UPDATE_IS_REQUIRED); } else { Log.e(TAG, "Initialization error."); callbackContext.error("Initialization error"); } return false; } mIsRichSupported = true; return true; }
From source file:com.abajeli.wearable.gesturecadabra.MainActivity.java
@Override protected void onResume() { super.onResume(); if (mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL)) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Successfully registered for the sensor updates"); }/* w w w . j a v a2 s .c o m*/ } }
From source file:com.google.android.apps.forscience.whistlepunk.metadata.EditTriggerFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mSensorId = getArguments().getString(ARG_SENSOR_ID); mExperimentId = getArguments().getString(ARG_EXPERIMENT_ID); try {/*www . jav a 2s.c o m*/ mSensorLayout = GoosciSensorLayout.SensorLayout .parseFrom(getArguments().getByteArray(ARG_SENSOR_LAYOUT)); } catch (InvalidProtocolBufferNanoException e) { if (Log.isLoggable(TAG, Log.ERROR)) { Log.e(TAG, "Error parsing the SensorLayout", e); } mSensorLayout = RecordFragment.defaultLayout(); } mSensorLayoutPosition = getArguments().getInt(ARG_LAYOUT_POSITION); String triggerId = getArguments().getString(ARG_TRIGGER_ID, ""); if (!TextUtils.isEmpty(triggerId)) { try { mTriggerToEdit = new SensorTrigger(triggerId, mSensorId, 0, GoosciSensorTriggerInformation.TriggerInformation .parseFrom(getArguments().getByteArray(ARG_TRIGGER_INFO))); } catch (InvalidProtocolBufferNanoException e) { if (Log.isLoggable(TAG, Log.ERROR)) { Log.e(TAG, "Error parsing the SensorTrigger", e); } // We will make a new trigger, since we could not parse the one to edit. mTriggerToEdit = null; } } }
From source file:com.hitomi.basic.view.percentlayout.PercentLayoutHelper.java
private static PercentLayoutInfo setWidthAndHeightVal(TypedArray array, PercentLayoutInfo info) { PercentLayoutInfo.PercentVal percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_widthPercent, true); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent width: " + percentVal.percent); }//from w ww. j av a2 s.com info = checkForInfoExists(info); info.widthPercent = percentVal; } percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_heightPercent, false); if (percentVal != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "percent height: " + percentVal.percent); } info = checkForInfoExists(info); info.heightPercent = percentVal; } return info; }
From source file:com.github.mguidi.asyncop.AsyncOpHelper.java
/** * @param action action//www . j av a2 s . com * @param args arguments * @return id of the request */ public int execute(String action, Bundle args) { int idRequest = mNextIdRequest++; mPendingRequests.add(idRequest); mMapPendingRequestsAction.putString(String.valueOf(idRequest), action); Intent intent = new Intent(Constants.ACTION_ASYNCOP); intent.putExtra(Constants.ARGS_ACTION, action); intent.putExtra(Constants.ARGS_ID_HELPER, mIdHelper); intent.putExtra(Constants.ARGS_ID_REQUEST, idRequest); intent.putExtra(Constants.ARGS_ARGS, args); if (!LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent)) { if (Log.isLoggable(Constants.LOG_TAG, Log.ERROR)) { Log.e(Constants.LOG_TAG, "asyncop manager not initialize"); } throw new RuntimeException("asyncop manager not initialize"); } return idRequest; }