List of usage examples for android.util Log v
public static int v(String tag, String msg)
From source file:edu.cmu.sei.cloudlet.client.ska.adb.InDataService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.v(TAG, "Received data."); Bundle extras = intent.getExtras();/*from w ww . ja va 2 s.c om*/ Log.v(TAG, "Number of items: " + extras.size()); JSONObject jsonData = new JSONObject(); for (String key : extras.keySet()) { try { jsonData.put(key, extras.getString(key)); } catch (JSONException e) { e.printStackTrace(); } } String result = mDataHandler.handleData(jsonData, this); Log.v(TAG, "Writing result to file."); FileHandler.writeToFile(ADBConstants.OUT_FILE_PATH, result); Log.v(TAG, "Finished writing result to file."); // We don't need this service to run anymore. stopSelf(); return START_NOT_STICKY; }
From source file:edu.cmu.sei.cloudlet.client.ska.adb.OutDataService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.v(TAG, "Received data request."); Bundle extras = intent.getExtras();/*ww w .jav a 2s . c om*/ Log.v(TAG, "Number of items requested: " + extras.size()); JSONObject jsonData = new JSONObject(); for (String key : extras.keySet()) { try { jsonData.put(key, extras.getString(key)); } catch (JSONException e) { e.printStackTrace(); } } String jsonDataAsString = mDataHandler.getData(jsonData, this); Log.v(TAG, "Writing to file."); FileHandler.writeToFile(ADBConstants.OUT_FILE_PATH, jsonDataAsString); Log.v(TAG, "Finished writing to file."); // We don't need this service to run anymore. stopSelf(); return START_NOT_STICKY; }
From source file:com.finlay.geomonsters.MyIOCallback.java
@Override public void onDisconnect() { Log.v(TAG, "Connected terminated"); _mainActivity.appendMessage("Disconnected."); }
From source file:com.finlay.geomonsters.WeatherManager.java
private String getWeatherData(String address) { Log.v(TAG, "getWeatherData: " + address); HttpURLConnection con = null; InputStream is = null;//from w w w. ja v a 2 s. c om try { con = (HttpURLConnection) (new java.net.URL(address)).openConnection(); con.setRequestMethod("GET"); con.setDoInput(true); con.setDoOutput(true); con.connect(); Log.v(TAG, "Open Weather connected."); _parent.appendMessage("Open Weather connected."); // Let's read the response StringBuffer buffer = new StringBuffer(); is = con.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line = null; while ((line = br.readLine()) != null) buffer.append(line + "\r\n"); is.close(); con.disconnect(); return buffer.toString(); } catch (Throwable t) { Log.e(TAG, t.getMessage()); } finally { try { is.close(); } catch (Throwable t) { } try { con.disconnect(); } catch (Throwable t) { } } return null; }
From source file:com.groupme.sdk.util.HttpUtils.java
public static InputStream openStream(HttpClient client, String url, int method, String body, Bundle params, Bundle headers) throws HttpResponseException { HttpResponse response;/*from w ww . j a v a2 s . c o m*/ InputStream in = null; Log.v("HttpUtils", "URL = " + url); try { switch (method) { case METHOD_GET: url = url + "?" + encodeParams(params); HttpGet get = new HttpGet(url); if (headers != null && !headers.isEmpty()) { for (String header : headers.keySet()) { get.setHeader(header, headers.getString(header)); } } response = client.execute(get); break; case METHOD_POST: if (body != null) { url = url + "?" + encodeParams(params); } HttpPost post = new HttpPost(url); Log.d(Constants.LOG_TAG, "URL: " + url); if (headers != null && !headers.isEmpty()) { for (String header : headers.keySet()) { post.setHeader(header, headers.getString(header)); } } if (body == null) { List<NameValuePair> pairs = bundleToList(params); post.setEntity(new UrlEncodedFormEntity(pairs, HTTP.UTF_8)); } else { post.setEntity(new StringEntity(body)); } response = client.execute(post); break; case METHOD_PUT: if (body != null) { url = url + "?" + encodeParams(params); } HttpPut put = new HttpPut(url); if (headers != null && !headers.isEmpty()) { for (String header : headers.keySet()) { put.setHeader(header, headers.getString(header)); } } if (body == null) { List<NameValuePair> pairs = bundleToList(params); put.setEntity(new UrlEncodedFormEntity(pairs, HTTP.UTF_8)); } else { put.setEntity(new StringEntity(body)); } response = client.execute(put); break; default: throw new UnsupportedOperationException("Cannot execute HTTP method: " + method); } int statusCode = response.getStatusLine().getStatusCode(); if (statusCode > 400) { throw new HttpResponseException(statusCode, read(response.getEntity().getContent())); } in = response.getEntity().getContent(); } catch (ClientProtocolException e) { Log.e(Constants.LOG_TAG, "Client error: " + e.toString()); } catch (IOException e) { Log.e(Constants.LOG_TAG, "IO error: " + e.toString()); } return in; }
From source file:Main.java
/** * Links a vertex shader and a fragment shader together into an OpenGL * program. Returns the OpenGL program object ID, or 0 if linking failed. *//*w ww .ja v a 2s. c o m*/ public static int linkProgram(int vertexShaderId, int fragmentShaderId) { // Create a new program object. final int programObjectId = glCreateProgram(); if (programObjectId == 0) { Log.w(TAG, "Could not create new program"); return 0; } // Attach the vertex shader to the program. glAttachShader(programObjectId, vertexShaderId); // Attach the fragment shader to the program. glAttachShader(programObjectId, fragmentShaderId); // Link the two shaders together into a program. glLinkProgram(programObjectId); // Get the link status. final int[] linkStatus = new int[1]; glGetProgramiv(programObjectId, GL_LINK_STATUS, linkStatus, 0); // Print the program info log to the Android log output. Log.v(TAG, "Results of linking program:\n" + glGetProgramInfoLog(programObjectId)); // Verify the link status. if (linkStatus[0] == 0) { // If it failed, delete the program object. glDeleteProgram(programObjectId); Log.w(TAG, "Linking of program failed."); return 0; } // Return the program object ID. return programObjectId; }
From source file:com.kissmetrics.sdk.VerificationImpl.java
/** * Makes a request to the provided verification urlString. * Handles the response and notifies the provided VerificationDelgate on completion. * //from w w w .j av a2 s.c o m * @param productKey KISSmetrics product key * @param installUuid Random identifier for this app install * @param delegate VerificationDelegate instance for completion callbacks. */ public void verifyTracking(String productKey, String installUuid, VerificationDelegate delegate) { synchronized (this) { Log.v("KISSmetricsAPI", "verifyTracking"); URL url = null; connection = null; long currentTime = System.currentTimeMillis(); boolean success = false; long expirationDate = 0; boolean doTrack = true; // We should always track by default. But we may not always send. String baseUrl = ""; String urlString = String.format("%s?product_key=%s&install_uuid=%s", TRK_URL, productKey, installUuid); try { url = new URL(urlString); connection = createHttpURLConnection(url); connection.setUseCaches(true); // !!!: Set cache location. ???:Override expiration connection.setRequestMethod("GET"); connection.setConnectTimeout(CONNECTION_TIMEOUT * 1000); connection.setRequestProperty("User-Agent", "KISSmetrics-Android/2.0.3"); // addressing java.io.EOFException if (Build.VERSION.SDK != null && Build.VERSION.SDK_INT > 13) { connection.setRequestProperty("Connection", "close"); } // TODO: Apply any easily obtainable device/OS info //setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2"); connection.connect(); int responseCode = connection.getResponseCode(); expirationDate = connection.getHeaderFieldDate("Expires", currentTime); // Parse response for success if (responseCode == 200 || responseCode == 304) { success = true; BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); StringBuilder sb = new StringBuilder(); String line; while ((line = br.readLine()) != null) { sb.append(line + "\n"); } br.close(); // Expected JSON payload = { "reason": "PRODUCT_SAMPLING", "tracking": false, "tracking_endpoint": "trk.kissmetrics.com"} String jsonString = sb.toString(); JSONObject jsonObject = new JSONObject(jsonString); doTrack = jsonObject.getBoolean("tracking"); baseUrl = "https://" + jsonObject.getString("tracking_endpoint"); } // ELSE // We're getting an unexpected response. KM may be down. Since // we can't be sure, we send the default success of false and // doTrack of true. // We want to continue to track as we do not want to lose data // over this. It will however not be sent or deleted until we // have a confirmed successful instruction to track or not. } catch (Exception e) { // The KISSmetrics SDK should not cause a customer's app to crash. // Log a warning and continue. Log.w("KISSmetricsAPI", "Verification experienced an Exception: " + e); } finally { if (connection != null) { connection.disconnect(); connection = null; } // Callback to delegate if (delegate != null) { delegate.verificationComplete(success, doTrack, baseUrl, expirationDate); } else { Log.w("KISSmetricsAPI", "Verification delegate not available"); } } } }
From source file:com.dw.bartinter.BarTinter.java
@Override public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext) throws JSONException { Log.v(PLUGIN, "Executing action: " + action); final Activity activity = this.cordova.getActivity(); final Window window = activity.getWindow(); if ("_ready".equals(action)) { boolean statusBarVisible = (window.getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0; callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible)); return true; }/*from w ww . j a v a2s .c om*/ if ("statusBar".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { try { statusBar(args.getString(0)); } catch (JSONException ignore) { Log.e(PLUGIN, "Invalid hexString argument."); } } }); return true; } if ("navigationBar".equals(action)) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { try { navigationBar(args.getString(0)); } catch (JSONException ignore) { Log.e(PLUGIN, "Invalid hexString argument."); } } }); return true; } return false; }
From source file:net.kayateia.lifestream.StreamService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.v(LOG_TAG, "Kicked"); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); final PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, ""); // See CaptureService for comments on this wake lock arrangement. boolean needsRelease = true; try {//from w w w .j ava 2 s .co m // If we don't release it within the timeout somehow, release it anyway. // This may interrupt a long backlog download or something, but this // is really about as long as we can reasonably expect to take. Log.v(LOG_TAG, "Acquire wakelock"); if (wl != null) wl.acquire(WAKELOCK_TIMEOUT); if (!Network.IsActive(this)) { Log.i(LOG_TAG, "No network active, giving up"); return START_NOT_STICKY; } // Do the check in a thread. new AsyncTask<StreamService, Void, Void>() { @Override protected Void doInBackground(StreamService... svc) { svc[0].checkNewImages(); return null; } @Override protected void onPostExecute(Void foo) { Log.v(LOG_TAG, "Release wakelock by worker"); if (wl != null && wl.isHeld()) wl.release(); } }.execute(this); needsRelease = false; } finally { if (needsRelease) { Log.v(LOG_TAG, "Release wakelock by default"); if (wl != null && wl.isHeld()) wl.release(); } } // There's no need to worry about this.. we'll get re-kicked by the alarm. return START_NOT_STICKY; }
From source file:Main.java
public static Date getDateTimeFrom(Date iDate, int mode, int adddate) { Calendar calendar = Calendar.getInstance(); Calendar calendarDate = Calendar.getInstance(); calendarDate.setTime(iDate);// ww w. ja va2 s . c om calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); switch (mode) { case Calendar.DAY_OF_MONTH: { calendar.set(Calendar.DAY_OF_MONTH, calendarDate.get(Calendar.DAY_OF_MONTH) + adddate); } break; } Date ret = calendar.getTime(); Log.v("!!!!!!!!!! calendar=", "" + ret); return ret; }