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

public static JSONStringer getJsonStringer(String tranCode, String phoneNo, String version,
        String clientVersion, String clientType, String oem, String logNo, String transDate, String transTime,
        String token, String param, String sign) {
    JSONStringer jsonStringer = new JSONStringer();
    try {/*from   www .ja v a2s  .c  o m*/
        jsonStringer.object();
        jsonStringer.key("tranCode");
        jsonStringer.value(tranCode);
        jsonStringer.key("phoneNo");
        jsonStringer.value(phoneNo);
        jsonStringer.key("version");
        jsonStringer.value(version);
        jsonStringer.key("clientVersion");
        jsonStringer.value(clientVersion);
        jsonStringer.key("clientType");
        jsonStringer.value(clientType);
        jsonStringer.key("oem");
        jsonStringer.value(oem);
        jsonStringer.key("logNo");
        jsonStringer.value(logNo);
        jsonStringer.key("transDate");
        jsonStringer.value(transDate);
        jsonStringer.key("transTime");
        jsonStringer.value(transTime);
        jsonStringer.key("token");
        jsonStringer.value(token);
        jsonStringer.key("param");
        jsonStringer.value(param);
        jsonStringer.key("sign");
        jsonStringer.value(sign);

        jsonStringer.endObject();

        Log.i(TAG, "getJsonObject = " + jsonStringer.toString());
    } catch (JSONException e) {
        e.printStackTrace();
        Log.i(TAG, "" + e.getMessage());
    }
    return jsonStringer;
}

From source file:it.nicola_amatucci.util.JsonAndroidLocalIO.java

public static <T> T loadData(Context context, String filename, Class<T> obj) {
    StringBuilder strContent = new StringBuilder("");
    try {//from w ww.j a v  a  2 s  .  co m
        BufferedInputStream in = new BufferedInputStream(context.openFileInput(filename));

        int ch;
        while ((ch = in.read()) != -1)
            strContent.append((char) ch);

        in.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    if (strContent.length() > 0) {
        try {
            Log.i("TAG", strContent.toString());
            JSONObject json = new JSONObject(strContent.toString());
            return Json.object_from_json(json, obj);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    return null;
}

From source file:GCMService.java

private void sendNotification(String message) {
    Log.i("GCMService", "sendNotification()");
    Uri notificationSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("GCM Message").setContentText(message)
            .setSound(notificationSoundUri).setLights(Color.BLUE, 500, 500);
    NotificationManager notificationManager = (NotificationManager) getApplicationContext()
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, notificationBuilder.build());
}

From source file:Main.java

public static byte[] resize(byte[] picArray, int size, boolean faceDetect) {
    if (picArray == null) {
        return null;
    }/*www  .  j  a v a  2 s. c om*/
    Bitmap pic = BitmapFactory.decodeByteArray(picArray, 0, picArray.length);
    if (pic == null) {
        return null;
    }

    size = Math.min(size, Math.min(pic.getHeight(), pic.getWidth()));
    if (size % 2 != 0)
        size--;
    Log.i("sizes", "old width:" + pic.getWidth() + " old height:" + pic.getHeight() + " new size:" + size);
    Bitmap scaledPic = scale(pic, size);

    int width = scaledPic.getWidth();
    int height = scaledPic.getHeight();

    //if pic is already square, we are done now
    if (width == height) {
        return bitmapToBytes(scaledPic);
    }

    PointF mid = null;
    int cropcenter;

    if (faceDetect)
        mid = findFaceMid(scaledPic);

    Bitmap out;
    if (width > height) {
        if (mid != null)
            cropcenter = Math.max(size / 2, Math.min((int) Math.floor(mid.y), width - size / 2));
        else
            cropcenter = width / 2;
        Log.i("CROPPING", "width:" + width + " center:" + cropcenter + " size:" + size + " left edge:"
                + (cropcenter - size / 2) + " right edge:" + (cropcenter + size / 2));
        out = Bitmap.createBitmap(scaledPic, cropcenter - size / 2, 0, size, size);
    } else {
        if (mid != null)
            cropcenter = Math.max(size / 2, Math.min((int) Math.floor(mid.x), height - size / 2));
        else
            cropcenter = height / 2;
        out = Bitmap.createBitmap(scaledPic, 0, 0, size, size);
    }

    return bitmapToBytes(out);
}

From source file:com.distimo.sdk.Utils.java

static Map<String, String> keyValueStringToMap(String query) {
    if (Utils.DEBUG) {
        Log.i(TAG, "keyValueStringToMap()");
    }//w  ww .j a  v  a  2  s  .  c  o m

    // Create Map to store the parameters
    Map<String, String> result = new HashMap<String, String>();

    // Parse the query string, extracting the relevant data
    String[] params = query.split("&"); // $NON-NLS-1$
    for (String param : params) {
        String[] pair = param.split("="); // $NON-NLS-1$
        if (pair.length == 2) {
            if (Utils.DEBUG) {
                Log.i(TAG, "Found " + pair[0] + "=" + pair[1]);
            }
            result.put(pair[0], pair[1]);
        } else {
            if (Utils.DEBUG) {
                Log.w(TAG, "Skipping " + param);
            }
        }
    }

    return result;
}

From source file:Main.java

/**
 * Returns a TempFile with given root, filename, and extension.
 * The resulting TempFile is safe for use with Android's MediaRecorder
 * @param c//from   ww  w.j  a v a  2  s .co  m
 * @param root
 * @param filename
 * @param extension
 * @return
 */
public static File createTempFile(Context c, File root, String filename, String extension) {
    File output = null;
    try {
        if (filename != null) {
            if (!extension.contains("."))
                extension = "." + extension;
            output = new File(root, filename + extension);
            output.createNewFile();
            //output = File.createTempFile(filename, extension, root);
            Log.i(TAG, "Created temp file: " + output.getAbsolutePath());
        }
        return output;
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:no.hig.gsd.quizgame.ServerUtilities.java

/**
 * Register this account/device pair within the server.
 *
 * @return whether the registration succeeded or not.
 *///from   w  ww .  j a v a  2 s .c  o m
public static String register(final Context context, final String regId) {

    Log.i("remote", "registering device (regId = " + regId + ")");
    String usm = LoginActivity.usm;
    String retSrc = "";
    try {
        HttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost("http://89.250.116.142/Quizgame/jaxrs/quizgame/gcm");
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("username", usm));
        nameValuePairs.add(new BasicNameValuePair("regId", regId));

        post.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));

        HttpResponse httpResponse = client.execute(post);
        HttpEntity entity = httpResponse.getEntity();
        retSrc = EntityUtils.toString(entity);
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    if (retSrc.equals("success")) {
        return status = "success";
    } else {

        return status = "failure";
    }

}

From source file:foam.zizim.android.net.Incidents.java

public static boolean getAllIncidentsFromWeb(long sinceId) throws IOException {
    BoskoiService.tracker.trackPageView("/Incidents/IncidentsFromWeb");

    HttpResponse response;/*  w w w .ja  va2 s.  c o  m*/
    String incidents = "";

    StringBuilder uriBuilder = new StringBuilder(BoskoiService.domain);
    uriBuilder.append("/api?task=incidents");
    uriBuilder.append("&by=sinceid");
    uriBuilder.append("&id=" + String.valueOf(sinceId)); //format date url correctly by replacing whitespace
    uriBuilder.append("&limit=5000");
    uriBuilder.append("&resp=xml");
    Log.i("URL: ", uriBuilder.toString());

    response = BoskoiHttpClient.GetURL(uriBuilder.toString());

    if (response == null) {
        return false;
    }

    final int statusCode = response.getStatusLine().getStatusCode();

    if (statusCode == 200) {

        incidents = BoskoiHttpClient.GetText(response);
        BoskoiService.incidentsResponse = incidents;
        return true;
    } else {
        return false;
    }

}

From source file:com.rfcx.cellmapping.tasks.JSONRequestTask.java

@Override
protected void onPostExecute(String result) {

    if (result == null) {
        jrsh.onError("INVALID_JSON_RESPONSE");
        return;/* w  w  w . ja va 2 s  .  c o  m*/
    }

    Log.i("api result", result);

    try {
        Object json = new JSONTokener(result).nextValue();
        if (json instanceof JSONObject) {
            JSONObject response = new JSONObject(result);
            jrsh.onSuccess(response);
            return;
        } else if (json instanceof JSONArray) {
            JSONArray response = new JSONArray(result);
            jrsh.onSuccess(response);
            return;
        }
        jrsh.onError("INVALID_JSON_RESPONSE");

    } catch (JSONException e) {
        jrsh.onError(e.getMessage());
    }
}

From source file:com.deliciousdroid.client.User.java

/**
 * Creates and returns an instance of the user from the provided JSON data.
 * /*from   w  w  w.ja va2  s. c o  m*/
 * @param user The JSONObject containing user data
 * @return user The new instance of Delicious user created from the JSON data.
 */
public static User valueOf(JSONObject user) {
    try {
        final String userName = user.getString("user");
        return new User(userName);
    } catch (final Exception ex) {
        Log.i("User", "Error parsing JSON user object" + ex.toString());

    }
    return null;
}