android-package-managers

Android intent's resolveActivity and Package Manager

纵饮孤独 提交于 2019-12-11 04:10:08
问题 To check if an intent can be handled, you would call: if (intent.resolveActivity(getPackageManager()) != null) { // start activity } Question - why is the parameter to package manager needed if the same getPackageManager() is always passed? Are there cases where different package manager may be passed? 回答1: Package Manager is like a registry. it contains all details of application as given below that's why you are providing package manager args to resolve intent before the fire. alternatively

Error in Manifest.xml when adding PACKAGE_USAGE_STATS [Android Lollipop]

隐身守侯 提交于 2019-12-10 21:27:40
问题 I am trying to use "android.permission.PACKAGE_USAGE_STATS" in my app. Here it says that NOTE: This API requires the permission android.permission.PACKAGE_USAGE_STATS, which is a system-level permission and will not be granted to third-party apps. However, declaring the permission implies intention to use the API and the user of the device can grant permission through the Settings application. It seems that I will need the user to explicitly give my app the permission to give access to the

Get list of applications which can share data

别等时光非礼了梦想. 提交于 2019-12-10 14:19:33
问题 This code shows default share dialog Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/html"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Message")); startActivity(Intent.createChooser(sharingIntent,"Share using")); Question: Instead of showing the list of applications in the default system dialog, I want to get the list of applications and show them in my custom list. 回答1: Use the PackageManager with the Intent to get the list of applications

How to change theme from another app resource in android?

做~自己de王妃 提交于 2019-12-10 04:04:56
问题 I know there is a way to set themes by defining in styles.xml and use it like that setTheme(android.R.style.MyTheme); However, I want to get themes from another app which I developed as well. I know the resources names and actually I am able to get theme id with this code block; Resources res = getPackageManager().getResourcesForApplication("com.example.theme"); int resThemeId = res.getIdentifier("my_theme","style","com.example.theme"); When I debug, I see that resThemeId is not zero. Then, I

Get All Activities by using package Name

匆匆过客 提交于 2019-12-09 17:21:37
问题 I want to get all activities present in Application as a list by using PackageInfo. Please tell me is there any way to do this. Thanks in advance. 回答1: I got answer to my question as follows. public static ArrayList<ActivityInfo> getAllRunningActivities(Context context) { try { PackageInfo pi = context.getPackageManager().getPackageInfo( context.getPackageName(), PackageManager.GET_ACTIVITIES); return new ArrayList<>(Arrays.asList(pi.activities)); } catch (PackageManager.NameNotFoundException

Delta update for Android App updates

老子叫甜甜 提交于 2019-12-09 11:36:22
问题 I am trying to setup my own Server to host apk files which will be available for installs and updates in the client App. On new version update of apk, only the updated part should get downloaded at the client end. I am able to generate a patch file using "bsdiff" at the server end. But at the client, how should I merge the patch file with the original apk and install the update. 回答1: Based on your question, it looks like you are looking for some kind of patching system. Normally Google play

Storage permission restarts application

依然范特西╮ 提交于 2019-12-08 08:21:12
问题 I have a launcher application which runs on a custom firmware(have only Camera , Settings , Chrome & Explorer). The problem come when we ask user (runtime permission) for Manifest.permission.WRITE_EXTERNAL_STORAGE on denying the permission onRequestPermissionsResult gets called but on allowing the permission application restarts. This is not happening for Manifest.permission.CAMERA permission. I can't find any proper logs pointing to this issue. The same issue is happening for the above

Understanding how android app is installed by PackageManagerService

橙三吉。 提交于 2019-12-08 01:30:24
问题 So I've been digging around AOSP trying to figure out how an android app is installed. So far this is where I'm at: The apk File will be sent from PackageInstallerActivity to InstallAppProgress where it invokes the PackageManager method installPackage(). The previous call to PackageManager gets directed to the PackageManagerService, with the magic of AIDL (took some time for me to understand this). In the core method installPackageWithVerification() an instance of the PackageHandler gets

Android get a list of all installed apps

无人久伴 提交于 2019-12-07 13:30:22
问题 I have obtained a list of installed app using this code: public List<ResolveInfo>() { PackageManager pm=getPackageManager(); Intent main=new Intent(Intent.ACTION_MAIN, null); main.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> launchables=pm.queryIntentActivities(main, 0); } There is only a problem: it list only apps that has a MAIN activity. How can I get a List of all installed apps? Note that I used this code in a project that need that the List is of ResolveInfo, so please

Android: getting an APKs minSdkVersion from Android code [duplicate]

你离开我真会死。 提交于 2019-12-07 04:01:17
问题 This question already has answers here : Get minSdkVersion and targetSdkVersion from apk file (8 answers) Closed 2 years ago . I'm developing an Android app that has the ability of installing additional apps (which act as plugins for my app) if the user requires it. However, each of these additional apps may require a specific Android version to run. I would like to perform a check at runtime to see if the APK I'm trying to install is actually compatible with the device. Now, with the