List of usage examples for android.app Activity getApplicationContext
@Override
public Context getApplicationContext()
From source file:Main.java
public static void blockRecentApps(Activity activity) { ActivityManager activityManager = (ActivityManager) activity.getApplicationContext() .getSystemService(Context.ACTIVITY_SERVICE); activityManager.moveTaskToFront(activity.getTaskId(), 0); }
From source file:Main.java
public static void disableRecentAppsClick(Activity activity) { ActivityManager activityManager = (ActivityManager) activity.getApplicationContext() .getSystemService(Context.ACTIVITY_SERVICE); activityManager.moveTaskToFront(activity.getTaskId(), 0); }
From source file:Main.java
public static boolean checkNet(Activity act) { ConnectivityManager manager = (ConnectivityManager) act.getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE); if (manager == null) { return false; }//from w w w. j a v a 2 s.c o m NetworkInfo networkinfo = manager.getActiveNetworkInfo(); if (networkinfo == null || !networkinfo.isAvailable()) { return false; } return true; }
From source file:Main.java
public static void restartClearActivity(Activity activity) { if (activity == null) return;/*from w w w.j a v a 2 s. co m*/ Context ctx = activity.getApplicationContext(); Intent intent; intent = activity.getIntent(); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION); activity.finish(); activity.overridePendingTransition(0, 0); ctx.startActivity(intent); activity.overridePendingTransition(0, 0); }
From source file:Main.java
public static void restartClearActivityOutside(Activity activity) { if (activity == null) return;/* w ww.j av a 2 s . c o m*/ Context ctx = activity.getApplicationContext(); Intent intent; intent = activity.getIntent(); intent.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION); activity.finish(); activity.overridePendingTransition(0, 0); ctx.startActivity(intent); activity.overridePendingTransition(0, 0); }
From source file:Main.java
private static void initializeVillage(Activity theActivity) { if (myPreferences == null) { myPreferences = PreferenceManager.getDefaultSharedPreferences(theActivity.getApplicationContext()); }/*from ww w . ja v a2 s. c o m*/ }
From source file:com.alex.utils.PermissionRequest.java
public static void onPermissionsDenied(final Activity activity, int requestCode) { onPermissionsDenied(activity, activity.getApplicationContext(), requestCode); }
From source file:Main.java
public static void skip(Activity aty, Class clazz) { if (aty == null || clazz == null) return;// w ww. j a va 2s .c om aty.startActivity(new Intent(aty.getApplicationContext(), clazz)); }
From source file:Main.java
public static int getNextEventCounter(Activity hostActivity, String key) { SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences(hostActivity.getApplicationContext()); int id = preferences.getInt(key, 0); id += 1;//from w w w .j av a2 s . c o m SharedPreferences.Editor editor = preferences.edit(); editor.putInt(key, id).commit(); return id; }
From source file:Main.java
public static void safeToastMessageShow(Activity pActivity, String pToastMsg, int pToastLength) { final String toastMsg = pToastMsg; final int toastLength = pToastLength; final Activity activity = pActivity; activity.runOnUiThread(new Runnable() { @Override/*from www. j a va 2 s .c om*/ public void run() { Toast.makeText(activity.getApplicationContext(), toastMsg, toastLength).show(); } }); }