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:MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Firebase.setAndroidContext(this);
    Firebase firebase = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com/");

    firebase.createUser("yourname@firebase.com", "yourmessage",
            new Firebase.ValueResultHandler<Map<String, Object>>() {
                @Override/*  w ww .  j a v  a  2 s  . c  om*/
                public void onSuccess(Map<String, Object> result) {
                    Log.i("Firebase", "Successfully created user account with uid: " + result.get("uid"));
                }

                @Override
                public void onError(FirebaseError firebaseError) {
                    // there was an error
                }
            });
}

From source file:com.quinsoft.zeidon.android.AndroidUtils.java

/**
 * Checks to see if the targetDbName exists.  If not it will be copied from emptyDbName,
 * which must be in the assets directory.
 *
 * @param context/*w  w w.  j  av a2s  .c om*/
 * @param emptyDbName
 * @param targetDbName
 */
public static void initializeDatabase(ContextWrapper context, String emptyDbName, String targetDbName) {
    context.getExternalFilesDir(null); // Create files directory if necessary.
    File f = new File(targetDbName);
    if (f.exists()) // Does DB already exist?
        return;

    Log.i("AndroidUtils.initializeDatabase",
            "Initializing DB by copying " + emptyDbName + " to " + f.getAbsolutePath());
    InputStream ins = null;
    FileOutputStream fos = null;
    try {
        ins = context.getAssets().open(emptyDbName);
    } catch (IOException e) {
        throw ZeidonException.wrapException(e).prependFilename(emptyDbName);
    }

    try {
        fos = new FileOutputStream(f);
    } catch (Exception e) {
        IOUtils.closeQuietly(ins);
        throw ZeidonException.wrapException(e).prependFilename(targetDbName);
    }

    try {
        byte[] buffer = new byte[1024];
        int size = 0;

        while ((size = ins.read(buffer, 0, buffer.length)) >= 0)
            fos.write(buffer, 0, size);
    } catch (IOException e) {
        throw ZeidonException.wrapException(e).prependFilename(emptyDbName);
    } finally {
        IOUtils.closeQuietly(ins);
        IOUtils.closeQuietly(fos);
    }
}

From source file:com.cssweb.android.service.AutoLoadAllStock.java

public void onCreate() {
    Log.i("TAG", "Services onCreate");
    super.onCreate();
}

From source file:Main.java

/**
 * Attempts to find a preview size that matches the provided width and height (which
 * specify the dimensions of the encoded video).  If it fails to find a match it just
 * uses the default preview size for video.
 * <p>//from  ww  w. j  av a  2s  . com
 * TODO: should do a best-fit match, e.g.
 * https://github.com/commonsguy/cwac-camera/blob/master/camera/src/com/commonsware/cwac/camera/CameraUtils.java
 */
public static void choosePreviewSize(Camera.Parameters parms, int width, int height) {
    // We should make sure that the requested MPEG size is less than the preferred
    // size, and has the same aspect ratio.
    Camera.Size ppsfv = parms.getPreferredPreviewSizeForVideo();
    if (ppsfv != null) {
        Log.d(TAG, "Camera preferred preview size for video is " + ppsfv.width + "x" + ppsfv.height);
    }

    //for (Camera.Size size : parms.getSupportedPreviewSizes()) {
    //    Log.d(TAG, "supported: " + size.width + "x" + size.height);
    //}

    for (Camera.Size size : parms.getSupportedPreviewSizes()) {

        Log.i(TAG, "preview size " + size.width + "x" + size.height);

        if (size.width == width && size.height == height) {
            parms.setPreviewSize(width, height);
            return;
        }
    }

    Log.w(TAG, "Unable to set preview size to " + width + "x" + height);
    if (ppsfv != null) {
        parms.setPreviewSize(ppsfv.width, ppsfv.height);
    }
    // else use whatever the default size is
}

From source file:com.google.android.gcm.demo.app.ServerUtilities.java

/**
 * Register this account/device pair within the server.
 *
 * @return whether the registration succeeded or not.
 *///from ww  w .  j ava2 s .co m
static boolean register(final Context context, final String regId) {
    Log.i(TAG, "registering device (regId = " + regId + ")");
    String serverUrl = SERVER_URL;
    Map<String, String> params = new HashMap<String, String>();
    params.put("regId", regId);
    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 {
            displayMessage(context, context.getString(R.string.server_registering, i, MAX_ATTEMPTS));
            post(serverUrl, params);
            GCMRegistrar.setRegisteredOnServer(context, true);
            String message = context.getString(R.string.server_registered);
            CommonUtilities.displayMessage(context, message);
            return true;
        } catch (IOException 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);
            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;
        }
    }
    String message = context.getString(R.string.server_register_error, MAX_ATTEMPTS);
    CommonUtilities.displayMessage(context, message);
    return false;
}

From source file:GCMRegistrationService.java

@Override
protected void onHandleIntent(Intent intent) {
    super.onCreate();
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    try {/*  w ww. ja  va 2s .  co  m*/
        InstanceID instanceID = InstanceID.getInstance(this);
        String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
                GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
        Log.i("GCMRegistrationService", "GCM Registration Token: " + token);
        //sendTokenToServer(token);
        sharedPreferences.edit().putBoolean(SENT_TOKEN, true).apply();
    } catch (Exception e) {
        sharedPreferences.edit().putBoolean(SENT_TOKEN, false).apply();
    }
}

From source file:com.ncu.sdroidagent.ServerUtilities.java

/**
 * Register this account/device pair within the server.
 *
 *//*  ww w.java2  s . c  o m*/
public static void register(final Context context, String name, String email, final String regId) {
    Log.i(TAG, "registering device (regId = " + regId + ")");

    String serverUrl = SERVER_URL + "/SDroid/RegisterServlet.do";

    Map<String, String> params = new HashMap<String, String>();
    params.put("regId", regId);
    params.put("name", name);
    params.put("email", email);

    try {
        post(serverUrl, params);
        GCMRegistrar.setRegisteredOnServer(context, true);
        String message = context.getString(R.string.server_registered);
        CommonUtilities.displayMessage(context, message);

    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

/**
 * Tries to figure out if the current phone is Galaxy S based, since it has
 * recording issues This is pretty nasty since we are string matching, but
 * unless I can get a better way to do it...
 * /*ww  w .  j a v  a2 s .  c om*/
 * @param
 */
public static boolean isSamsungGalaxyS() {
    String manufacturer = android.os.Build.MANUFACTURER.toLowerCase();
    String model = android.os.Build.MODEL.toLowerCase();
    String device = android.os.Build.DEVICE.toLowerCase();
    Log.i(TAG_AUDIOHELPER,
            String.format("manufacturer: %s, model: %s, device: %s", manufacturer, model, device));

    if (manufacturer.equals(MANUFACTURER_SAMSUNG)) {
        if (device.equals(DEVICE_ID_GALAXY_S)) {
            Log.i(TAG_AUDIOHELPER, "Samsung Galaxy S detected");
            return true;
        }

        if (device.equals(DEVICE_ID_CAPTIVATE)) {
            Log.i(TAG_AUDIOHELPER, "ATT, Samsung Captivate detected");
            return true;
        }

        if (device.equals(DEVICE_ID_VIBRANT)) {
            Log.i(TAG_AUDIOHELPER, "T-Mobile US, Samsung Vibrant detected");
            return true;
        }

        if (device.equals(DEVICE_ID_EPIC)) {
            Log.i(TAG_AUDIOHELPER, "Sprint, Samsung Epic 4G detected");
            return true;
        }

        if (device.equals(DEVICE_ID_FASCINATE)) {
            Log.i(TAG_AUDIOHELPER, "Verizon, Samsung Fascinate detected");
            return true;
        }

        if (device.equals(DEVICE_ID_MESMERIZE)) {
            Log.i(TAG_AUDIOHELPER, "Samsung Mesmerize detected");
            return true;
        }
    }
    return false;
}

From source file:Main.java

public static boolean is3gpFileAudio(String url) {
    int height = 0;
    File mediaFile = new File(url);
    try {//www  .j av a  2s .c  om
        MediaPlayer mp = new MediaPlayer();
        FileInputStream fs;
        FileDescriptor fd;
        fs = new FileInputStream(mediaFile);
        fd = fs.getFD();
        mp.setDataSource(fd);
        mp.prepare();
        height = mp.getVideoHeight();
        mp.release();
    } catch (Exception e) {
        Log.e("KKIM", "Exception trying to determine if 3gp file is video.", e);
    }
    Log.i("KKIM", "The height of the file is " + height);
    return height == 0;
}

From source file:org.liberty.android.fantastischmemo.downloader.DownloaderUtils.java

public static String downloadJSONString(String url) throws Exception {
    HttpClient httpclient = new DefaultHttpClient();
    HttpGet httpget = new HttpGet(url);
    HttpResponse response;/*w  w  w  . j a v a  2s .  co  m*/
    response = httpclient.execute(httpget);
    Log.i(TAG, "Response: " + response.getStatusLine().toString());
    HttpEntity entity = response.getEntity();

    if (entity == null) {
        throw new NullPointerException("Null entity error");
    }

    InputStream instream = entity.getContent();
    // Now convert stream to string 
    BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
    StringBuilder sb = new StringBuilder();
    String line = null;
    String result = null;
    while ((line = reader.readLine()) != null) {
        sb.append(line + "\n");
    }
    result = sb.toString();

    return result;
}