List of usage examples for android.content Context getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:Main.java
public static String getMainActivityName(Context context) { String classname = context.getClass().getName(); return classname; }
From source file:Main.java
public static ComponentName getComponentName(Context context) { return new ComponentName(context, context.getClass()); }
From source file:Main.java
public static void MyLog_e(Context context, String str) { if (isOpen) { Log.e(context.getClass().getSimpleName(), str); }/*from w ww .ja v a2 s . c om*/ }
From source file:Main.java
public static void i(Context context, String msg) { try {/*from w w w .j a v a 2 s .c o m*/ Log.i("" + context.getClass().getSimpleName(), msg); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void i(Context context, String message) { String tag = context.getClass().getSimpleName(); i(tag, message); }
From source file:Main.java
public static void e(Context context, String message) { String tag = context.getClass().getSimpleName(); e(tag, message); }
From source file:Main.java
public static void showException(Context parent, Throwable ex) { if (ex != null) { Log.e(parent.getClass().getSimpleName(), ex.getLocalizedMessage(), ex); new AlertDialog.Builder(parent).setTitle("Error").setMessage(ex.getLocalizedMessage()) .setNeutralButton("Close", null).show(); }//from w ww. jav a2 s . co m }
From source file:Main.java
public static void d(Context context, String message) { String tag = context.getClass().getSimpleName(); d(tag, message); }
From source file:Main.java
/** * Fetch the versionCode from the AndroicManifest.xml * //from w w w . j a va 2s. co m * @param context * @return the versionCode */ public static int getVersionCode(Context context) { try { ComponentName comp = new ComponentName(context, context.getClass()); PackageInfo pinfo = context.getPackageManager().getPackageInfo(comp.getPackageName(), 0); return pinfo.versionCode; } catch (android.content.pm.PackageManager.NameNotFoundException e) { return 0; } }
From source file:Main.java
/** * Fetch the versionName from the AndroicManifest.xml * /*from w w w . j a v a 2s . co m*/ * @param context * @return the versionName */ public static String getVersionName(Context context) { try { ComponentName comp = new ComponentName(context, context.getClass()); PackageInfo pinfo = context.getPackageManager().getPackageInfo(comp.getPackageName(), 0); return pinfo.versionName; } catch (android.content.pm.PackageManager.NameNotFoundException e) { return null; } }