use of android.content.pm.PackageManager in project cw-advandroid by commonsguy.
the class TJDetect method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
HashSet<CharSequence> runningPackages = new HashSet<CharSequence>();
for (ActivityManager.RunningAppProcessInfo proc : am.getRunningAppProcesses()) {
for (String pkgName : proc.pkgList) {
runningPackages.add(pkgName);
}
}
PackageManager mgr = getPackageManager();
ArrayList<CharSequence> scary = new ArrayList<CharSequence>();
for (PackageInfo pkg : mgr.getInstalledPackages(PackageManager.GET_PERMISSIONS)) {
if (PackageManager.PERMISSION_GRANTED == mgr.checkPermission(android.Manifest.permission.SYSTEM_ALERT_WINDOW, pkg.packageName)) {
if (PackageManager.PERMISSION_GRANTED == mgr.checkPermission(android.Manifest.permission.INTERNET, pkg.packageName)) {
if (runningPackages.contains(pkg.packageName)) {
scary.add(mgr.getApplicationLabel(pkg.applicationInfo));
}
}
}
}
setListAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, scary));
}
use of android.content.pm.PackageManager in project cw-omnibus by commonsguy.
the class Nukesalot method buildAdapter.
private AppAdapter buildAdapter() {
HashSet<String> runningPackages = new HashSet<String>();
for (ActivityManager.RunningAppProcessInfo proc : am.getRunningAppProcesses()) {
for (String pkg : proc.pkgList) {
runningPackages.add(pkg);
}
}
PackageManager pm = getPackageManager();
List<ApplicationInfo> apps = new ArrayList<ApplicationInfo>();
for (ApplicationInfo app : pm.getInstalledApplications(0)) {
if (runningPackages.contains(app.packageName)) {
apps.add(app);
}
}
Collections.sort(apps, new ApplicationInfo.DisplayNameComparator(pm));
return (new AppAdapter(pm, apps));
}
use of android.content.pm.PackageManager in project UltimateAndroid by cymcsg.
the class PackageUtils method appInstalledOrNot.
public static boolean appInstalledOrNot(Context context, String uri) {
PackageManager pm = context.getPackageManager();
boolean app_installed = false;
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
app_installed = true;
} catch (PackageManager.NameNotFoundException e) {
app_installed = false;
}
return app_installed;
}
use of android.content.pm.PackageManager in project RocooFix by dodola.
the class RocooSoFix method getApplicationInfo.
private static ApplicationInfo getApplicationInfo(Context context) throws PackageManager.NameNotFoundException {
PackageManager pm;
String packageName;
try {
pm = context.getPackageManager();
packageName = context.getPackageName();
} catch (RuntimeException e) {
/*
* Ignore those exceptions so that we don't break tests relying on Context like a
* android.test.mock.MockContext or a android.content.ContextWrapper with a null base Context.
*/
Log.w(TAG, "Failure while trying to obtain ApplicationInfo from Context. " + "Must be running in test mode. Skip patching.", e);
return null;
}
if (pm == null || packageName == null) {
// This is most likely a mock context, so just return without patching.
return null;
}
ApplicationInfo applicationInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
return applicationInfo;
}
use of android.content.pm.PackageManager in project RocooFix by dodola.
the class RocooFix method getApplicationInfo.
private static ApplicationInfo getApplicationInfo(Context context) throws NameNotFoundException {
PackageManager pm;
String packageName;
try {
pm = context.getPackageManager();
packageName = context.getPackageName();
} catch (RuntimeException e) {
/* Ignore those exceptions so that we don't break tests relying on Context like
* a android.test.mock.MockContext or a android.content.ContextWrapper with a null
* base Context.
*/
Log.w(TAG, "Failure while trying to obtain ApplicationInfo from Context. " + "Must be running in test mode. Skip patching.", e);
return null;
}
if (pm == null || packageName == null) {
// This is most likely a mock context, so just return without patching.
return null;
}
ApplicationInfo applicationInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
return applicationInfo;
}
Aggregations