public static void manageAds(Activity activity) { final PackageManager pm = activity.getPackageManager(); // get a list of installed apps. List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA); boolean yboTvProFound = false; for (ApplicationInfo info : packages) { if (PACKAGE_PRO.equals(info.packageName)) { yboTvProFound = true; break; } } // Look up the AdView as a resource and load a request. AdView adView = (AdView) activity.findViewById(R.id.adView); if (yboTvProFound) { View layout = activity.findViewById(R.id.ad_container); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) layout.getLayoutParams(); layoutParams.bottomMargin = 0; layout.setLayoutParams(layoutParams); adView.setVisibility(View.GONE); } else { adView.loadAd(new AdRequest.Builder().build()); } }
// PackageManager pm = context.getPackageManager(); // 获得PackageManager对象 // 查询所有已经安装的应用程序 public static void getIcon() { Log.i("acanoe", "------------app icon------------"); Bitmap map = null; List<ApplicationInfo> listAppcations = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); Collections.sort(listAppcations, new ApplicationInfo.DisplayNameComparator(pm)); // 排序 for (ApplicationInfo info : listAppcations) { // if(info.packageName.equals(context.getPackageName())){ Log.d("icon", "save"); map = drawableToBitmap(info.loadIcon(pm)); FileUtils.isFolderExists("/sdcard/phonemanager"); // File myCaptureFile = new File( "/sdcard/phonemanager" + videoList.get(position).title // +".jpg"); File myCaptureFile = new File("/sdcard/phonemanager/test" + (String) info.loadLabel(pm) + ".jpg"); BufferedOutputStream bos; try { Log.d("acanoe", "app icon"); bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile)); map.compress(Bitmap.CompressFormat.JPEG, 80, bos); // bos.flush(); // bos.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block Log.d("acanoe", "save jpg error"); e.printStackTrace(); } // } } // return map; }
private List<ApplicationInfo> getInstallAppMethod2() { PackageManager pm = getPackageManager(); // TODO get apps in separate thread or do in background thread. List<ApplicationInfo> apps = pm.getInstalledApplications(0); List<ApplicationInfo> systemInstalledApps = new ArrayList<ApplicationInfo>(); List<ApplicationInfo> userInstalledApps = new ArrayList<ApplicationInfo>(); if (apps != null) { for (ApplicationInfo app : apps) { // this flag to check for system app if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 1) { // add system installed app systemInstalledApps.add(app); } else { // in this case, it should be a user-installed app // add user installed app userInstalledApps.add(app); } } } if (systemInstalledApps.size() > 0) { for (int i = 0; i < systemInstalledApps.size() - 1; i++) { ApplicationInfo ai = systemInstalledApps.get(i); Log.i("", i + "-app packageName name - " + ai.packageName); } } return userInstalledApps; }
public static ArrayList<Item> GetInstalledApps(Context context) { ArrayList<Item> appList = new ArrayList<Item>(); List<ApplicationInfo> myApplications; Bitmap APKIcon; Drawable icon; final PackageManager pm = context.getPackageManager(); myApplications = pm.getInstalledApplications(PackageManager.GET_META_DATA); for (ApplicationInfo packageInfo : myApplications) { if (!Arrays.asList(SystemApps).contains(packageInfo.packageName)) { icon = packageInfo.loadIcon(pm); if (icon instanceof BitmapDrawable) { APKIcon = ((BitmapDrawable) icon).getBitmap(); } else { Bitmap bitmap = Bitmap.createBitmap( icon.getIntrinsicWidth(), icon.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); icon.draw(canvas); APKIcon = bitmap; } appList.add( new Item( APKIcon, (String) pm.getApplicationLabel(packageInfo), packageInfo.packageName, true)); } } return appList; }
@Override public void init() { try { this.loadOrCreateLastRun(); } catch (IOException e) { Log.w(TAG, "couldn't read lastrun.txt", e); } makeSureDirectoryExists(ORIGINAL_EXTRACTED_DIR); makeSureDirectoryExists(TEMP_MODDED_DIR); PackageManager pm = WoGInitData.getPackageManager(); String originalLocation = null; for (ApplicationInfo app : pm.getInstalledApplications(0)) { if (app.packageName.equals(WOG_PACKAGE_NAME)) { Log.i(TAG, String.format("Found World of Goo apk in %s", app.sourceDir)); originalLocation = app.sourceDir; WOG_APK_FILE = new File(originalLocation); isWogFound = true; } } if (!isWogFound) { Log.i(TAG, "World of Goo apk not found. Is it installed?"); return; } if (lastRunData.get("original_apk_extracted").equals("true")) { return; } forceClean(); lastRunData.put("original_apk_extracted", "true"); saveLastRun(); }
private static List<String> getPackageDatas(Context context) { List<String> packageDatas = new ArrayList<String>(); PackageManager packageManager = context.getPackageManager(); List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_META_DATA); for (ApplicationInfo appInfo : list) { StringBuffer data = new StringBuffer(); try { PackageInfo packageInfo = packageManager.getPackageInfo(appInfo.packageName, PackageManager.GET_META_DATA); data.append(appInfo.packageName); // パッケージ名 data.append(","); data.append(packageInfo.versionName); // バージョン } catch (NameNotFoundException e) { e.printStackTrace(); } packageDatas.add(data.toString()); } Collections.sort( packageDatas, new Comparator<String>() { public int compare(String lhs, String rhs) { return lhs.compareTo(rhs); } }); return packageDatas; }
/** * returns list of all packages installed * * @return List<String> of all installed packages */ public List<String> getAllPackages() { settingsDB dataSrc = new settingsDB(context); dataSrc.open(); showadv = Boolean.parseBoolean(dataSrc.getSetting("showadv")); boolean tmp = false; List<String> out = new ArrayList<String>(); final PackageManager pm = context.getPackageManager(); List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA); allNames.clear(); allEnabled.clear(); for (ApplicationInfo packageInfo : packages) { for (int i = 0; i < MainActivity.CBAllBlackList.length; i++) { if (MainActivity.CBAllBlackList[i].contains(packageInfo.packageName)) { tmp = true; break; } } if (!tmp || showadv) { out.add(packageInfo.packageName); allNames.add(pm.getApplicationLabel(packageInfo).toString()); allEnabled.add(packageInfo.enabled); } allAdv.add(tmp); tmp = false; } dataSrc.close(); return out; }
// common utility - get intent by label, null if not found public Intent getIntentByLabel(String label) { PackageManager pm = getPackageManager(); for (ApplicationInfo packageInfo : pm.getInstalledApplications(PackageManager.GET_META_DATA)) { if (label.equals(pm.getApplicationLabel(packageInfo))) return pm.getLaunchIntentForPackage(packageInfo.packageName); } return null; }
public static boolean IsPackageInstalled(String targetPackage, Context context) { List<ApplicationInfo> packages; PackageManager pm; pm = context.getPackageManager(); packages = pm.getInstalledApplications(0); for (ApplicationInfo packageInfo : packages) { if (packageInfo.packageName.equals(targetPackage)) return true; } return false; }
@Override protected void onPreExecute() { PackageManager pm = getPackageManager(); try { pkgAppsList = pm.getInstalledPackages(0); } catch (RuntimeException e) { // this is usually thrown when people have too many things installed (or bloatware in the // case of Samsung devices) pm = getPackageManager(); appsList = pm.getInstalledApplications(0); } }
@NonNull private List<ApplicationInfo> getAllAppInfos() { List<ApplicationInfo> installedApplications = mPackageManager.getInstalledApplications(0); Iterator<ApplicationInfo> infoIterator = installedApplications.iterator(); while (infoIterator.hasNext()) { ApplicationInfo next = infoIterator.next(); if (mPackageManager.getLaunchIntentForPackage(next.packageName) == null) { infoIterator.remove(); } } return installedApplications; }
public static ApplicationInfo getApplicationInfo(Context context, String processName) { if (processName == null) { return null; } PackageManager packageManager = context.getApplicationContext().getPackageManager(); List<ApplicationInfo> appList = packageManager.getInstalledApplications(8192); for (ApplicationInfo appInfo : appList) { if (processName.equals(appInfo.processName)) { return appInfo; } } return null; }
@Override protected void onHandleIntent(Intent intent) { Log.v(ApeicUtil.TAG_HTTP, "UpdateInstalledAppsIntentService onHandleIntent"); PackageManager pm = getPackageManager(); Set<String> currInstalledApps = new HashSet<String>(); for (ApplicationInfo info : pm.getInstalledApplications(PackageManager.GET_META_DATA)) { if (pm.getLaunchIntentForPackage(info.packageName) != null) { currInstalledApps.add(info.packageName); } } ApeicPrefsUtil prefsUtil = ApeicPrefsUtil.getInstance(this); Set<String> registeringApps = prefsUtil.getStringSetPref(ApeicPrefsUtil.KEY_REGISTERING_APPS); if (registeringApps.size() > 0) { Log.v(ApeicUtil.TAG_HTTP, "Re-update newly installed apps."); registerApps(prefsUtil.getStringSetPref(ApeicPrefsUtil.KEY_REGISTERING_APPS)); } Set<String> unregisteringApps = prefsUtil.getStringSetPref(ApeicPrefsUtil.KEY_REGISTERING_APPS); if (unregisteringApps.size() > 0) { Log.v(ApeicUtil.TAG_HTTP, "Re-update uninstalled installed apps."); unregisterApps(prefsUtil.getStringSetPref(ApeicPrefsUtil.KEY_UNREGISTERING_APPS)); } if (prefsUtil.getPrefs().contains(ApeicPrefsUtil.KEY_INSTALLED_APPS)) { Set<String> lastInstalledApps = prefsUtil.getStringSetPref(ApeicPrefsUtil.KEY_INSTALLED_APPS); Set<String> newlyInstalledApps = getNewlyInstalledApps(currInstalledApps, lastInstalledApps); if (newlyInstalledApps.size() > 0) { Log.v(ApeicUtil.TAG_HTTP, "Newly installed Apps: "); registerApps(newlyInstalledApps); } Set<String> removedApps = getUninstalledApps(currInstalledApps, lastInstalledApps); if (removedApps.size() > 0) { Log.v(ApeicUtil.TAG_HTTP, "Uninstalled Apps: "); unregisterApps(removedApps); } } else { Log.v(ApeicUtil.TAG_HTTP, "Current installed Apps: "); registerApps(currInstalledApps); } ApeicPrefsUtil.getInstance(this) .setStringSetPref(ApeicPrefsUtil.KEY_INSTALLED_APPS, currInstalledApps); }
public void load_app_list() { __DEBUG__("load_app_list()"); if (m_list_items != null) { __DEBUG__("load_app_list(): adding... "); final android.content.pm.PackageManager pm = getPackageManager(); List<ApplicationInfo> packages = null; if (pm == null) return; packages = pm.getInstalledApplications(android.content.pm.PackageManager.GET_META_DATA); if ((packages == null) || packages.isEmpty()) return; /* for ( android.content.pm.ApplicationInfo packageInfo : packages ) { __DEBUG__( "load_app_list(): Installed package :" + packageInfo.packageName ); __DEBUG__( "load_app_list(): Source dir : " + packageInfo.sourceDir ); __DEBUG__( "load_app_list(): Launch Activity :" + pm.getLaunchIntentForPackage(packageInfo.packageName) ); } // the getLaunchIntentForPackage returns an intent that you can use with startActivity() */ __DEBUG__("load_app_list(): package size = " + packages.size()); for (int i = 0; i < packages.size(); i++) { if ((packages.get(i).flags & ApplicationInfo.FLAG_SYSTEM) != 0) continue; // __DEBUG__( "load_app_list(): list = " + i + " {" ); // __DEBUG__( "load_app_list(): Installed package = " + packages.get(i).packageName ); // __DEBUG__( "load_app_list(): name = " + (String)packages.get(i).loadLabel(pm) ); // __DEBUG__( "load_app_list(): Source dir = " + packages.get(i).sourceDir ); // __DEBUG__( "load_app_list(): Launch Activity = " + // pm.getLaunchIntentForPackage(packages.get(i).packageName) ); // __DEBUG__( "load_app_list(): icon id = " + packages.get(i).icon ); // __DEBUG__( "load_app_list(): }" ); HashMap<String, Object> map = new HashMap<String, Object>(); if (map != null) { map.put(Common.__ALARM_LIST__KEY__APP_NAME__, (String) packages.get(i).loadLabel(pm)); map.put(Common.__ALARM_LIST__KEY__APP_PKG_NAME__, (String) packages.get(i).packageName); map.put(Common.__ALARM_LIST__KEY__APP_ICON__, (Drawable) packages.get(i).loadIcon(pm)); // map.put( Common.__ALARM_LIST__KEY__APP_ICON_ID__, packages.get(i).icon ); m_list_items.add(map); } } } }
private List<ApplicationInfo> createAppList() { ArrayList<ApplicationInfo> appList = new ArrayList<ApplicationInfo>(); List<ApplicationInfo> list = pm.getInstalledApplications(PackageManager.GET_META_DATA); int l = list.size(); for (int i = 0; i < l; i++) { try { if (pm.getLaunchIntentForPackage(list.get(i).packageName) != null) { appList.add(list.get(i)); } } catch (Exception ex) { ex.printStackTrace(); } } return appList; }
/** * @param context * @return 所有已安装应用的图标,名称,是否为系统应用,是否安装在内部储存 */ public static List<AppInfo> getAppInfo(Context context) { List<AppInfo> appInfos = new ArrayList<AppInfo>(); PackageManager packageManager = context.getPackageManager(); List<ApplicationInfo> applications = packageManager.getInstalledApplications(0); for (ApplicationInfo applicationInfo : applications) { AppInfo appInfo = new AppInfo(); appInfo.setIcon(applicationInfo.loadIcon(packageManager)); appInfo.setSysApp((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0); appInfo.setInRom((applicationInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0); appInfo.setAppName(applicationInfo.loadLabel(packageManager).toString()); appInfo.setPackName(applicationInfo.packageName); System.out.println(appInfo); appInfos.add(appInfo); } return appInfos; }
public static ApplicationInfo findApplication(Context context, String regex, boolean system) { ApplicationInfo info = null; if (context != null) { String[] regs = regex.split("\\|"); // 0:start, 1:end, 2:contain PackageManager pm = context.getPackageManager(); List<ApplicationInfo> list = null; try { list = pm.getInstalledApplications(0); } catch (Exception e) { } boolean match = true; if (list != null && list.size() != 0) { String pkgName = ""; for (ApplicationInfo pn : list) { if (system && (!pn.publicSourceDir.contains("/system/app") && !pn.publicSourceDir.contains("/system/priv-app"))) { continue; } pkgName = pn.packageName; if (!regs[0].trim().equals("")) { match = pkgName.startsWith(regs[0].trim()); } if (match && !regs[1].trim().equals("")) { match = pkgName.endsWith(regs[1].trim()); } if (match && !regs[2].trim().equals("")) { match = pkgName.contains(regs[2].trim()); } if (match) { try { info = pm.getApplicationInfo(pkgName, 0); } catch (Exception e) { } if (info != null) { break; } } } } } return info; }
public static Usage getUsageData(Context context) { Usage usage = new Usage(); List<Application> result = new ArrayList<Application>(); usage.setApplications(result); mPm = context.getPackageManager(); ArrayList<String> runningNames = getRunningProcesses(context); List<ApplicationInfo> allInfo = mPm.getInstalledApplications(0); Set<Integer> uids = new TreeSet<Integer>(); long total_recv = TrafficStats.getTotalRxBytes(); long total_sent = TrafficStats.getTotalTxBytes(); long mobile_recv = TrafficStats.getMobileRxBytes(); long mobile_sent = TrafficStats.getMobileTxBytes(); for (ApplicationInfo info : allInfo) { Integer uid = info.uid; if (uids.contains(uid)) continue; uids.add((Integer) uid); long recv = TrafficStats.getUidRxBytes(uid); long sent = TrafficStats.getUidTxBytes(uid); // remove those application which do not sent and recv data if (recv > 0 || sent > 0) { Application app = new Application(); app.setName(AppUsageUtil.getAppLabel(context, uid)); app.setPackageName(AppUsageUtil.getAppPkg(context, uid)); app.setIcon(AppUsageUtil.getAppIcon(context, uid)); app.setTotal_recv(TrafficStats.getUidRxBytes(uid)); app.setTotal_sent(TrafficStats.getUidTxBytes(uid)); app.setIsRunning(runningNames.contains(AppUsageUtil.getAppPkg(context, uid))); result.add(app); } } usage.setTotal_recv(total_recv); usage.setTotal_sent(total_sent); usage.setMobile_recv(mobile_recv); usage.setMobile_sent(mobile_sent); return usage; }
@Override protected List<AppInfo> doInBackground(Void... objects) { List<AppInfo> labelsPackages = new ArrayList<AppInfo>(); PackageManager packageManager = activity.getPackageManager(); Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0); for (PackageItemInfo appInfo : appInfos) { String packageName = appInfo.packageName; if (!isHidden(packageName)) { CharSequence label = appInfo.loadLabel(packageManager); Drawable icon = appInfo.loadIcon(packageManager); if (label != null) { labelsPackages.add(new AppInfo(packageName, label.toString(), icon)); } } } Collections.sort(labelsPackages); return labelsPackages; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_notifications); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle("Set which apps to block"); packageManager = getPackageManager(); appList = packageManager.getInstalledApplications(packageManager.GET_META_DATA); NotificationsAdapter adapter = new NotificationsAdapter(this, R.layout.activity_notifications, appList, packageManager); ListView listView = (ListView) findViewById(android.R.id.list); listView.setAdapter(adapter); }
public ArrayList<String> getAppsInstalled() { PackageManager packageManager = context.getPackageManager(); ArrayList<ApplicationInfo> listApp = (ArrayList<ApplicationInfo>) packageManager.getInstalledApplications(PackageManager.GET_ACTIVITIES); Iterator<ApplicationInfo> iterator = listApp.iterator(); ArrayList<String> lstApps = new ArrayList<String>(); while (iterator.hasNext()) { ApplicationInfo appInfo = (ApplicationInfo) iterator.next(); Intent intent = packageManager.getLaunchIntentForPackage(appInfo.packageName); if (intent != null) { lstApps.add(appInfo.packageName); } } return lstApps; }
private boolean unlockPremium() { boolean unlocked = false; PackageManager pm = mContext.getPackageManager(); List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA); for (ApplicationInfo applicationInfo : packages) { try { PackageInfo packageInfo = pm.getPackageInfo(applicationInfo.packageName, PackageManager.GET_PERMISSIONS); if ("org.gots.premium".equals(packageInfo.packageName)) { unlocked = true; } } catch (NameNotFoundException e) { Log.e(TAG, e.getMessage(), e); } } return unlocked; }
public boolean isAppsInstalled(String packageName) { boolean result = false; PackageManager packageManager = context.getPackageManager(); ArrayList<ApplicationInfo> listApp = (ArrayList<ApplicationInfo>) packageManager.getInstalledApplications(PackageManager.GET_ACTIVITIES); Iterator<ApplicationInfo> iterator = listApp.iterator(); while (iterator.hasNext()) { ApplicationInfo appInfo = (ApplicationInfo) iterator.next(); Log.i(this.getClass().getName(), appInfo.packageName + " vs " + packageName); if (appInfo.packageName.equals(packageName)) { result = true; break; } } return result; }
public int getUID() { int UID = 0; final PackageManager pm = getPackageManager(); // get a list of installed apps. List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA); // loop through the list of installed packages and see if the selected // app is in the list for (ApplicationInfo packageInfo : packages) { System.out.println(packageInfo.uid); if (packageInfo.packageName.equals("project.metrodatacollector")) { // get the UID for the selected app UID = packageInfo.uid; break; // found a match, don't need to search anymore } } return UID; }
@Background void isOldDonateVersionInstalled() { List<ApplicationInfo> packages; PackageManager pm; pm = getPackageManager(); packages = pm.getInstalledApplications(0); for (ApplicationInfo packageInfo : packages) { if (packageInfo.packageName.equals("com.nononsenseapps.notepad_donate")) { migrateDonateUser(); mHasPremiumAccess = true; // Allow them to donate again PreferenceManager.getDefaultSharedPreferences(ActivityMain.this) .edit() .putBoolean(PREMIUMSTATUS, true) .commit(); // Stop loop break; } } }
private List<AppInfo> loadApps(ProgressDialog dialog) { PackageManager packageManager = getPackageManager(); List<ApplicationInfo> packages = packageManager.getInstalledApplications(PackageManager.GET_META_DATA); List<AppInfo> apps = new ArrayList<AppInfo>(); dialog.setMax(packages.size()); int i = 1; for (ApplicationInfo app : packages) { AppInfo appInfo = new AppInfo(); appInfo.title = (String) app.loadLabel(packageManager); appInfo.summary = app.packageName; appInfo.icon = app.loadIcon(packageManager); appInfo.enabled = mSettingsHelper.isListed(app.packageName); apps.add(appInfo); dialog.setProgress(i++); } Collections.sort( apps, new Comparator<AppInfo>() { @Override public int compare(AppInfo appInfo1, AppInfo appInfo2) { boolean app1 = mSettingsHelper.isListed(appInfo1.summary); boolean app2 = mSettingsHelper.isListed(appInfo2.summary); if (app1 && app2 || !app1 && !app2) { return appInfo1.title.compareToIgnoreCase(appInfo2.title); } else if (app1) { return -1; } else if (app2) { return 1; } return 0; } }); return apps; }
private List<Sticker> getListApp() { List<Sticker> lstSticker = new ArrayList<Sticker>(); final PackageManager pm = getPackageManager(); // get a list of installed apps. List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA); for (ApplicationInfo packageInfo : packages) { if (!isSystemPackage(packageInfo)) { Sticker sticker = new Sticker( packageInfo.packageName, pm.getApplicationLabel(packageInfo).toString(), true); lstSticker.add(sticker); } } Collections.sort(lstSticker); return lstSticker; }
@Override protected List<AppModel> loadData(ProgressCallback callback) { List<AppModel> list = new ArrayList<AppModel>(); final PackageManager pm = getActivity().getPackageManager(); List<ApplicationInfo> la = pm.getInstalledApplications(PackageManager.GET_META_DATA); for (final ApplicationInfo info : la) { final AppModel app = new AppModel(); app.packageName = info.packageName; app.title = pm.getApplicationLabel(info).toString(); app.iconRefreshRunnable = new Runnable() { @Override public void run() { app.icon = new WeakReference<Drawable>(pm.getApplicationIcon(info)); } }; list.add(app); callback.updateProgress(list.size(), la.size()); } Collections.sort( list, new Comparator<AppModel>() { @Override public int compare(AppModel p1, AppModel p2) { return Collator.getInstance().compare(p1.title, p2.title); } }); // Add the Global config entry AppModel global = new AppModel(); global.packageName = "global"; global.title = getString(R.string.global); global.icon = null; list.add(0, global); return list; }
public static void killApps(boolean systemUI) { List<ApplicationInfo> packages; PackageManager pm; pm = c.getPackageManager(); packages = pm.getInstalledApplications(0); ActivityManager mActivityManager = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE); for (ApplicationInfo packageInfo : packages) mActivityManager.killBackgroundProcesses(packageInfo.packageName); if (systemUI) { Process su = null; try { su = Runtime.getRuntime().exec("su"); } catch (IOException e) { e.printStackTrace(); } if (su != null) { try { DataOutputStream os = new DataOutputStream(su.getOutputStream()); os.writeBytes("pkill com.android.systemui \n"); os.flush(); os.writeBytes("exit\n"); os.flush(); su.waitFor(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } } }
protected List<ApplicationInfo> getInstalledApplications() { return packageManager.getInstalledApplications(PackageManager.GET_META_DATA); }