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 Point findBestPreviewSizeValue(Camera.Parameters parameters, Point screenResolution) {

    List<Camera.Size> rawSupportedSizes = parameters.getSupportedPreviewSizes();
    if (rawSupportedSizes == null) {
        Log.w(TAG, "Device returned no supported preview sizes; using default");
        Camera.Size defaultSize = parameters.getPreviewSize();
        if (defaultSize == null) {
            throw new IllegalStateException("Parameters contained no preview size!");
        }/*  w ww .j  av  a  2s.  co  m*/
        return new Point(defaultSize.width, defaultSize.height);
    }

    // Sort by size, descending
    List<Camera.Size> supportedPreviewSizes = new ArrayList<Camera.Size>(rawSupportedSizes);
    Collections.sort(supportedPreviewSizes, new Comparator<Camera.Size>() {
        @Override
        public int compare(Camera.Size a, Camera.Size b) {
            int aPixels = a.height * a.width;
            int bPixels = b.height * b.width;
            if (bPixels < aPixels) {
                return -1;
            }
            if (bPixels > aPixels) {
                return 1;
            }
            return 0;
        }
    });

    if (Log.isLoggable(TAG, Log.INFO)) {
        StringBuilder previewSizesString = new StringBuilder();
        for (Camera.Size supportedPreviewSize : supportedPreviewSizes) {
            previewSizesString.append(supportedPreviewSize.width).append('x')
                    .append(supportedPreviewSize.height).append(' ');
        }
        Log.i(TAG, "Supported preview sizes: " + previewSizesString);
    }

    double screenAspectRatio = (double) screenResolution.x / (double) screenResolution.y;

    // Remove sizes that are unsuitable
    Iterator<Camera.Size> it = supportedPreviewSizes.iterator();
    while (it.hasNext()) {
        Camera.Size supportedPreviewSize = it.next();
        int realWidth = supportedPreviewSize.width;
        int realHeight = supportedPreviewSize.height;
        if (realWidth * realHeight < MIN_PREVIEW_PIXELS) {
            it.remove();
            continue;
        }

        boolean isCandidatePortrait = realWidth < realHeight;
        int maybeFlippedWidth = isCandidatePortrait ? realHeight : realWidth;
        int maybeFlippedHeight = isCandidatePortrait ? realWidth : realHeight;
        double aspectRatio = (double) maybeFlippedWidth / (double) maybeFlippedHeight;
        double distortion = Math.abs(aspectRatio - screenAspectRatio);
        if (distortion > MAX_ASPECT_DISTORTION) {
            it.remove();
            continue;
        }

        if (maybeFlippedWidth == screenResolution.x && maybeFlippedHeight == screenResolution.y) {
            Point exactPoint = new Point(realWidth, realHeight);
            Log.i(TAG, "Found preview size exactly matching screen size: " + exactPoint);
            return exactPoint;
        }
    }

    // If no exact match, use largest preview size. This was not a great
    // idea on older devices because
    // of the additional computation needed. We're likely to get here on
    // newer Android 4+ devices, where
    // the CPU is much more powerful.
    if (!supportedPreviewSizes.isEmpty()) {
        Camera.Size largestPreview = supportedPreviewSizes.get(0);
        Point largestSize = new Point(largestPreview.width, largestPreview.height);
        Log.i(TAG, "Using largest suitable preview size: " + largestSize);
        return largestSize;
    }

    // If there is nothing at all suitable, return current preview size
    Camera.Size defaultPreview = parameters.getPreviewSize();
    if (defaultPreview == null) {
        throw new IllegalStateException("Parameters contained no preview size!");
    }
    Point defaultSize = new Point(defaultPreview.width, defaultPreview.height);
    Log.i(TAG, "No suitable preview sizes, using default: " + defaultSize);
    return defaultSize;
}

From source file:cc.softwarefactory.lokki.android.utilities.gcm.GcmHelper.java

private static String getRegistrationId(Context context) {

    final SharedPreferences prefs = getGCMPreferences(context);
    String registrationId = prefs.getString(PROPERTY_REG_ID, "");
    if (registrationId.isEmpty()) {
        Log.e(TAG, "Registration not found.");
        return "";
    }//  w  w w  . ja v a  2 s .c o m
    // Check if app was updated; if so, it must clear the registration ID since the existing regID is not guaranteed to work with the new app version.
    int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
    int currentVersion = getAppVersion(context);
    if (registeredVersion == currentVersion) {
        return registrationId;
    }
    Log.i(TAG, "App version changed.");
    return "";
}

From source file:Main.java

public static void logInfo(String texto) {
    if (INFO)
        Log.i("DebugUtils", String.valueOf(texto));
}

From source file:Main.java

public static final String postData(String url, HashMap<String, String> params) {
    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(url);
    String outputString = null;/*from  w  w  w.j  a va2 s  . com*/

    try {
        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(params.size());
        Iterator it = params.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry) it.next();
            nameValuePairs.add(new BasicNameValuePair((String) pair.getKey(), (String) pair.getValue()));
            System.out.println(pair.getKey() + " = " + pair.getValue());
            it.remove(); // avoids a ConcurrentModificationException
        }
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);

        StatusLine statusLine = response.getStatusLine();
        if (statusLine.getStatusCode() == HttpURLConnection.HTTP_OK) {
            byte[] result = EntityUtils.toByteArray(response.getEntity());
            outputString = new String(result, "UTF-8");
        }

    } catch (ClientProtocolException e) {
        Log.i(CLASS_NAME, "Client protocolException happened: " + e.getMessage());
    } catch (IOException e) {
        Log.i(CLASS_NAME, "Client IOException happened: " + e.getMessage());
    } catch (NetworkOnMainThreadException e) {
        Log.i(CLASS_NAME, "Client NetworkOnMainThreadException happened: " + e.getMessage());
        e.printStackTrace();
    } catch (Exception e) {
        Log.i(CLASS_NAME, "Unknown exeception: " + e.getMessage());
    }
    return outputString;
}

From source file:com.g_node.gca.abstracts.AbstractsJsonParse.java

public void jsonParse() {
    try {//from w  w  w.  j av a2  s  .  c om
        Log.i(gTag, "in JSON PARSING FUNCTION");
        //get json file from raw 
        InputStream inStream = this.jsonStream;
        JSONArray jsonArray = JSONReader.parseStream(inStream); //read json file and put in JSONarray

        for (int index = 0; index < jsonArray.length(); index++) {

            //get first abstract item object
            JSONObject jsonObject = jsonArray.getJSONObject(index);
            Log.i(gTag, "json got: " + jsonObject);

            //iterate over the object got, to extract required keys and values

            //abstract UUID
            String abs_uuid = jsonObject.getString("uuid");
            Log.i(gTag, "abstract uuid: " + abs_uuid);

            //abstract topic
            String topic = jsonObject.getString("topic");
            Log.i(gTag, "topic: " + topic);

            //abstract title
            String title = jsonObject.getString("title");
            Log.i(gTag, "title: " + title);

            //abstract text
            String text = jsonObject.getString("text");
            Log.i(gTag, "text: " + text);

            //abstract state
            String state = jsonObject.getString("state");
            Log.i(gTag, "state: " + state);

            //abstract sortID
            int sortID = jsonObject.getInt("sortId");
            Log.i(gTag, "sortID: " + sortID);

            //abstract reasonForTalk
            String reasonForTalk = jsonObject.getString("reasonForTalk");
            Log.i(gTag, "reasonForTalk: " + reasonForTalk);

            //abstract mtime
            String mtime = jsonObject.getString("mtime");
            Log.i(gTag, "mtime: " + mtime);

            //abstract isTalk
            Boolean isTalk = jsonObject.getBoolean("isTalk");
            String abstractType;
            Log.i(gTag, "isTalk: " + isTalk);

            if (!isTalk) { //if isTalk is false, then type is poster
                abstractType = "poster";
            } else {
                abstractType = "Talk";
            }
            Log.i(gTag, "abstract type: " + abstractType);

            //abstract DOI
            String doi = jsonObject.getString("doi");
            Log.i(gTag, "doi: " + doi);

            //Abstract conflictOfInterest
            String coi = jsonObject.getString("conflictOfInterest");
            Log.i(gTag, "conflictOfInterest: " + coi);

            //Abstract acknowledgements
            String acknowledgements = jsonObject.getString("acknowledgements");
            Log.i(gTag, "acknowledgements: " + acknowledgements);

            //Table insertion
            //add the basic abstract json keys into abstract_details table
            dbHelper.addItems(abs_uuid, topic, title, text, state, sortID, reasonForTalk, mtime, abstractType,
                    doi, coi, acknowledgements);

            //Abstract affiliations JSONarray
            JSONArray abs_Aff_Array = jsonObject.getJSONArray("affiliations");

            //now iterate over this array for extracting each affiliation 
            for (int j = 0; j < abs_Aff_Array.length(); j++) {
                //get affiliation object
                JSONObject affiliationJSONObject = abs_Aff_Array.getJSONObject(j);

                //affiliation UUID
                String affiliation_uuid = affiliationJSONObject.getString("uuid");
                Log.i(gTag, "aff uuid: " + affiliation_uuid);

                //affiliation section
                String affiliation_section = affiliationJSONObject.getString("section");
                Log.i(gTag, "aff section: " + affiliation_section);

                //affiliation department
                String affiliation_department = affiliationJSONObject.getString("department");
                Log.i(gTag, "aff department: " + affiliation_department);

                //affiliation country
                String affiliation_country = affiliationJSONObject.getString("country");
                Log.i(gTag, "aff country: " + affiliation_country);

                //affiliation address
                String affiliation_address = affiliationJSONObject.getString("address");
                Log.i(gTag, "aff address: " + affiliation_address);

                //affiliation position - (different for each abstract)
                int affiliation_position = affiliationJSONObject.getInt("position");
                Log.i(gTag, "aff position: " + affiliation_position);

                //check if affiliation UUID is not already in table
                if (!dbHelper.AffiliationExists(affiliation_uuid)) {
                    //add affiliation detail into AFFILIATION_DETAILS Table
                    dbHelper.addInAFFILIATION_DETAILS(affiliation_uuid, affiliation_address,
                            affiliation_country, affiliation_department, affiliation_section);
                }

                //add affiliation position against particular abstract in ABSTRACT_AFFILIATION_ID_POSITION table
                dbHelper.addInABSTRACT_AFFILIATION_ID_POSITION(abs_uuid, affiliation_uuid,
                        affiliation_position);

            } //loop end for each affiliation object

            //Abstract Authors JSONarray
            JSONArray abs_authors_Array = jsonObject.getJSONArray("authors");

            //now iterate over authors array to extract each author information
            for (int j = 0; j < abs_authors_Array.length(); j++) {
                //get author object

                JSONObject authorJSONObject = abs_authors_Array.getJSONObject(j);

                //author UUID
                String author_uuid = authorJSONObject.getString("uuid");
                Log.i(gTag, "auth uuid: " + author_uuid);

                //author first Name
                String author_fName = authorJSONObject.getString("firstName");
                Log.i(gTag, "auth first name: " + author_fName);

                //author last Name
                String author_lName = authorJSONObject.getString("lastName");
                Log.i(gTag, "auth last name: " + author_lName);

                //author middle Name
                String author_middleName = authorJSONObject.getString("middleName");
                Log.i(gTag, "auth middle name: " + author_middleName);

                //author mail
                String author_mail = authorJSONObject.getString("mail");
                Log.i(gTag, "auth mail: " + author_mail);

                //author position (unique for each abstract)
                int author_position = authorJSONObject.getInt("position");
                Log.i(gTag, "auth position: " + author_position);

                //now get affiliations of a particular author for an abstract for example
                // "affiliations": [0,1]
                JSONArray authorAffiliationsArray = authorJSONObject.getJSONArray("affiliations");
                Log.i(gTag, "auth affiliations: " + authorAffiliationsArray.toString());

                if (!dbHelper.AuthorExists(author_uuid)) {
                    //Add authors data in AUTHORS_DETAILS table 
                    dbHelper.addAuthors(author_uuid, author_fName, author_middleName, author_lName,
                            author_mail);
                }

                //Remove brackets from author affiliation that's to be written in super script
                String authorAffiliationsWithoutBraces = authorAffiliationsArray.toString()
                        .replaceAll("\\[", "").replaceAll("\\]", "");

                //Add position, affiliation data in ABSTRACT_AUTHOR_POSITION_AFFILIATION table
                dbHelper.addInABSTRACT_AUTHOR_POSITION_AFFILIATION(abs_uuid, author_uuid, author_position,
                        authorAffiliationsWithoutBraces);

            } //end authors array loop

            //Abstract Figures JSONArray
            JSONArray abs_fugures_array = jsonObject.getJSONArray("figures");

            //now iterate over this array for extracting each figure detail, if it's length is greater than 0
            if (abs_fugures_array.length() > 0) {

                for (int j = 0; j < abs_fugures_array.length(); j++) {
                    //get figure json object
                    JSONObject figureJSONObject = abs_fugures_array.getJSONObject(j);

                    //Figure UUID
                    String figure_uuid = figureJSONObject.getString("uuid");
                    Log.i(gTag, "Fig uuid: " + figure_uuid);

                    //Figure Caption
                    String figure_caption = figureJSONObject.getString("caption");
                    Log.i(gTag, "Fig caption: " + figure_caption);

                    //Figure URL
                    String figure_URL = figureJSONObject.getString("URL");
                    Log.i(gTag, "Fig URL: " + figure_URL);

                    //Figure position
                    String figure_position = figureJSONObject.getString("position");
                    Log.i(gTag, "Fig position: " + figure_position);

                    //insert the figure into ABSTRACT_FIGURES table
                    dbHelper.addInABSTRACT_FIGURES(abs_uuid, figure_uuid, figure_caption, figure_URL,
                            figure_position);

                } //end figures array loop
            } //end if

            //Abstract references JSONarray
            JSONArray abs_References_Array = jsonObject.getJSONArray("references");

            //now iterate over this array for extracting each reference
            for (int j = 0; j < abs_References_Array.length(); j++) {
                //get reference object
                JSONObject referenceJSONObject = abs_References_Array.getJSONObject(j);

                //Reference UUID
                String reference_uuid = referenceJSONObject.getString("uuid");
                Log.i(gTag, "ref uuid: " + reference_uuid);

                //Reference text
                String reference_text = referenceJSONObject.getString("text");
                Log.i(gTag, "ref text: " + reference_text);

                //Reference link
                String reference_link = referenceJSONObject.getString("link");
                Log.i(gTag, "ref link: " + reference_link);

                //Reference DOI
                String reference_doi = referenceJSONObject.getString("doi");
                Log.i(gTag, "ref DOI: " + reference_doi);

                //insert the reference into ABSTRACT_REFERENCES table 
                dbHelper.addInABSTRACT_REFERENCES(abs_uuid, reference_uuid, reference_text, reference_link,
                        reference_doi);

            } //end references array loop

        } //end abstracts array parsing

    } catch (FileNotFoundException e) {
        Log.e("jsonFile", "file not found");
    } catch (IOException e) {
        Log.e("jsonFile", "ioerror");
    } catch (JSONException e) {
        e.printStackTrace();
    }

}

From source file:net.benmoran.affectsampler.SyncTask.java

@Override
protected SyncResult doInBackground(SyncParams... params) {
    Log.i(TAG, "run()");

    int syncCount;
    SyncParams param = params[0];//  w  w w.  j  av  a 2s. c o m
    try {
        // TODO Allow Mock client for testing
        AppEngineClient client = new AppEngineClientImpl(param.username, param.password, param.URI);
        Synchronizer sync = new Synchronizer(client);
        AffectSerializer ser = new AffectSerializer(param.contentResolver);
        syncCount = sync.sync(ser.toJSONArray());
    } catch (SyncException e) {
        return new SyncResult(e);
    } catch (JSONException e) {
        return new SyncResult(e);
    }
    return new SyncResult(syncCount);
}

From source file:com.marianhello.bgloc.BootCompletedReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.d(TAG, "Received boot completed");
    ConfigurationDAO dao = DAOFactory.createConfigurationDAO(context);
    Config config = null;// www  . ja  v a  2 s  .  c  om

    try {
        config = dao.retrieveConfiguration();
    } catch (JSONException e) {
        //noop
    }

    if (config == null) {
        return;
    }

    Log.d(TAG, "Boot completed " + config.toString());

    if (config.getStartOnBoot()) {
        Log.i(TAG, "Starting service after boot");
        Intent locationServiceIntent = new Intent(context, LocationService.class);
        locationServiceIntent.addFlags(Intent.FLAG_FROM_BACKGROUND);
        locationServiceIntent.putExtra("config", config);

        context.startService(locationServiceIntent);
    }
}

From source file:com.xiao.smartband.http.XmlHttpResponseHandler.java

public void onSuccess(JSONObject response) {
    Log.i("info", "xml sucess=");
}

From source file:Main.java

private static File getExternalCacheDir(Context context, String dirName) {
    File dataDir = new File(new File(Environment.getExternalStorageDirectory(), "Android"), "data");
    File appCacheDir = new File(new File(dataDir, context.getPackageName()), dirName);
    //      File appCacheDir = new File(appCacheDir2, dirName);
    if (!appCacheDir.exists()) {
        if (!appCacheDir.mkdirs()) {
            Log.w(TAG, "Unable to create external cache directory");
            return null;
        }//w w w  . j a  v  a 2  s  . co m
        try {
            new File(appCacheDir, ".nomedia").createNewFile();
        } catch (IOException e) {
            Log.i(TAG, "Can't create \".nomedia\" file in application external cache directory");
        }
    }
    return appCacheDir;
}

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

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