Example usage for android.util Log w

List of usage examples for android.util Log w

Introduction

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

Prototype

public static int w(String tag, Throwable tr) 

Source Link

Usage

From source file:Main.java

/**
 * Compiles a shader, returning the OpenGL object ID.
 *///from  w w  w .ja v  a2 s  .  co  m
private static int compileShader(int type, String shaderCode) {
    // Create a new shader object.
    final int shaderObjectId = glCreateShader(type);

    if (shaderObjectId == 0) {
        if (IS_LOGGING_ON) {
            Log.w(TAG, "Could not create new shader.");
        }

        return 0;
    }

    // Pass in the shader source.
    glShaderSource(shaderObjectId, shaderCode);

    // Compile the shader.
    glCompileShader(shaderObjectId);

    // Get the compilation status.
    final int[] compileStatus = new int[1];
    glGetShaderiv(shaderObjectId, GL_COMPILE_STATUS, compileStatus, 0);

    if (IS_LOGGING_ON) {
        // Print the shader info log to the Android log output.
        Log.v(TAG, "Results of compiling source:" + "\n" + shaderCode + "\n:"
                + glGetShaderInfoLog(shaderObjectId));
    }

    // Verify the compile status.
    if (compileStatus[0] == 0) {
        // If it failed, delete the shader object.
        glDeleteShader(shaderObjectId);

        if (IS_LOGGING_ON) {
            Log.w(TAG, "Compilation of shader failed.");
            throw new RuntimeException("Compilation of shader failed.");
        }

        return 0;
    }

    // Return the shader object ID.
    return shaderObjectId;
}

From source file:Main.java

public static void debug(Object msg, Object msg2) {
    if (debug) {//from w w  w .j  ava  2  s .  c om
        Log.w("AQuery", msg + ":" + msg2);
    }
}

From source file:Main.java

public static Bitmap decodeUrl(String urlString) {
    URL url;/*  w w w .ja  v  a2 s  . c o m*/

    try {
        url = new URL(urlString);
    } catch (MalformedURLException e) {
        Log.w(LOGTAG, "decodeUrl: malformed URL " + urlString);
        return null;
    }

    return decodeUrl(url);
}

From source file:Main.java

public static void logw(String msg) {
    if (!debug) {
        return;/* ww  w .ja v a  2s  . c o  m*/
    }
    Log.w("ldx", "" + msg);
}

From source file:Main.java

public static boolean isExternalStorageWriteable() {
    boolean writealbe = false;
    long start = System.currentTimeMillis();
    if (TextUtils.equals(Environment.MEDIA_MOUNTED, Environment.getExternalStorageState())) {
        File esd = Environment.getExternalStorageDirectory();
        if (esd.exists() && esd.canWrite()) {
            File file = new File(esd, ".696E5309-E4A7-27C0-A787-0B2CEBF1F1AB");
            if (file.exists()) {
                writealbe = true;/*from w  w w.  j  a  va  2 s.  co  m*/
            } else {
                try {
                    writealbe = file.createNewFile();
                } catch (IOException e) {
                    Log.w(TAG, "isExternalStorageWriteable() can't create test file.");
                }
            }
        }
    }
    long end = System.currentTimeMillis();
    Log.i(TAG, "Utility.isExternalStorageWriteable(" + writealbe + ") cost " + (end - start) + "ms.");
    return writealbe;
}

From source file:Main.java

/**
 * Creates Log Warning message according to given tag and message.
 *
 * @param tag the name of the class whose instance called this function
 * @param message warning message to output to log
 *//*from www  . j  a  v a 2s .c om*/
public static void LogWarning(String tag, String message) {
    Log.w(tag, message);
}

From source file:Main.java

public static void copyFileToDir(File sourceFile, File destFile) {
    InputStream inStream = null;/*from w  w  w.  j a  v a2s  .com*/
    OutputStream outStream = null;

    try {

        inStream = new FileInputStream(sourceFile);
        outStream = new FileOutputStream(destFile);

        byte[] buffer = new byte[1024];

        int length;

        // copy the file content in bytes
        while ((length = inStream.read(buffer)) > 0) {

            outStream.write(buffer, 0, length);

        }

        Log.d(TAG, "File copied: " + destFile);

    } catch (IOException e) {
        Log.w(TAG, e.toString());
    } finally {
        if (inStream != null) {
            try {
                inStream.close();
            } catch (IOException e) {
                Log.d(TAG, e.toString());
            }
        }

        if (outStream != null) {
            try {
                outStream.close();
            } catch (IOException e) {
                Log.d(TAG, e.toString());
            }
        }
    }
}

From source file:Main.java

public static String getCompleteAddressString(Context context, double LATITUDE, double LONGITUDE) {
    String strAdd = "";
    Geocoder geocoder = new Geocoder(context, Locale.getDefault());
    try {/*  w  ww .  ja  v a 2 s  .  co  m*/
        List<Address> addresses = geocoder.getFromLocation(LATITUDE, LONGITUDE, 1);
        if (addresses != null) {
            Address returnedAddress = addresses.get(0);
            StringBuilder strReturnedAddress = new StringBuilder("");

            for (int i = 0; i < returnedAddress.getMaxAddressLineIndex(); i++) {
                strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\n");
            }
            strAdd = strReturnedAddress.toString();
            Log.w("My Current loction address", "" + strReturnedAddress.toString());
        } else {
            Log.w("My Current loction address", "No Address returned!");
        }

    } catch (Exception e) {
        e.printStackTrace();
        Log.w("My Current loction address", "Canont get Address!");
    }
    return strAdd;
}

From source file:Main.java

public static void outputData(short[] data, PrintWriter writer) {
    for (int i = 0; i < data.length; i++) {
        writer.println(String.valueOf(data[i]));
    }//  w ww  . j a  va  2  s  .c  o m
    if (writer.checkError()) {
        Log.w(TAG, "Error writing sensor event data");
    }
}

From source file:Main.java

/**
 * Locks a semaphore for handling multi threading with insert/delete/update methods.
 *
 * @param key key for inserting the locked semaphore in a hashmap.
 * @return the locked semaphore.//w  w  w  .  ja  v  a2 s  . c  o  m
 */
public static boolean lockChat(String key) {
    Semaphore semaphore = new Semaphore(1);
    Semaphore oldSemaphore = semaphoreMap.putIfAbsent(key, semaphore);

    if (oldSemaphore != null) {
        semaphore = oldSemaphore;
    }
    //semaphore.tryAcquire(30, TimeUnit.SECONDS);
    try {
        semaphore.acquire();
        return true;
    } catch (InterruptedException ignored) {
        Log.w(TAG, "Could not acquire chat: " + key);
        return false;
    }
}