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

/**
 * Get app's version from manifest file (attribute <i>android:versionName</i>).
 * (Method added for ChBoSync)/*from w  w  w  . j a v a2 s  .c om*/
 * 
 * @param context Reference to context needed for obtaining package manager.
 * @return Version of App as specified manifest file.
 */
public static String getVersionNumberFromManifest(Context context) {

    final int flags = 0;
    String appVersionStr = "";

    try {
        appVersionStr = context.getPackageManager().getPackageInfo(context.getPackageName(), flags).versionName;
    } catch (Exception ex) {
        Log.w(TAG_LOG, "Could not obtain version of app from manifest file: " + ex);
        appVersionStr = "???"; // Fallback for version number
    }

    return appVersionStr;
}

From source file:com.example.util.ImageUtils.java

public static Bitmap getImageFromUrl(String url) {

    //        SessionManager cache = SessionManager.getInstance();

    HttpGet httpRequest = new HttpGet(url);
    HttpResponse response = null;/*from w w  w .  j  a va2s  .  c o m*/
    AndroidHttpClient client = HttpClientFactory.get().getHttpClient();
    try {
        response = client.execute(httpRequest);
        final int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_OK) {
            Log.w("ImageDownloader", "Error " + statusCode + " while retrieving bitmap from " + url);
            return null;
        }
        HttpEntity entity = response.getEntity();
        if (entity != null) {
            InputStream inputStream = null;
            try {
                inputStream = entity.getContent();
                // non-compressed images no need to be cached to the sd-card
                BitmapFactory.Options o = new BitmapFactory.Options();
                o.inPurgeable = true;
                Bitmap bmp = BitmapFactory.decodeStream(new FlushedInputStream(inputStream), null, o);
                //                    cache.saveToDisk(url, bmp);
                return bmp;
            } finally {
                if (inputStream != null) {
                    inputStream.close();
                }
                entity.consumeContent();
            }
        }
    } catch (ClientProtocolException e) {
        Log.w("ImageDownloader", "ClientProtocolException " + url);
    } catch (IOException e) {
        Log.w("ImageDownloader", "IOException " + url);
    } catch (Exception e) {
        Log.w("ImageDownloader", "other exception when download images from " + url);
    } catch (OutOfMemoryError err) {
        Log.w("ImageDownloader", "OutOfMemoryError when download images from " + url);
    } finally {
        httpRequest.abort();
    }
    return null;
}

From source file:com.google.samples.apps.friendlyping.gcm.MyGcmListenerService.java

@Override
public void onMessageReceived(String from, Bundle data) {
    if (from == null) {
        Log.w(TAG, "Couldn't determine origin of message. Skipping.");
        return;//w w w .  j  a  v a  2 s .co  m
    }
    try {
        digestData(data);
    } catch (JSONException e) {
        Log.e(TAG, "onMessageReceived: Could not digest data", e);
    }
}

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.
 *///from  w ww .ja  v a 2  s .  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.google.android.apps.chrometophone.DeviceRegistrar.java

public static void registerWithServer(final Context context, final String deviceRegistrationID) {
    new Thread(new Runnable() {
        @Override//from   w w  w . j a va  2 s.  c o m
        public void run() {
            Intent updateUIIntent = new Intent("com.google.ctp.UPDATE_UI");
            try {
                HttpResponse res = makeRequest(context, deviceRegistrationID, REGISTER_PATH);
                if (res.getStatusLine().getStatusCode() == 200) {
                    GCMRegistrar.setRegisteredOnServer(context, true);
                    updateUIIntent.putExtra(STATUS_EXTRA, REGISTERED_STATUS);
                } else if (res.getStatusLine().getStatusCode() == 400) {
                    updateUIIntent.putExtra(STATUS_EXTRA, AUTH_ERROR_STATUS);
                } else {
                    Log.w(TAG, "Registration error " + String.valueOf(res.getStatusLine().getStatusCode()));
                    updateUIIntent.putExtra(STATUS_EXTRA, ERROR_STATUS);
                }
                context.sendBroadcast(updateUIIntent);
                // Check if this is an update from C2DM to GCM - if it is, remove the
                // old registration id.
                SharedPreferences settings = Prefs.get(context);
                String c2dmRegId = settings.getString("deviceRegistrationID", null);
                if (c2dmRegId != null) {
                    Log.i(TAG, "Removing old C2DM registration id");
                    SharedPreferences.Editor editor = settings.edit();
                    editor.remove("deviceRegistrationID");
                    editor.commit();
                }
            } catch (AppEngineClient.PendingAuthException pae) {
                // Get setup activity to ask permission from user.
                Intent intent = new Intent(SetupActivity.AUTH_PERMISSION_ACTION);
                intent.putExtra("AccountManagerBundle", pae.getAccountManagerBundle());
                context.sendBroadcast(intent);
            } catch (Exception e) {
                Log.w(TAG, "Registration error " + e.getMessage());
                updateUIIntent.putExtra(STATUS_EXTRA, ERROR_STATUS);
                context.sendBroadcast(updateUIIntent);
            }
        }
    }).start();
}

From source file:com.browsertophone.DeviceRegistrar.java

public static void registerWithServer(final Context context, final String deviceRegistrationID) {
    new Thread(new Runnable() {
        public void run() {
            Intent updateUIIntent = new Intent("com.browsertophone.btp.UPDATE_UI");
            try {
                HttpResponse res = makeRequest(context, deviceRegistrationID, REGISTER_PATH);
                if (res.getStatusLine().getStatusCode() == 200) {
                    SharedPreferences settings = Prefs.get(context);
                    SharedPreferences.Editor editor = settings.edit();
                    editor.putString("deviceRegistrationID", deviceRegistrationID);
                    editor.commit();/* w ww  .j a  v a 2  s.c  o  m*/
                    updateUIIntent.putExtra(STATUS_EXTRA, REGISTERED_STATUS);
                } else if (res.getStatusLine().getStatusCode() == 400) {
                    updateUIIntent.putExtra(STATUS_EXTRA, AUTH_ERROR_STATUS);
                } else {
                    Log.w(TAG, "Registration error " + String.valueOf(res.getStatusLine().getStatusCode()));
                    updateUIIntent.putExtra(STATUS_EXTRA, ERROR_STATUS);
                }
                context.sendBroadcast(updateUIIntent);
            } catch (AppEngineClient.PendingAuthException pae) {
                // Ignore - we'll reregister later
            } catch (Exception e) {
                Log.w(TAG, "Registration error " + e.getMessage());
                updateUIIntent.putExtra(STATUS_EXTRA, ERROR_STATUS);
                context.sendBroadcast(updateUIIntent);
            }
        }
    }).start();
}

From source file:com.mindprotectionkit.freephone.monitor.MonitorConfigUpdateReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.w("MonitorConfigUpdateReceiver", "Initiating scheduled monitor config update...");
    Intent serviceIntent = new Intent(context, MonitorConfigUpdateService.class);
    context.startService(serviceIntent);
}

From source file:com.google.android.vending.licensing.NaaPolicy.java

private void setMaxRetries(String maxRetries) {
    Long lMaxRetries;/*from   w w w .  ja va 2 s. com*/
    try {
        lMaxRetries = Long.parseLong(maxRetries);
    } catch (NumberFormatException e) {
        Log.w(TAG, "Licence retry count (GR) missing, grace period disabled");
        lMaxRetries = 0l;
    }

    mMaxRetries = lMaxRetries;
}

From source file:com.loftcat.utils.log.LogCenter.java

public void warn(String tag, String msg) {
    if (logCenter != null)
        Log.w(tag, msg);
}

From source file:com.bandbaaja.c2dm.DeviceRegistrar.java

public static void registerWithServer(final Context context, final String deviceRegistrationID) {
    new Thread(new Runnable() {
        public void run() {
            Intent updateUIIntent = new Intent("com.google.ctp.UPDATE_UI");
            try {
                HttpResponse res = makeRequest(context, deviceRegistrationID, REGISTER_PATH);
                if (res.getStatusLine().getStatusCode() == 200) {
                    SharedPreferences settings = Prefs.get(context);
                    SharedPreferences.Editor editor = settings.edit();
                    editor.putString("deviceRegistrationID", deviceRegistrationID);
                    editor.commit();//from w  ww  .  j  a  va2 s  .com
                    updateUIIntent.putExtra(STATUS_EXTRA, REGISTERED_STATUS);
                } else if (res.getStatusLine().getStatusCode() == 400) {
                    updateUIIntent.putExtra(STATUS_EXTRA, AUTH_ERROR_STATUS);
                } else {
                    Log.w(TAG, "Registration error " + String.valueOf(res.getStatusLine().getStatusCode()));
                    updateUIIntent.putExtra(STATUS_EXTRA, ERROR_STATUS);
                }
                context.sendBroadcast(updateUIIntent);
            } catch (Exception e) {
                Log.w(TAG, "Registration error " + e.getMessage());
                updateUIIntent.putExtra(STATUS_EXTRA, ERROR_STATUS);
                context.sendBroadcast(updateUIIntent);
            }
        }
    }).start();
}