編輯:關於Android編程
public static boolean isTopActivy(String cmdName, Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ListrunningTaskInfos = manager.getRunningTasks(Integer.MAX_VALUE); String cmpNameTemp = null; if (null != runningTaskInfos) { cmpNameTemp = (runningTaskInfos.get(0).topActivity).toString(); } if (null == cmpNameTemp) { return false; } return cmpNameTemp.equals(cmdName); }
public static boolean isAppOnForeground(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); String packageName = context.getPackageName(); ListappTask = activityManager.getRecentTasks(Integer.MAX_VALUE, 1); if (appTask == null) { return false; } if (appTask.get(0).baseIntent.toString().contains(packageName)) { return true; } return false; }
private static ListgetAllTheLauncher(Context context) { List names = null; PackageManager pkgMgt = context.getPackageManager(); Intent it = new Intent(Intent.ACTION_MAIN); it.addCategory(Intent.CATEGORY_HOME); List ra = pkgMgt.queryIntentActivities(it, 0); if (ra.size() != 0) { names = new ArrayList (); } for (int i = 0; i < ra.size(); i++) { String packageName = ra.get(i).activityInfo.packageName; names.add(packageName); } return names; }
public static boolean isLauncherRunnig(Context context) { boolean result = false; Listnames = getAllTheLauncher(context); ActivityManager mActivityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List appList = mActivityManager.getRunningAppProcesses(); for (RunningAppProcessInfo running : appList) { if (running.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { for (int i = 0; i < names.size(); i++) { if (names.get(i).equals(running.processName)) { result = true; break; } } } } return result; }
AndroidStudio 的SVN 安裝和使用方法與我以前用的其他IDE 都有很大差別,感覺特麻煩,網上相關資料很少,貌似現在 Git 比較流行,之前有用過 githu
就在前幾天的一個晚上, Google召開了它的秋季發布會, 毫無懸念的宣布了它的最新手機品牌Pixel, 與此同時我的nexus設備也從親兒子降級成為干兒子. 不過還好G
今天這篇稍微增強點代碼量,可能要多花上5分鐘喽。本篇完成一個稍微顯得絢麗的菜單項,模仿優酷選擇菜單。如果想對其中的任意一項實現點擊功能,自行加入即可。現在就一步一步做出這
SearchView是android系統中內置的一個搜索框組件,可以很方便在添加在用戶界面之上,但是也帶來了一些問題,那就是searchview的UI是固定的,定制起來會