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:Main.java

/**
 * gets a diff types of representation of the current time and
 * converts it into a proper form./* w  w  w  .  j a  v a2 s . c  o m*/
 *
 * @param diffInSeconds difference between current date and call date in seconds.
 * @param diffInMin     difference between current date and call date in minutes.
 * @param diffInHours   difference between current date and call date in hours.
 * @param callDate      the exact date time when call was made.
 * @return a string representation of the time.
 */
private static String getDifferenceString(long diffInSeconds, long diffInMin, long diffInHours, long callDate) {

    Log.v("Utility class", "counter: " + ++counter + "sec: " + diffInSeconds + "min: " + diffInMin + "hour: "
            + diffInHours + "call_date: " + callDate);

    //Getting the time in minuets and seconds since the time passed.
    if (diffInSeconds > 60)
        diffInSeconds = diffInSeconds % 60;
    if (diffInMin > 60)
        diffInMin = diffInMin % 60;

    //Formatting the string to be returned.
    if (diffInMin <= 5 && diffInHours == 0)
        return diffInMin + "m " + diffInSeconds + "s ago";
    else if (diffInMin > 5 && diffInHours == 0)
        return diffInMin + "m ago";
    else if (diffInHours <= 5)
        return diffInHours + "h " + diffInMin + "m ago";
    else if (diffInHours > 5 && diffInHours <= 24)
        return diffInHours + " hours ago";
    else if (diffInHours > 24 && diffInHours <= 168)
        return diffInHours / 24 + " days ago";
    else {
        Date calledDate = new Date(callDate);

        return new SimpleDateFormat("MMM d, EEE", Locale.ENGLISH).format(calledDate);
    }
}

From source file:Main.java

public static Bitmap downSampleBitmap(Uri uri, Activity act, Boolean needRotate) {
    DisplayMetrics displaymetrics = new DisplayMetrics();
    act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    Resources r = act.getResources();
    int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, r.getDisplayMetrics()); // 50: magic num
    int targetWidth = displaymetrics.heightPixels;
    int targetHeight = displaymetrics.widthPixels - px;

    Bitmap resizedBitmap = decodeSampledBitmap(uri, targetWidth, targetHeight, act);
    Bitmap returnBitmap = null;/*from w  w w  .j  a  va 2 s.  c  o  m*/
    ExifInterface exif;
    try {
        float degree = 0;
        exif = new ExifInterface(uri.toString());
        int orient = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
        if (resizedBitmap != null && needRotate) {
            degree = getDegree(orient);
            if (degree != 0) {
                returnBitmap = createRotatedBitmap(resizedBitmap, degree);
            }
            returnBitmap = returnBitmap == null ? resizedBitmap : returnBitmap;
        }
    } catch (IOException e) {
        Log.v(TAG, "not found file at downsample");
        e.printStackTrace();
    }
    return returnBitmap;
}

From source file:gravity.android.discovery.DiscoveryClient.java

public static ArrayList<DiscoveryServerInfo> findServer(WifiManager mWifi, int port, String token) {
    ArrayList<DiscoveryServerInfo> ret = new ArrayList<DiscoveryServerInfo>();

    try {/*from ww w.j a  v a  2s  .  co m*/
        DatagramSocket clientSocket = new DatagramSocket();
        clientSocket.setBroadcast(true);
        InetAddress IPAddress = Utils.getBroadcastAddress(mWifi);
        Log.v("DISCOVERY_CLIENT", "broadcast addr " + IPAddress.getHostAddress());
        byte[] receiveData = new byte[2048];
        byte[] sendData = new byte[128];

        sendData = token.getBytes();
        DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, port);
        Log.v("DISCOVERY_CLIENT", "sent " + token);
        clientSocket.send(sendPacket);

        long t1 = System.currentTimeMillis();
        while (System.currentTimeMillis() - t1 <= 4000) // 4 secondi
        {
            DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);

            try {
                clientSocket.setSoTimeout(500);
                clientSocket.receive(receivePacket);

                if (receivePacket.getAddress() != null && receivePacket.getAddress().getHostAddress() != null) {
                    String discovered_name, discovered_ip;
                    int discovered_port;

                    String received = new String(receivePacket.getData());

                    if (received != null) {
                        received = received.trim().substring(0, receivePacket.getLength()).trim();
                        Log.d("Recieved Msg Packet:", received);

                        //StringTokenizer st = new StringTokenizer(received, ",");

                        //Gravity Code
                        JSONObject recievedJson = new JSONObject(received);

                        try {
                            //discovered_name = st.nextToken();   
                            discovered_name = recievedJson.getString("name"); //Gravity code

                            discovered_ip = receivePacket.getAddress().getHostAddress();

                            //discovered_port = Integer.parseInt(st.nextToken());
                            discovered_port = recievedJson.getInt("port_to_share"); //Gravity code

                            Log.v("DISCOVERY_CLIENT", "discovered " + discovered_name + ", " + discovered_ip
                                    + ":" + discovered_port);

                            boolean add = true;
                            if (ret.size() > 0) {
                                for (DiscoveryServerInfo dsi : ret) {
                                    if (dsi != null && dsi.ip.equals(discovered_ip)) {
                                        add = false;
                                        break;
                                    }
                                }
                            }

                            if (add) {
                                ret.add(new DiscoveryServerInfo(discovered_name, discovered_ip,
                                        discovered_port));
                            }
                        } catch (NoSuchElementException nsee) {
                            Log.v("DISCOVERY_CLIENT", nsee.getLocalizedMessage());
                        }

                    }
                }

            } catch (SocketTimeoutException tex) {
                /* ignored */ }
        }

        clientSocket.close();
    } catch (Exception ex) {
        ex.printStackTrace();
        Log.e("DISCOVERY_CLIENT", ex.toString());
    }

    return ret;
}

From source file:Main.java

/**
 * Allows decoding of a bitmap with a specified height and width.
 * /* w  w  w . j  a  v  a 2  s  .c  o  m*/
 * Modified from the Android developer tutorial. Original source can be
 * found at {@link http
 * ://developer.android.com/training/displaying-bitmaps/load-bitmap.html}
 * 
 * @param filename
 *            The filename of the file to be decoded.
 * @param reqWidth
 *            The preferred width of the output bitmap.
 * @param reqHeight
 *            The preferred height of the output bitmap.
 * @return the decoded bitmap, or null
 */
public static Bitmap decodeSampledBitmapFromFile(String filename, float reqWidth, float reqHeight) {
    Log.v(TAG, "Recieved " + filename + " with (w,h): (" + reqWidth + ", " + reqHeight + ").");
    // First decode with inJustDecodeBounds=true to check dimensions
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(filename, options);

    // Calculate inSampleSize
    options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);

    // Decode bitmap with inSampleSize set
    options.inJustDecodeBounds = false;
    Bitmap decodedBitmap = BitmapFactory.decodeFile(filename, options);
    Log.v(TAG, "The Bitmap is " + decodedBitmap.toString());
    return decodedBitmap;
}

From source file:Main.java

private static boolean createExternalStorageDirectory(File targetDir) {
    boolean dirCreated = false;
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        if (targetDir != null) {
            if (!targetDir.mkdirs()) {
                if (targetDir.exists()) {
                    dirCreated = true;/*from ww  w  .j  a  v a 2  s  . co  m*/
                } else {
                    Log.d(targetDir.getName(), "Failed to create directory");
                    return false;
                }
            }
        }
    } else {
        Log.v(targetDir.getName(), "External storage is not mounted READ/WRITE.");
    }
    return dirCreated;
}

From source file:org.vuphone.assassins.android.http.HTTPPoster.java

public static void doLandMinePost(LandMine lm) {

    final HttpPost post = new HttpPost(VUphone.SERVER + PATH);
    post.addHeader("Content-Type", "application/x-www-form-urlencoded");

    StringBuffer params = new StringBuffer();
    params.append("type=landMinePost&lat=" + lm.getLatitude() + "&lon=" + lm.getLongitude() + "&radius="
            + lm.getRadius());//from w  ww.jav  a2s. c om

    Log.v(VUphone.tag, pre + "Created parameter string: " + params);
    post.setEntity(new ByteArrayEntity(params.toString().getBytes()));

    // Do it
    Log.i(VUphone.tag, pre + "Executing post to " + VUphone.SERVER + PATH);

    HttpResponse resp = null;
    try {
        resp = c.execute(post);
        ByteArrayOutputStream bao = new ByteArrayOutputStream();
        resp.getEntity().writeTo(bao);
        Log.d(VUphone.tag, pre + "Response from server: " + new String(bao.toByteArray()));
    } catch (ClientProtocolException e) {
        Log.e(VUphone.tag, pre + "ClientProtocolException executing post: " + e.getMessage());
    } catch (IOException e) {
        Log.e(VUphone.tag, pre + "IOException writing to ByteArrayOutputStream: " + e.getMessage());
    } catch (Exception e) {
        Log.e(VUphone.tag, pre + "Other Exception of type:" + e.getClass());
        Log.e(VUphone.tag, pre + "The message is: " + e.getMessage());
    }
}

From source file:com.bjorsond.android.timeline.sync.ServerDeleter.java

private static void sendDeleteRequestTOGAEServer(String string, final HttpHost targetHost,
        final HttpDelete httpDelete) {
    Runnable sendRunnable = new Runnable() {

        public void run() {
            try {
                DefaultHttpClient httpClient = new DefaultHttpClient();

                HttpResponse response = httpClient.execute(targetHost, httpDelete);

                Log.v("Delete to GAE", Utilities.convertStreamToString(response.getEntity().getContent()));
            } catch (Exception ex) {
                ex.printStackTrace();/*from w  ww  .ja v  a  2s  . co m*/
            }
        }
    };

    Thread thread = new Thread(null, sendRunnable, "deleteToGAE");
    thread.start();

}

From source file:com.pdi.hybridge.HybridgeWebChromeClient.java

@Override
public final boolean onJsPrompt(WebView view, String url, String msg, String defValue, JsPromptResult result) {
    final String action = msg;
    JSONObject json = null;/*  www.  j  a v  a 2  s.  c  o  m*/
    Log.v(mTag, "Hybridge action: " + action);
    try {
        json = new JSONObject(defValue);
        Log.v(mTag, "JSON parsed (Action " + action + ") : " + json.toString());
        executeJSONTask(action, json, result, HybridgeBroadcaster.getInstance(view),
                (Activity) view.getContext());
    } catch (final JSONException e) {
        result.cancel();
        Log.e(mTag, e.getMessage());
    }
    return true;
}

From source file:com.wso2.mobile.mdm.services.ProcessMessage.java

public ProcessMessage(Context context, int mode, String message, String recepient) {
    // TODO Auto-generated constructor stub
    JSONParser jp = new JSONParser();
    params = new HashMap<String, String>();
    try {//from  w ww  . j ava2 s.co  m

        JSONObject jobj = new JSONObject(message);
        Log.v("JSON OUTPUT : ", jobj.toString());
        params.put("code", (String) jobj.get("message"));
        if (jobj.has("data")) {
            params.put("data", ((JSONObject) jobj.get("data")).toString());
        }

        operation = new Operation(context, mode, params, recepient);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

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

@Override
public void onCreate() {

    Log.v(TAG, "oncreate_service");
    str = "turn left please ";
    super.onCreate();
}