android-package-managers

Get Preferred/Default app on Android

对着背影说爱祢 提交于 2019-11-28 08:40:32
I am trying to get the default/preferred application for a given Intent . For example, when the user installs a second web browser, then attempts to open a URL, he or she will get a dialog like this: If the user then selects the Use by default for this action option, then the dialog box no longer opens when a URL is pressed. I am working on an application that should be aware of what this default or preferred app/action is. How do I do this? I am currently using the code below, but getPreferredPackage doesn't return anything: Intent i = (new Intent(Intent.ACTION_VIEW, Uri.parse("https://www

Android M reflection method freeStorageAndNotify exception

佐手、 提交于 2019-11-28 08:22:35
I'm using reflection method freeStorageAndNotify: Method freeStorageAndNotify = null; freeStorageAndNotify = service.packageManager.getClass().getMethod( "freeStorageAndNotify", long.class, IPackageDataObserver.class); freeStorageAndNotify.invoke(PackageManager.class, maxCache + freeSpace, packageDataObserver); This causes InvocationTargetException: java.lang.SecurityException: Neither user 10199 nor current process has android.permission.CLEAR_APP_CACHE. Some points: - I already have android.permission.CLEAR_APP_CACHE - This happens only in android "M" Version (Flashed the preview sdk from

Is there a way to keep meta-data in the Android manifest private to the package?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 08:06:19
问题 I want to use meta-data in the Android manifest to customize the behavior of a service. <service android:name=".SampleService" android:exported="false"> <meta-data android:name="sampleName" android:resource="@string/sampleValue" /> </service> My service is part of a library, and it is possible some may put sensitive data into these attributes when they use my service. Are these meta-data attributes visible to other installed packages on the phone via the PackageManager even if the service is

Get Recent and Running application list not processes

夙愿已清 提交于 2019-11-28 00:09:21
I tried a lot to get the list of recent and running applications(not processes) but couldn't get it. I went through all the stackoverflow questions regarding this but the only answer i got about the running processes and recent tasks not the application specific like we can see in Samsung Mobile task manager on long press of home button. I am able to get the Running processes by this code : ActivityManager actvityManager = (ActivityManager) this.getSystemService( ACTIVITY_SERVICE ); List<RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses(); for(RunningAppProcessInfo

Get active Application name in Android

落花浮王杯 提交于 2019-11-27 19:29:55
I am trying to make a program that shows all the active applications. I searched everywhere but could only find code that shows the package name only. It would be of great help if you masters can tell me how to display all the active application name Did you try using ActivityManager.getRunningAppProcesses() ? Here is the sample code for retrieving names: ActivityManager am = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE); List l = am.getRunningAppProcesses(); Iterator i = l.iterator(); PackageManager pm = this.getPackageManager(); while(i.hasNext()) { ActivityManager

How to get the list of apps that have been installed by a user on an Android device?

独自空忆成欢 提交于 2019-11-27 18:37:02
I am using the following piece of code at the moment: List<PackageInfo> packs = getPackageManager().getInstalledPackages(0); but it returns Apps that have been installed by the both device manufacturer and me. How to limit it so that only the apps that I installed are returned? Zelimir // Flags: See below int flags = PackageManager.GET_META_DATA | PackageManager.GET_SHARED_LIBRARY_FILES | PackageManager.GET_UNINSTALLED_PACKAGES; PackageManager pm = getPackageManager(); List<ApplicationInfo> applications = pm.getInstalledApplications(flags); for (ApplicationInfo appInfo : applications) { if (

Difference between adb “install” command and “pm install” command?

旧城冷巷雨未停 提交于 2019-11-27 17:42:13
问题 What's the difference between installing an app using the install command and using the package manager's pm install command? Do they do the exact same job? Does one command actually call the other in the back? adb install -r APK_FILE adb shell pm install APK_FILE 回答1: adb install is a command to run from a development host, which uploads a package somewhere temporary and then installs it. pm install is a command to run locally on the device. adb does indeed utilize the pm program on the

How to get information of an APK file in the file system (not just installed ones) without using File or file-path?

三世轮回 提交于 2019-11-27 17:05:31
问题 Background My app (here) can search for APK files throughout the file system (not just of installed apps), showing information about each, allowing to delete, share, install... As part of the scoped-storage feature on Android Q, Google announced that SAF (storage access framework) will replace the normal storage permissions. This means that even if you will try to use storage permissions, it will only grant to access to specific types of files for File and file-path to be used or completely

Android 6.0: Get package name of current activity [duplicate]

蹲街弑〆低调 提交于 2019-11-27 15:54:06
This question already has an answer here: Package name of current running application package name Android 6.0 [duplicate] 1 answer How to get package name from anywhere? 12 answers How to get current activity package name? as getRunningAppProcesses() not working in Android 6.0. Below is my code: grdPhoto.setOnItemClickListener(new AdapterView.OnItemClickListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { //get package name of current running application. ActivityManager mActivityManager =

Can PackageManager.getInstallerPackageName() tell me that my app was installed from Amazon app store?

隐身守侯 提交于 2019-11-27 12:48:50
I plan on publishing my app on Amazon app store as well as Google Play, and have some things in my app that need to behave slightly different depending on whether the app was installed from Amazon app store or not. If I understood the PackageManager.getInstallerPackageName(String packageName) method correctly, it tells me the name of the application that installed my app. Right? If so, does anyone know what the value returned by this method would be if my app was installed from Amazon app store? If not, does anyone know any other methods I can use to determine whether my app was installed from