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

private static int loadBitmapIntoOpenGL(Bitmap bitmap) {
    final int[] textureObjectIds = new int[1];
    glGenTextures(1, textureObjectIds, 0);

    if (textureObjectIds[0] == 0) {
        if (IS_LOGGING_ON) {
            Log.w(TAG, "Could not generate a new OpenGL texture object.");
        }// www  .  ja va2s  . co m
        return 0;
    }

    if (bitmap == null) {
        if (IS_LOGGING_ON) {
            Log.w(TAG, "Bitmap could not be decoded.");
        }

        glDeleteTextures(1, textureObjectIds, 0);
        return 0;
    }
    // Bind to the texture in OpenGL
    glBindTexture(GL_TEXTURE_2D, textureObjectIds[0]);

    // Set filtering: a default must be set, or the texture will be
    // black.
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    // Load the bitmap into the bound texture.
    texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);

    // Note: Following code may cause an error to be reported in the
    // ADB log as follows: E/IMGSRV(20095): :0: HardwareMipGen:
    // Failed to generate texture mipmap levels (error=3)
    // No OpenGL error will be encountered (glGetError() will return
    // 0). If this happens, just squash the source image to be
    // square. It will look the same because of texture coordinates,
    // and mipmap generation will work.

    glGenerateMipmap(GL_TEXTURE_2D);

    // Recycle the bitmap, since its data has been loaded into
    // OpenGL.
    bitmap.recycle();

    // Unbind from the texture.
    glBindTexture(GL_TEXTURE_2D, 0);

    return textureObjectIds[0];
}

From source file:Main.java

public static byte[] loadImageDataFromWeb(String url) {

    byte[] imageData = null;
    try {/* w  ww.  j a  va  2  s.com*/

        URLConnection connection = new URL(url).openConnection();
        InputStream stream = connection.getInputStream();
        //BufferedInputStream in=new BufferedInputStream(stream);//default 8k buffer
        BufferedInputStream in = new BufferedInputStream(stream, 10240);//YG: 10k=10240, 2x8k=16384
        ByteArrayOutputStream out = new ByteArrayOutputStream(10240);
        int read;
        byte[] b = new byte[4096];

        while ((read = in.read(b)) != -1) {
            out.write(b, 0, read);
        }

        out.flush();
        out.close();

        imageData = out.toByteArray();

    } catch (Exception e) {

        Log.w(TAG, "Exc=" + e);
        return null;
    }

    return imageData;
}

From source file:com.yandex.sample.metrica.Stuff.java

public static void simulateNativeCrash() {
    try {//from  ww w .  j a v a  2  s .com
        nativeCrash();
    } catch (Throwable error) {
        Log.w(Stuff.LOG_TAG, Stuff.NATIVE_LIBRARY_PROBLEMS_HINT);
    }
}

From source file:Main.java

public static void debug(Throwable e) {
    if (debug) {/*w w  w.  ja  v a  2  s  .c  o m*/
        String trace = Log.getStackTraceString(e);
        Log.w("AQuery", trace);
    }
}

From source file:Main.java

public static boolean isNetworkAvailable(Context context) {
    ConnectivityManager connectivity = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    if (connectivity == null) {
        Log.w(LOG_TAG, "couldn't get connectivity manager");
    } else {//  w w  w  .j a  v  a2 s .  co  m
        NetworkInfo[] info = connectivity.getAllNetworkInfo();
        if (info != null) {
            for (int i = 0; i < info.length; i++) {
                if (info[i].isAvailable()) {
                    Log.d(LOG_TAG, "network is available");
                    return true;
                }
            }
        }
    }
    Log.d(LOG_TAG, "network is not available");
    return false;
}

From source file:Main.java

@SuppressLint("SdCardPath")
public static File getCacheDirectory(Context context, boolean preferExternal, String dirName) {
    File appCacheDir = null;/*from   w w w .  jav  a  2s  .c  o m*/
    if (preferExternal && MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
            && hasExternalStoragePermission(context)) {
        appCacheDir = getExternalCacheDir(context, dirName);
    }
    if (appCacheDir == null) {
        appCacheDir = context.getCacheDir();
    }
    if (appCacheDir == null) {
        String cacheDirPath = "/data/data/" + context.getPackageName() + "/cache/";
        Log.w("Can't define system cache directory! '%s' will be used.", cacheDirPath);
        appCacheDir = new File(cacheDirPath);
    }
    return appCacheDir;
}

From source file:Main.java

public static int linkProgram(int vertexId, int fragmentId) {
    int programObjectId = glCreateProgram();

    if (programObjectId != 0) {
        //creation succesfull
        glAttachShader(programObjectId, vertexId);
        glAttachShader(programObjectId, fragmentId);

        //link//from w  w w.  j  a va 2  s .co  m
        glLinkProgram(programObjectId);

        //retrieve status
        final int[] status = new int[1];
        glGetProgramiv(programObjectId, GL_LINK_STATUS, status, 0);

        if (status[0] != 0) {

            return programObjectId;
        } else {
            //linking failed
            glDeleteProgram(programObjectId);
            Log.w(TAG, "linking failed");

            return 0;
        }
    } else {
        Log.w(TAG, "couldn't create program");
        return 0;
    }
}

From source file:Main.java

private static String getPhoneIMEI(Context context) {
    String result = null;/*from  ww  w  . jav a2s. co m*/
    try {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        result = tm.getDeviceId();
    } catch (Exception e) {
        Log.w(LOG_TAG, e);
    }

    return result == null ? "" : result;
}

From source file:Main.java

public static void warn(String tag, String message) {
    if (isDebug) {
        try {//from ww w  .  j  a va 2 s.  com
            Log.w(debugTag + tag, message);
        } catch (Exception e) {
            System.out.println(debugTag + ">>>" + message);
        }
    }
}

From source file:Main.java

private static void ensureHttpClient() {
    if (httpClient != null)
        return;//from www  .  j  a  va  2s .  c  o  m

    BasicHttpParams params = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(params, 45000);
    HttpConnectionParams.setSoTimeout(params, 30000);

    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", new PlainSocketFactory(), 80));
    try {
        registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
    } catch (Exception e) {
        Log.w(TAG, "Unable to register HTTPS socket factory: " + e.getLocalizedMessage());
    }

    ThreadSafeClientConnManager connManager = new ThreadSafeClientConnManager(params, registry);
    httpClient = new DefaultHttpClient(connManager, params);
}