Example usage for android.util Log v

List of usage examples for android.util Log v

Introduction

In this page you can find the example usage for android.util Log v.

Prototype

public static int v(String tag, String msg) 

Source Link

Document

Send a #VERBOSE log message.

Usage

From source file:net.frygo.findmybuddy.GCMIntentService.java

@Override
protected void onError(Context arg0, String arg1) {

    //Called on registration or unregistration error.
    Log.v("TAG", "GCMIntentService onError");
}

From source file:com.google.android.gcm.GCMBroadcastReceiver.java

@Override
public final void onReceive(Context context, Intent intent) {
    Log.v(TAG, "onReceive: " + intent.getAction());

    /*/*w  w w.  j  a  v a 2 s . com*/
    //Test
    for(String s : intent.getExtras().keySet())
       Log.v(TAG, "bogdan: " + "(" + s + ", " + intent.getExtras().getString(s) + ")");
            
    String bonus = intent.getExtras().getString("u");
    try {
     JSONObject obj = new JSONObject(bonus);
     Log.v(TAG, "bogdan type-> " + obj.getJSONObject("bonus").getInt("Type"));
     Log.v(TAG, "bogdan amount -> " + obj.getJSONObject("bonus").getInt("Amount"));
    } catch (JSONException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
    */

    String className = getGCMIntentServiceClassName(context);
    Log.v(TAG, "GCM IntentService class: " + className);
    // Delegates to the application-specific intent service.
    GCMBaseIntentService.runIntentInService(context, intent, className);
    setResult(Activity.RESULT_OK, null /* data */, null /* extra */);
}

From source file:ca.xecure.easychip.CommonUtilities.java

public static void http_post(String endpoint, Map<String, String> params) throws IOException {
    URL url;/*  w w  w . ja v a2 s .c  o  m*/
    try {
        url = new URL(endpoint);
    } catch (MalformedURLException e) {
        throw new IllegalArgumentException("invalid url: " + endpoint);
    }

    String body = JSONValue.toJSONString(params);
    Log.v(LOG_TAG, "Posting '" + body + "' to " + url);

    byte[] bytes = body.getBytes();
    HttpURLConnection conn = null;
    try {
        conn = (HttpURLConnection) url.openConnection();
        conn.setDoOutput(true);
        conn.setUseCaches(false);
        conn.setFixedLengthStreamingMode(bytes.length);
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "application/json");

        OutputStream out = conn.getOutputStream();
        out.write(bytes);
        out.close();

        int status = conn.getResponseCode();
        if (status != 200) {
            throw new IOException("Post failed with error code " + status);
        }
    } finally {
        if (conn != null) {
            conn.disconnect();
        }
    }
}

From source file:Main.java

static String convertUriToPath(Context context, Uri uri) {
    Log.v(TAG, "convertUriToPath : " + uri + " @" + context);

    String path = null;//w w  w  .  j  ava2s .co  m
    if (null != uri) {
        String scheme = uri.getScheme();
        if (null == scheme || scheme.equals("") || scheme.equals(ContentResolver.SCHEME_FILE)) {
            path = uri.getPath();
        } else if (scheme.equals("http")) {
            path = uri.toString();
        } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
            String[] projection = new String[] { MediaStore.MediaColumns.DATA };
            Cursor cursor = null;
            try {
                cursor = context.getContentResolver().query(uri, projection, null, null, null);
                if (null == cursor || 0 == cursor.getCount() || !cursor.moveToFirst()) {
                    throw new IllegalArgumentException("Given Uri could not be found in media store");
                }
                int pathIndex = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
                path = cursor.getString(pathIndex);
            } catch (SQLiteException e) {
                throw new IllegalArgumentException(
                        "Given Uri is not formatted in a way so that it can be found in media store.");
            } finally {
                if (null != cursor) {
                    cursor.close();
                }
            }
        } else {
            throw new IllegalArgumentException("Given Uri scheme is not supported");
        }
    }

    Log.v(TAG, "convertUriToPath : >" + path);
    return path;
}

From source file:com.rvce.rvce8thmile.driver.TTSService.java

@Override
public void onStart(Intent intent, int startId) {

    sayHello(str);/*from   w  w  w .j  ava 2  s . c  om*/
    Log.v(TAG, "onstart_service");
    gps = new GPSTracker(getApplicationContext());
    super.onStart(intent, startId);
    final SharedPreferences prefs = getSharedPreferences(MainActivity.class.getSimpleName(),
            Context.MODE_PRIVATE);
    busno = prefs.getString("busno", "nobuses");
    license = prefs.getString("license", "unlicensed");

    final android.os.Handler h = new android.os.Handler();
    Runnable r = new Runnable() {
        @Override
        public void run() {

            // create class object

            // check if GPS enabled
            if (gps.canGetLocation()) {
                latitude = gps.getLatitude();
                longitude = gps.getLongitude();

            } else {
                // can't get location
                // GPS or Network is not enabled
                // Ask user to enable GPS/network in settings
                gps.showSettingsAlert();
            }

            Thread t = new Thread(new Runnable() {
                @Override
                public void run() {
                    HttpClient httpClient = new DefaultHttpClient();
                    HttpPost httpPost = new HttpPost("http://rotaractrvce.com/bidn/updatebus.php");
                    //HttpPost httpPost=new HttpPost("http://ibmhackblind.mybluemix.net/updatebus.php");
                    BasicResponseHandler responseHandler = new BasicResponseHandler();
                    List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(4);
                    nameValuePair.add(new BasicNameValuePair("busno", busno));
                    nameValuePair.add(new BasicNameValuePair("license", license));
                    nameValuePair.add(new BasicNameValuePair("x", Double.toString(latitude)));
                    nameValuePair.add(new BasicNameValuePair("y", Double.toString(longitude)));
                    try {
                        httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
                    } catch (UnsupportedEncodingException e) {
                        // log exception
                        e.printStackTrace();
                    }
                    try {
                        ans = httpClient.execute(httpPost, responseHandler);
                        //Toast.makeText(getApplicationContext(),response,Toast.LENGTH_LONG).show();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            });
            t.start();
            try {
                t.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            Toast.makeText(getApplicationContext(), latitude.toString() + " : " + longitude.toString(),
                    Toast.LENGTH_SHORT).show();
            Toast.makeText(getApplicationContext(), ans, Toast.LENGTH_SHORT).show();
            latitude = (double) 0;
            longitude = (double) 0;
            h.postDelayed(this, 5000);
        }
    };
    h.post(r);

}

From source file:co.uk.gauntface.cordova.plugin.gcmbrowserlaunch.GCMBrowserLaunch.java

@Override
public boolean execute(String action, JSONArray args, final CallbackContext callbackContext)
        throws JSONException {
    GCMController gcmController = new GCMController(this.cordova.getActivity().getApplicationContext());
    if (action.equals("getRegId")) {
        gcmController.getRegistrationId(new GCMController.GCMControllerListener() {
            @Override//  w ww  . j  a  v a 2s  .c om
            public void onRegistrationIdReceived(String regId) {
                Log.v(C.TAG, "CordovaGCMPlugin: onRegistrationIdReceived() Registration = " + regId);
                if (regId != null && regId.length() > 0) {
                    JSONObject jsonObj = new JSONObject();
                    try {
                        jsonObj.put("regId", regId);
                        callbackContext.success(jsonObj);
                        return;
                    } catch (JSONException e) {
                        Log.e(C.TAG, "CordovaGCMPlugin: regId = " + regId, e);
                    }
                }

                callbackContext.error(-1);
            }
        });
        return true;
    }

    return false;
}

From source file:org.bishoph.oxdemo.util.GetTaskList.java

@Override
protected JSONObject doInBackground(Object... params) {
    try {/*from  ww w  .j ava  2  s. com*/
        String uri = (String) params[0];
        Log.v("OXDemo", "Attempting to get task list " + uri);
        HttpGet httpget = new HttpGet(uri);
        httpget.setHeader("Accept", "application/json, text/javascript");
        HttpResponse response = httpclient.execute(httpget, localcontext);
        HttpEntity entity = response.getEntity();
        String result = EntityUtils.toString(entity, HTTP.UTF_8);
        Log.d("OXDemo", "<<<<<<<\n" + result + "\n\n");
        JSONObject jsonObj = new JSONObject(result);
        return jsonObj;
    } catch (JSONException e) {
        Log.e("OXDemo", e.getMessage());
    } catch (ClientProtocolException e) {
        Log.e("OXDemo", e.getMessage());
    } catch (IOException e) {
        Log.e("OXDemo", e.getMessage());
    }
    return null;
}

From source file:com.plugin.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")) {
        try {//from   ww w  .  java2 s .c  o  m
            Log.v(TAG, data.getString(0));
            Log.v(TAG, data.getJSONObject(1).toString());
            String b64String = data.getString(0);
            if (b64String.startsWith("data:image")) {
                if (b64String.contains("data:image/jpeg")) {
                    b64String = b64String.substring(23);
                } else if (b64String.contains("data:image/png") || b64String.contains("data:image/gif")) {
                    b64String = b64String.substring(22);
                }

            } else {
                b64String = data.getString(0);
            }
            JSONObject params = data.getJSONObject(1);

            //Optional parameter
            String filename = (params.has("filename") ? params.getString("filename")
                    : "Weave_" + System.currentTimeMillis()) + ".png";

            String storagetype = params.has("externalStorage") ? Environment.getExternalStorageDirectory() + ""
                    : getApplicationContext().getFilesDir().getAbsolutePath();

            String folder = params.has("folder") ? storagetype + "/" + params.getString("folder")
                    : storagetype + "/Pictures/Weave";

            Boolean overwrite = params.has("overwrite") ? params.getBoolean("overwrite") : false;

            result = this.saveImage(b64String, filename, folder, overwrite, callbackContext);

        } catch (JSONException e) {
            Log.v(TAG, "Exception from json in save image action");
            Log.v(TAG, e.getMessage());
            callbackContext.error("Exception :" + e.getMessage());
            result = false;
        }

    } else if (action.equals("convertImageToBase64FromUrl")) {
        try {
            JSONArray imageUrls = data.getJSONArray(0);
            result = this.convertImageToBase64FromUrl(imageUrls, callbackContext);
        } catch (JSONException e) {
            Log.v(TAG, "Exception from json in convertImageToBase64FromUrl action");
            Log.v(TAG, e.getMessage());
            callbackContext.error("Exception :" + e.getMessage());
            result = false;
        }

    } else {

        callbackContext.error("Invalid action : " + action);
        result = false;
    }

    return result;
}

From source file:org.devtcg.five.util.streaming.LocalHttpServerTest.java

public MyHttpServer startMyHttpServer() throws IOException {
    int port = 1024 + (new Random()).nextInt(1000);

    Log.v(TAG, "Starting server on port " + port);

    MyHttpServer server = new MyHttpServer(port);
    server.start();/* w  w  w .  j av a 2s .com*/

    return server;
}

From source file:org.tritsch.android.chargefinder.CFService.java

/**
 * <code>lockup<code> will contact the chargefinder service and will retrieve
 * a/the list of stations described by the parameters.
 *
 * @param pointX - x coordinates to start the search from
 * @param pointY - y coordinates to start the search from
 * @param radius - the radius from x, y to include in the search
 *
 * @return a/the list of stations that are within the radius
 */// www  . ja  va 2  s.  c  o  m
public static List<CFStation> lookup(final String pointX, final String pointY, final String radius) {
    if (Log.isLoggable(TAG, Log.DEBUG))
        Log.d(TAG, "Enter: lookup()");
    Assert.assertNotNull(pointX);
    Assert.assertFalse(pointX.length() == 0);
    Assert.assertNotNull(pointY);
    Assert.assertFalse(pointY.length() == 0);
    Assert.assertNotNull(radius);
    Assert.assertFalse(radius.length() == 0);

    if (Log.isLoggable(TAG, Log.VERBOSE))
        Log.v(TAG, "pointX:" + pointX);
    if (Log.isLoggable(TAG, Log.VERBOSE))
        Log.v(TAG, "pointY:" + pointY);
    if (Log.isLoggable(TAG, Log.VERBOSE))
        Log.v(TAG, "radius:" + radius);

    if (Log.isLoggable(TAG, Log.VERBOSE))
        Log.v(TAG, "create the list we will return ...");
    List<CFStation> stations = new ArrayList<CFStation>();

    if (Log.isLoggable(TAG, Log.VERBOSE))
        Log.v(TAG, "create http client ...");
    HttpClient httpClient = new DefaultHttpClient();
    Assert.assertNotNull(httpClient);

    String url = "" + BASE_URL + "?point_x=" + pointX + "&point_y=" + pointY + "&radius=" + radius;
    if (Log.isLoggable(TAG, Log.VERBOSE))
        Log.v(TAG, "URL:" + url);

    if (Log.isLoggable(TAG, Log.VERBOSE))
        Log.v(TAG, "go and do it ...");
    HttpResponse response = null;
    try {
        response = httpClient.execute(new HttpGet(url));
        Assert.assertNotNull(response);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail();
    }

    if (Log.isLoggable(TAG, Log.VERBOSE))
        Log.v(TAG, "process response ...");
    JSONArray stationsObject = null;
    try {
        HttpEntity entity = response.getEntity();
        Assert.assertNotNull(entity);

        String resultString = getString(entity.getContent());
        Assert.assertNotNull(resultString);
        if (Log.isLoggable(TAG, Log.VERBOSE))
            Log.v(TAG, "Result:" + resultString);

        JSONObject resultObject = new JSONObject(resultString);
        Assert.assertNotNull(resultObject);

        stationsObject = resultObject.getJSONArray("stations");
        Assert.assertNotNull(stationsObject);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail();
    }

    if (Log.isLoggable(TAG, Log.VERBOSE))
        Log.v(TAG, "build list of stations ...");
    try {
        for (int i = 0; i < stationsObject.length(); i++) {
            JSONObject station = stationsObject.getJSONObject(i);
            Assert.assertNotNull(station);

            CFStation newStation = new CFStation();
            newStation.setName(station.getString("name"));
            newStation.setX(station.getDouble("st_x"));
            newStation.setY(station.getDouble("st_y"));

            Assert.assertTrue(stations.add(newStation));
        }
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail();
    }

    if (Log.isLoggable(TAG, Log.DEBUG))
        Log.d(TAG, "Leave: lookup()");
    return stations;
}