Example usage for android.util Log i

List of usage examples for android.util Log i

Introduction

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

Prototype

public static int i(String tag, String msg) 

Source Link

Document

Send an #INFO log message.

Usage

From source file:Main.java

/** Read a properties file from /assets.  Returns null if it does not exist. */
public static Properties getProperties(String name, Context context) {
    Resources resources = context.getResources();
    AssetManager assetManager = resources.getAssets();

    // Read from the /assets directory
    try {/*w ww.j a va2  s. c  o  m*/
        InputStream inputStream = assetManager.open(name);
        Properties properties = new Properties();
        properties.load(inputStream);
        return properties;
    } catch (IOException e) {
        Log.i("ChatSecure", "no chatsecure.properties available");
        return null;
    }
}

From source file:Main.java

public static Bitmap getSDImg(Context context, String imagePath) {
    if (context == null || imagePath == null) {
        return null;
    }/*  w  w  w . j a v  a 2 s .c o  m*/

    Bitmap bitmap = null;
    InputStream is = null;
    try {
        File file = new File(imagePath);
        if (!file.exists()) {
            return null;
        }
        if (file.isDirectory()) {
            return null;
        }
        imagePath = "file://" + imagePath;
        Log.i("info", imagePath);
        is = context.getContentResolver().openInputStream(Uri.parse(imagePath));
        bitmap = BitmapFactory.decodeStream(is);
    } catch (FileNotFoundException e) {

    } catch (OutOfMemoryError e) {

    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (Exception e) {

            }
        }
    }

    return bitmap;
}

From source file:Main.java

public static String postReqAsJsonAddParam(String uri, String requestJson, Map<String, String> param)
        throws ClientProtocolException, IOException {
    Log.i(TAG, "Send data to :" + uri + " ========== and the data str:" + requestJson);
    HttpPost post = new HttpPost(uri);
    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    for (Map.Entry<String, String> entry : param.entrySet()) {
        parameters.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
    }//w w  w.j  a  va 2 s  . c  om
    parameters.add(new BasicNameValuePair("attendanceClientJSON", requestJson));
    post.setEntity(new UrlEncodedFormEntity(parameters, "UTF-8"));
    HttpClient client = new DefaultHttpClient();
    HttpResponse response = client.execute(post);
    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
        String retStr = EntityUtils.toString(response.getEntity());
        Log.i(TAG, "=================response str:" + retStr);
        return retStr;
    }

    return response.getStatusLine().getStatusCode() + "ERROR";
}

From source file:Main.java

/**
 * Notifies UI to display a message. This method is defined in the common
 * helper because it's used both by the UI and the background service.
 *
 * @param context The application context.
 * @param message The message to be displayed.
 *///from w  ww .  j  a  va  2s . c  om
public static void displayMessage(Context context, String message) {
    Log.i(TAG, "displayMessage: " + message);
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);
}

From source file:Main.java

/**
 * @param message     Message to display
 * @param type        [Log.Error, Log.Warn, ...]
 * @param shouldPrint value that comes from Preferences which allows the user to decide if debug info should be printed to logcat. Error info will ALWAYS be displayed despite this value
 *///from  www.  j a  v a  2 s . c o  m
public static void debugFunc(String message, int type, boolean shouldPrint) {
    // errors must always be displayed
    if (type == Log.ERROR) {
        Log.e(LOG_TAG, message);
    } else if (shouldPrint) {
        switch (type) {
        case Log.DEBUG:
            Log.d(LOG_TAG, message);
            break;
        case Log.INFO:
            Log.i(LOG_TAG, message);
            break;
        case Log.VERBOSE:
            Log.v(LOG_TAG, message);
            break;
        case Log.WARN:
            Log.w(LOG_TAG, message);
            break;
        default:
            Log.v(LOG_TAG, message);
            break;
        }
    }
}

From source file:Main.java

/**
 * Utility method for building up URL param string.
 * //from   w  w  w  .  j a  v  a2s.  co  m
 * @param params
 * @return URL parameter string
 */
private static String buildParamString(Map<String, String> params) {
    StringBuffer paramBuf = new StringBuffer();
    if (params != null && params.size() > 0) {
        paramBuf.append('?');
        Iterator<Map.Entry<String, String>> iter = params.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry<String, String> param = (Map.Entry<String, String>) iter.next();
            paramBuf.append(param.getKey() + "=" + param.getValue());
            if (iter.hasNext()) {
                paramBuf.append('&');
            }
        }
    }
    Log.i("PARAM STRING CHECK", paramBuf.toString());
    return paramBuf.toString();
}

From source file:Main.java

private static boolean apiLevelIsAtLeastEclair() {
    // we need to at least be running on cupcake for QuickContactBadges.
    boolean isAtLeastEclair = false;
    try {/*from  w  w w  . ja  va 2 s  . c  om*/
        Field verField = Class.forName("android.os.Build$VERSION").getField("SDK_INT");
        int sdkInt = verField.getInt(verField);
        isAtLeastEclair = (sdkInt >= 5);
    } catch (Exception e) {
        try {
            Field verField = Class.forName("android.os.Build$VERSION").getField("SDK");
            String sdk = (String) verField.get(verField);
            isAtLeastEclair = (Integer.parseInt(sdk) >= 5);
        } catch (Exception e2) {
            isAtLeastEclair = false;
        }
    }
    Log.i("CompatibilityHelp", "api level at least eclair? " + isAtLeastEclair);
    return isAtLeastEclair;
}

From source file:Main.java

/**
 * Called when a connection to the beacon GATT server has been severed.
 *///  ww  w .jav a  2  s  .  c  om
private static void onDisconnectedFromNearbyBeaconGattServer() {
    Log.i(TAG, "Disconnected from GATT server.");
}

From source file:Main.java

/**
 * Trigger the media scanner to ensure files show up in MTP.
 * @param context a context to use for communication with the media scanner
 * @param scanfile directory or file to scan
 */// ww w .java  2  s  .co m
@TargetApi(11)
private static void triggerMediaScanner(Context context, File scanfile) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
        return; // API 11 - lower versions do not have MTP
    try {
        String path = scanfile.getCanonicalPath();
        Log.i("SavingHelper", "Triggering media scan for " + path);
        MediaScannerConnection.scanFile(context, new String[] { path }, null, new OnScanCompletedListener() {
            @Override
            public void onScanCompleted(String path, Uri uri) {
                Log.i("SavingHelper", "Media scan completed for " + path + " URI " + uri);
            }
        });
    } catch (Exception e) {
        Log.e("SavingHelper", "Exception when triggering media scanner", e);
    }
}

From source file:Main.java

public static void copyAsset(Context context, AssetManager am, boolean force) {
    File newDir = getSDDir(context);
    File sd = Environment.getExternalStorageDirectory();
    if (sd != null && sd.exists() && sd.isDirectory() && newDir.exists() && newDir.isDirectory()) {
        File hpDir = new File(sd, ".hp48");
        if (hpDir.exists()) {
            File allFiles[] = hpDir.listFiles();
            if (allFiles != null && allFiles.length > 0) {
                Log.i("x48",
                        "Moving x48 files from the old dir " + sd.getAbsolutePath() + " to the proper one :");
                for (File file : allFiles) {
                    File newFile = new File(newDir, file.getName());
                    Log.i("x48", "Moving " + file.getAbsolutePath() + " to " + newFile);
                    file.renameTo(newFile);
                }/*from w  ww. jav a  2s .c  o  m*/
            }
            Log.i("x48", "Deleting old directory");
            hpDir.delete();
        }
    }
    copyAsset(am, newDir, force);
}