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:uk.org.todome.Util.java

public static String getFileFromServer(String request) {
    StringBuilder builder = new StringBuilder();
    HttpClient client = new DefaultHttpClient();
    HttpGet httpGet = new HttpGet(request);
    Log.i("Util.getFileFromServer", "Request used: " + request);
    try {/* w w w.  ja  va2s .  c o m*/
        HttpResponse response = client.execute(httpGet);
        StatusLine statusLine = response.getStatusLine();
        int statusCode = statusLine.getStatusCode();
        if (statusCode == 200) {
            HttpEntity entity = response.getEntity();
            InputStream content = entity.getContent();
            BufferedReader reader = new BufferedReader(new InputStreamReader(content));
            String line;
            while ((line = reader.readLine()) != null) {
                builder.append(line);
            }
        } else {
            Log.e("", "Failed to download file");
        }
    } catch (Exception ex) {
        Log.e("Util.getFileFromServer", ex.getClass().toString() + " " + ex.getMessage());
    }

    return builder.toString();
}

From source file:Main.java

/**
 * Load the libtango_client_api.so library based on different Tango device setup.
 *
 * @return returns the loaded architecture id.
 *//*from  www  .  j  a v a2  s.  c o  m*/
public static final int loadTangoSharedLibrary() {
    int loadedSoId = ARCH_ERROR;
    String basePath = "/data/data/com.google.tango/libfiles/";
    if (!(new File(basePath).exists())) {
        basePath = "/data/data/com.projecttango.tango/libfiles/";
    }
    Log.i("TangoInitializationHelper", "basePath: " + basePath);

    try {
        System.load(basePath + "arm64-v8a/libtango_client_api.so");
        loadedSoId = ARCH_ARM64;
        Log.i("TangoInitializationHelper", "Success! Using arm64-v8a/libtango_client_api.");
    } catch (UnsatisfiedLinkError e) {
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.load(basePath + "armeabi-v7a/libtango_client_api.so");
            loadedSoId = ARCH_ARM32;
            Log.i("TangoInitializationHelper", "Success! Using armeabi-v7a/libtango_client_api.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.load(basePath + "x86_64/libtango_client_api.so");
            loadedSoId = ARCH_X86_64;
            Log.i("TangoInitializationHelper", "Success! Using x86_64/libtango_client_api.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.load(basePath + "x86/libtango_client_api.so");
            loadedSoId = ARCH_X86;
            Log.i("TangoInitializationHelper", "Success! Using x86/libtango_client_api.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.load(basePath + "default/libtango_client_api.so");
            loadedSoId = ARCH_DEFAULT;
            Log.i("TangoInitializationHelper", "Success! Using default/libtango_client_api.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    if (loadedSoId < ARCH_DEFAULT) {
        try {
            System.loadLibrary("tango_client_api");
            loadedSoId = ARCH_FALLBACK;
            Log.i("TangoInitializationHelper", "Falling back to libtango_client_api.so symlink.");
        } catch (UnsatisfiedLinkError e) {
        }
    }
    return loadedSoId;
}

From source file:Main.java

/**
 * @author Cheb//from w ww  . ja  v  a 2 s.co  m
 * @param URL - URL to server
 * @param context - context
 * @param mPreferences SharedPreferences
 * downloading JSON from URL
 */
public static String downloadJSON(String URL, Context context, SharedPreferences mPreferences) {
    StringBuilder sb = new StringBuilder();
    DefaultHttpClient mHttpClient = new DefaultHttpClient();
    HttpGet dhttpget = new HttpGet(URL);
    HttpResponse dresponse = null;
    try {
        dresponse = mHttpClient.execute(dhttpget);
    } catch (IOException e) {
        e.printStackTrace();
    }
    int status = dresponse.getStatusLine().getStatusCode();
    if (status == 200) {
        char[] buffer = new char[1];
        try {
            InputStream content = dresponse.getEntity().getContent();
            InputStreamReader isr = new InputStreamReader(content);
            while (isr.read(buffer) != -1) {
                sb.append(buffer);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        //saving JSON 
        mPreferences = context.getSharedPreferences(TAG_FEED, 0);
        mPreferences.edit().putString(TAG_FEED, sb.toString()).commit();
    } else {
        Log.i("Error", "Connection error : " + Integer.toString(status));
    }
    return sb.toString();
}

From source file:Main.java

public static Bitmap getBitmapScaledToDisplay(File f, int screenHeight, int screenWidth) {
    // Determine image size of f
    BitmapFactory.Options o = new BitmapFactory.Options();
    o.inJustDecodeBounds = true;/* ww w. j  a va2s .c  o  m*/
    BitmapFactory.decodeFile(f.getAbsolutePath(), o);

    int heightScale = o.outHeight / screenHeight;
    int widthScale = o.outWidth / screenWidth;

    // Powers of 2 work faster, sometimes, according to the doc.
    // We're just doing closest size that still fills the screen.
    int scale = Math.max(widthScale, heightScale);

    // get bitmap with scale ( < 1 is the same as 1)
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inInputShareable = true;
    options.inPurgeable = true;
    options.inSampleSize = scale;
    Bitmap b = BitmapFactory.decodeFile(f.getAbsolutePath(), options);
    if (b != null) {
        Log.i(t, "Screen is " + screenHeight + "x" + screenWidth + ".  Image has been scaled down by " + scale
                + " to " + b.getHeight() + "x" + b.getWidth());
    }
    return b;
}

From source file:com.minihelper.logic.ClientApi.java

/**
 * add by zxy update at 2012-07-05 /*w ww  . j  av  a  2s.  c o  m*/
 * */
public static JSONObject getAppUpdate() throws HttpRequstError, JSONException {
    JSONObject jsonobj = Util.httpGet(ApiConfig.AppUpdate, new Bundle());
    Log.i("app_msg", "" + jsonobj);
    if (!jsonobj.getBoolean("status")) {
        throw new HttpRequstError(jsonobj.getString("ErrorMessage"));
    }
    return jsonobj.getJSONObject("msg");
}

From source file:com.lugia.timetable.SubjectList.java

public static synchronized SubjectList getInstance(Context context) {
    Log.i(TAG, "getIntance() called");

    if (mContext == null)
        mContext = context;//from w ww  .j av  a2  s  .  c o m

    return InstanceHolder.INSTANCE;
}

From source file:Main.java

public static void setRinger2Silent(Context context) {
    AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
    Log.i("HelperFunctions ", "Silent method called");
}

From source file:Main.java

private static String readInStream(FileInputStream inStream) {
    try {/*w  w w .  j a va  2  s  . c o m*/
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        byte[] buffer = new byte[512];
        int length = -1;
        while ((length = inStream.read(buffer)) != -1) {
            outStream.write(buffer, 0, length);
        }

        outStream.close();
        inStream.close();
        return outStream.toString();
    } catch (IOException e) {
        Log.i("FileTest", e.getMessage());
    }
    return null;
}

From source file:com.binil.pushnotification.ServerUtil.java

/**
 * Registration this account/device pair within the server.
 *
 * @return whether the registration succeeded or not.
 *//*from w w  w. j a va 2s  .  c o  m*/
public static boolean register(final Context context, final String regId) {
    Log.i(TAG, "registering device (regId = " + regId + ")");
    Log.e(TAG, "registering device (regId = " + regId + ")");

    /*        String serverUrl = URLConst.registerDevice();
            HashMap<String, Object> params = new HashMap<>();
            params.put("DeviceType", 2);
            params.put("RegistrationId", regId);
            params.put("DeviceId", DeviceInfo.id(context)); // http://android-developers.blogspot.com/2011/03/identifying-app-installations.html
            params.put("GuiVersion", getVersion(context));*/

    long backoff = BACKOFF_MILLI_SECONDS + random.nextInt(1000);
    // Once GCM returns a registration id, we need to register it in the
    // demo server. As the server might be down, we will retry it a couple
    // times.
    for (int i = 1; i <= MAX_ATTEMPTS; i++) {
        Log.d(TAG, "Attempt #" + i + " to register");
        try {

            //post(serverUrl, params);
            if (!TextUtils.isEmpty(regId)) {
                Log.i(TAG, "[AgmoStudioSDK] Push server registration success! Device Token => " + regId);
            }
            return true;
        } catch (Exception e) {
            // Here we are simplifying and retrying on any error; in a real
            // application, it should retry only on unrecoverable errors
            // (like HTTP error code 503).
            Log.e(TAG, "Failed to register on attempt " + i, e);
            e.printStackTrace();
            if (i == MAX_ATTEMPTS) {
                break;
            }
            try {
                Log.d(TAG, "Sleeping for " + backoff + " ms before retry");
                Thread.sleep(backoff);
            } catch (InterruptedException e1) {
                // Activity finished before we complete - exit.
                Log.d(TAG, "Thread interrupted: abort remaining retries!");
                Thread.currentThread().interrupt();
                return false;
            }
            // increase backoff exponentially
            backoff *= 2;
        }
    }
    return false;
}

From source file:Main.java

public static void setBestExposure(Camera.Parameters parameters, boolean lightOn) {
    int minExposure = parameters.getMinExposureCompensation();
    int maxExposure = parameters.getMaxExposureCompensation();
    float step = parameters.getExposureCompensationStep();
    if ((minExposure != 0 || maxExposure != 0) && step > 0.0f) {
        // Set low when light is on
        float targetCompensation = lightOn ? MIN_EXPOSURE_COMPENSATION : MAX_EXPOSURE_COMPENSATION;
        int compensationSteps = Math.round(targetCompensation / step);
        float actualCompensation = step * compensationSteps;
        // Clamp value:
        compensationSteps = Math.max(Math.min(compensationSteps, maxExposure), minExposure);
        if (parameters.getExposureCompensation() == compensationSteps) {
            Log.i(TAG,
                    "Exposure compensation already set to " + compensationSteps + " / " + actualCompensation);
        } else {//from  www  .  j a  v  a2  s  .c o m
            Log.i(TAG, "Setting exposure compensation to " + compensationSteps + " / " + actualCompensation);
            parameters.setExposureCompensation(compensationSteps);
        }
    } else {
        Log.i(TAG, "Camera does not support exposure compensation");
    }
}