Example usage for android.util Log d

List of usage examples for android.util Log d

Introduction

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

Prototype

public static int d(String tag, String msg) 

Source Link

Document

Send a #DEBUG log message.

Usage

From source file:Main.java

public static List grabFiles() {
    List<String> tFileList = new ArrayList<String>();
    String p = Environment.getExternalStorageDirectory().getAbsolutePath() + "/nexsight/";
    File f = new File(p);

    Log.d(TAG, "Read from " + p);
    File[] files = f.listFiles();
    files = flipArray(files);/*from   www.j  a  v a  2s  . c o m*/
    if (files != null) {
        for (int i = 0; i < files.length; i++) {
            File file = files[i];
            tFileList.add(file.getPath());
        }
    } else {
        Log.w(TAG, "nothing found in " + p);
    }

    return tFileList;
}

From source file:Main.java

private static void shareImageOnFacebook(String imagePath, Context context) {

    Log.d("CitationsManager-ShareOnFb", "sharing the image " + imagePath);
    Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    // shareIntent.putExtra(Intent.EXTRA_TEXT, "www.google.com");
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));
    PackageManager pm = context.getPackageManager();
    List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
    for (final ResolveInfo app : activityList) {

        Log.d("CitationsManager-ShareOnFb", app.activityInfo.name);
        if ((app.activityInfo.name).contains("com.facebook") && !(app.activityInfo.name).contains("messenger")
                && !(app.activityInfo.name).contains("pages")) {
            final ActivityInfo activity = app.activityInfo;
            final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
            shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
            shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                    | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            shareIntent.setComponent(name);
            context.startActivity(shareIntent);
            break;
        }//  w  w w .  j a va2s . com
    }

}

From source file:Main.java

public static void openUrl(Context context, String url) {
    if (!url.startsWith("https://") && !url.startsWith("http://")) {
        url = "http://" + url;
    }/*  www.  j a v  a  2  s . c om*/

    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    Log.d("WipiwayController", "openUrl . Openning link - " + url);

    context.startActivity(i);
}

From source file:Main.java

public static float getScreenWidth(Activity activity) {
    if (mScreenWidth == 0) {
        Point size = new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(size);
        mScreenWidth = size.x;/*from w w w . j  a v a2  s  .co m*/
        Log.d(TAG, "screen size is " + size);
    }
    return mScreenWidth;
}

From source file:Main.java

public static Location chooseBetterLocation(Location location1, Location location2) {
    if (location1 != null) {
        Log.i(TAG, "Location1 : Lat: " + location1.getLatitude() + " Lng: " + location1.getLongitude());
    } else {/*w  w w.j a  v  a 2 s  . c om*/
        Log.d(TAG, "Location1 is null!");
        return location2;
    }
    if (location2 != null) {
        Log.i(TAG, "Location2 : Lat: " + location2.getLatitude() + " Lng: " + location2.getLongitude());
    } else {
        Log.d(TAG, "Location2 is null!");
        return location1;
    }

    if (location1.getTime() > location2.getTime()) {
        return chooseTimeOrderedLocation(location1, location2);
    } else {
        return chooseTimeOrderedLocation(location2, location1);
    }
}

From source file:Main.java

protected static void debug(String message) {
    if (logDebug) {
        Log.d(LOGTAG, message);
    }
}

From source file:Main.java

/**
 * Function to stop a service./*w  w  w .  ja  v a 2  s .c o m*/
 *
 * @param cls The service's class.
 */
public static void stopService(Class<?> cls, Activity activity) {
    if (serviceIsRunning(cls, activity)) {
        activity.stopService(new Intent(activity, cls));
        Log.d("Utils Service", "Service Stopped");
    }
}

From source file:Main.java

public static String getImageAsString(Bitmap bmp) {
    ByteArrayOutputStream bYtE = new ByteArrayOutputStream();

    bmp.compress(Bitmap.CompressFormat.JPEG, 100, bYtE);
    byte[] byteArray = bYtE.toByteArray();
    String image = Base64.encodeToString(byteArray, Base64.DEFAULT);
    bmp.recycle();// ww w .  ja v a  2s.  c  o  m
    Log.d("Converted TO : ", image);
    return image;
}

From source file:Main.java

public static void createNarDirOnSDCard() {
    File narDir = new File(Environment.getExternalStorageDirectory(), "nar");
    if (narDir.exists() && narDir.isDirectory())
        return;//from w  w  w.  jav a  2  s. c  om

    boolean success = narDir.mkdirs();
    if (success == false)
        Log.d(TAG, "nar folder creation failed");
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.KITKAT)
public static boolean isAllowed(Context context, int op) {
    Log.d(TAG, "api level: " + Build.VERSION.SDK_INT);
    if (Build.VERSION.SDK_INT < 19) {
        return true;
    }//from ww w  . j av a 2 s.co  m
    Log.d(TAG, "op is " + op);
    String packageName = context.getApplicationContext().getPackageName();
    AppOpsManager aom = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
    Class<?>[] types = new Class[] { int.class, int.class, String.class };
    Object[] args = new Object[] { op, Binder.getCallingUid(), packageName };
    try {
        Method method = aom.getClass().getDeclaredMethod("checkOpNoThrow", types);
        Object mode = method.invoke(aom, args);
        Log.d(TAG, "invoke checkOpNoThrow: " + mode);
        if ((mode instanceof Integer) && ((Integer) mode == AppOpsManager.MODE_ALLOWED)) {
            Log.d(TAG, "allowed");
            return true;
        }
    } catch (Exception e) {
        Log.e(TAG, "invoke error: " + e);
        e.printStackTrace();
    }
    return false;
}