Example usage for java.lang SecurityException printStackTrace

List of usage examples for java.lang SecurityException printStackTrace

Introduction

In this page you can find the example usage for java.lang SecurityException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:Main.java

public static int getMoveType(PackageInfo pInfo, ApplicationInfo info) {
    int moveType = MOVEAPPTYPE_NONE;
    if ((FLAG_EXTERNAL_STORAGE & info.flags) != 0) {
        moveType = MOVEAPPTYPE_MOVETOPHONE;
    } else if (pInfo != null) {
        int installLocation = 1;
        try {/*w w w  .j  a  v  a2  s .c  o  m*/
            Field field = pInfo.getClass().getDeclaredField("installLocation");
            field.setAccessible(true);
            installLocation = field.getInt(pInfo);
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        if (installLocation == 0) {
            moveType = MOVEAPPTYPE_MOVETOSDCARD;
        } else if (installLocation == -1 || installLocation == 1) {
            moveType = MOVEAPPTYPE_NONE;
        }
    }
    return moveType;
}

From source file:Main.java

public static int getMoveType(PackageInfo pInfo, ApplicationInfo info) {
    int moveType = MOVEAPPTYPE_NONE;
    if ((FLAG_EXTERNAL_STORAGE & info.flags) != 0) {
        moveType = MOVEAPPTYPE_MOVETOPHONE;
    } else if (pInfo != null) {
        int installLocation = 1;
        try {//from  w  w  w.ja v  a 2  s . c  om
            Field field = pInfo.getClass().getDeclaredField("installLocation");
            field.setAccessible(true);
            installLocation = field.getInt(pInfo);
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        if (installLocation == 0) {
            moveType = MOVEAPPTYPE_MOVETOSDCARD;
        } else if (installLocation == -1 || installLocation == 1) {
            moveType = MOVEAPPTYPE_NONE;
        }
    }
    System.out.println("moveType..............." + moveType);
    return moveType;
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static Method getMethod(Object target, String name, Class... parameterTypes) {
    String key = target.getClass().getSimpleName() + ":" + name + ":"
            + (parameterTypes == null ? 0 : parameterTypes.length);
    Method method = methods.get(key);
    if (method == null) {
        for (Class obj = target.getClass(); !obj.equals(Object.class); obj = obj.getSuperclass()) {
            try {
                method = obj.getDeclaredMethod(name, parameterTypes);
                method.setAccessible(true);
                methods.put(key, method);
                break;
            } catch (SecurityException e) {
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                e.printStackTrace();//ww w.j a  v a  2  s .com
            }
        }
    }
    return method;
}

From source file:Main.java

public static Object getVariableFromMethod(Activity activity, String method) {
    Object value = false;/*from  www.  ja v a 2 s .  c  om*/
    Class c = activity.getClass();
    try {
        Method m = (Method) c.getDeclaredMethod(method, new Class[] {});
        m.setAccessible(true);
        value = m.invoke(activity, new Object[] {});
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
    return value;
}

From source file:Main.java

static public boolean setPin(Class btClass, BluetoothDevice btDevice, String str) throws Exception {
    try {//from  www.  j a v a 2s .  c o m
        Method removeBondMethod = btClass.getDeclaredMethod("setPin", new Class[] { byte[].class });
        Boolean returnValue = (Boolean) removeBondMethod.invoke(btDevice, new Object[] { str.getBytes() });
        Log.v("tag", "++++++++++++" + returnValue);
        Log.e("returnValue", "" + returnValue);
    } catch (SecurityException e) {
        // throw new RuntimeException(e.getMessage());
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        // throw new RuntimeException(e.getMessage());
        e.printStackTrace();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return true;

}

From source file:Main.java

static public boolean setPin(Class<? extends BluetoothDevice> btClass, BluetoothDevice btDevice, String str)
        throws Exception {
    try {//  w w w.ja v a 2s.co  m
        Method removeBondMethod = btClass.getDeclaredMethod("setPin", new Class[] { byte[].class });
        Boolean returnValue = (Boolean) removeBondMethod.invoke(btDevice, new Object[] { str.getBytes() });
        Log.e("returnValue", "" + returnValue);
    } catch (SecurityException e) {
        // throw new RuntimeException(e.getMessage());  
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        // throw new RuntimeException(e.getMessage());  
        e.printStackTrace();
    } catch (Exception e) {
        // TODO Auto-generated catch block  
        e.printStackTrace();
    }
    return true;

}

From source file:Main.java

public static boolean isMeizuSecurity(Context context) {
    if (!isSecVer(context)) {
        return false;
    }//from w  ww .  ja v a  2  s .c  o  m
    Boolean valueOf = Boolean.valueOf(false);
    try {
        Boolean bool;
        Class cls = Class.forName("android.os.Build");
        Field field = cls.getField("MeizuSecurity");
        field.setAccessible(true);
        bool = (Boolean) field.get(cls);
        return bool;
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (Error e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return valueOf.booleanValue();
}

From source file:Main.java

public static Field getField(Class<?> targetClass, String name) {
    if (targetClass == null || TextUtils.isEmpty(name))
        return null;
    try {/*  w  ww.j a  va  2  s  .  co  m*/
        return targetClass.getDeclaredField(name);
    } catch (SecurityException e) {
        // ignore
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.yelinaung.android.utils.NetUtils.java

public static boolean isOnlineOrNot(Context c) {
    NetworkInfo netInfo = null;//from w  w w  .  j  av  a2  s . co  m
    try {
        ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
        netInfo = cm.getActiveNetworkInfo();
    } catch (SecurityException e) {
        e.printStackTrace();
    }
    return netInfo != null && netInfo.isConnectedOrConnecting();
}

From source file:org.simple.injector.SimpleDagger.java

/**
 * Fragment mView,?rootViewmView// ww w.  j a  va 2s.  c o m
 * 
 * @param fragment
 * @param rootView
 * @return
 */
private static boolean fuckTheFragment(Fragment fragment, View rootView) {
    try {
        Class<?> v4fragmentClass = fragment.getClass();
        while (v4fragmentClass != Object.class && !v4fragmentClass.equals(Fragment.class)) {
            v4fragmentClass = v4fragmentClass.getSuperclass();
        }
        Field rootViewField = v4fragmentClass.getDeclaredField("mView");
        rootViewField.setAccessible(true);
        rootViewField.set(fragment, rootView);
        Log.e("", "### getView " + fragment.getView());
        return true;
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

    return false;
}