android-package-managers

How can I find all the packages with a particular intent filter?

旧巷老猫 提交于 2019-12-24 14:43:15
问题 I need to get the names of all the installed packages whose names being with com.mridang . In order to do this, I'm using something on the lines of the following snippet: for (PackageInfo pkgPackage : mgrPackages.getInstalledPackages(0)) { if (pkgPackage.applicationInfo.packageName.startsWith("com.mridang.")) { System.out.println(pkgPackage.applicationInfo.packageName); } } I need to only get the names of those packages which have a service containing the following intent filter com.google

What's “PackageInstaller” class on Lollipop, and how to use it?

冷暖自知 提交于 2019-12-24 03:09:08
问题 Background I've noticed there is a new function on the PackageManager called "getPackageInstaller" , with minAPI 21 (Lollipop). I've reached the "PackageInstaller" class, and this is what it is written about it: Offers the ability to install, upgrade, and remove applications on the device. This includes support for apps packaged either as a single "monolithic" APK, or apps packaged as multiple "split" APKs. An app is delivered for installation through a PackageInstaller.Session, which any app

Android get list of non Play Store apps

左心房为你撑大大i 提交于 2019-12-24 00:47:11
问题 As a safety measure I would like to get the list of apps that aren't installed from the Play Store. Is there a way to do this? The packageManager contains a method getInstalledApplications but I don't know which flags to add to get the list. Any help would be appreciated. Edit: Here is an code example of v4_adi's answer. public static List<String> getAppsFromUnknownSources(Context context) { List<String> apps = new ArrayList<>(); PackageManager packageManager = context.getPackageManager();

How to close foreground app in Android service?

白昼怎懂夜的黑 提交于 2019-12-23 04:54:29
问题 I want to close current foreground app in Android service. However, it does not work in service. Could you have me to fix it? Thanks. ActivityManager manager = (ActivityManager) getApplicationContext().getSystemService(ACTIVITY_SERVICE); List<ApplicationInfo> packages; PackageManager pm; pm = getPackageManager(); //get a list of installed apps. packages = pm.getInstalledApplications(0); ActivityManager mActivityManager = (ActivityManager)getApplicationContext().getSystemService(Context

Clear Cache of All Apps in Marshmallow?

浪子不回头ぞ 提交于 2019-12-23 04:53:49
问题 I try to solve using below code: [Reference: Android: Clear Cache of All Apps? PackageManager pm = getPackageManager(); // Get all methods on the PackageManager Method[] methods = pm.getClass().getDeclaredMethods(); for (Method m : methods) { if (m.getName().equals("freeStorage")) { // Found the method I want to use try { long desiredFreeStorage = 8 * 1024 * 1024 * 1024; // Request for 8GB of free space m.invoke(pm, desiredFreeStorage , null); } catch (Exception e) { // Method invocation

Android get Phone Dialer app package instead of Contacts

坚强是说给别人听的谎言 提交于 2019-12-23 04:47:23
问题 I'm working on an android app where I get list of installed apps using this code: Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> allAppsInstalled = pm.queryIntentActivities(mainIntent, 0); then I assign each app icon, label and packagename to a recyclerview element where I can launch each package using the appropriate intent Intent launchIntent = pm.getLaunchIntentForPackage(packageName); context.startActivity

List of default apps showing wrong in Android L

允我心安 提交于 2019-12-22 03:37:29
问题 I want to get all default apps in Android L. I used bellow code but they give me a wrong solution. Let see my code first private void getMyAppLauncherDefault() { final IntentFilter filter = new IntentFilter(Intent.ACTION_MAIN); filter.addCategory(Intent.CATEGORY_HOME); List<IntentFilter> filters = new ArrayList<IntentFilter>(); filters.add(filter); List<ComponentName> activities = new ArrayList<ComponentName>(); final PackageManager packageManager = (PackageManager) getPackageManager();

List of default apps showing wrong in Android L

こ雲淡風輕ζ 提交于 2019-12-22 03:36:28
问题 I want to get all default apps in Android L. I used bellow code but they give me a wrong solution. Let see my code first private void getMyAppLauncherDefault() { final IntentFilter filter = new IntentFilter(Intent.ACTION_MAIN); filter.addCategory(Intent.CATEGORY_HOME); List<IntentFilter> filters = new ArrayList<IntentFilter>(); filters.add(filter); List<ComponentName> activities = new ArrayList<ComponentName>(); final PackageManager packageManager = (PackageManager) getPackageManager();

How to programmatically set a lock or pin for an app

你。 提交于 2019-12-18 10:20:53
问题 So right now I am trying to develop an Android App for my young children. I want to set a pin or passwords on selected applications for a particular amount of time to prevent them from opening the app. For example, let's say that my daughter wants to play angry birds for some time on my phone while I am doing work. I will select my important apps like messaging, gmail, etc and put a pin or password on it for 30 minutes while she plays angry birds. After 30 minutes, I get my phone from my

Android Package manager has died with TransactionTooLargeException

我怕爱的太早我们不能终老 提交于 2019-12-17 23:37:02
问题 My app reads the list of all installed APK files, and then loop through the list to read the APK info, however it throws a TransactionTooLargeException exception. From what I have read here http://developer.android.com/reference/android/os/TransactionTooLargeException.html, google recommends to break large transactions into smaller transactions. However it seems this happens in the middle when looping through the APK list. If I catch the exception and continue it, the rest all works fine. Is