Get the App
SLTechnology News&Howtos  ›  Development  › 

How to get the information of installed applications in android mobile phone

Shulou Source: shulou.com Published: 2022-06-03 09:40:52 09月12日 Update

This article mainly introduces how to obtain the application information installed in the android phone, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let's take a look at it.

Just take it and use it:

/ * whether the application * @ param context * @ param apk_package package name * @ return * / public static boolean isInstallApp (Context context, String apk_package) {PackageInfo packageInfo has been installed Try {packageInfo = context.getPackageManager () .getPackageInfo (apk_package, 0);} catch (NameNotFoundException e) {packageInfo = null; e.printStackTrace () } if (packageInfo! = null) {return true;} return false } / * traverses the specified files in the folder under a path * @ param Path search directory * @ param Extension extension (the suffix of the file type determined) * @ param IsIterative whether to enter the subfolder * @ return * / public static final List GetFiles (String Path, String Extension) Boolean IsIterative) {List apklist = new ArrayList () / / result List try {File [] files = new File (Path). ListFiles (); for (int I = 0; I < files.length; iTunes +) {File f = files [I] If (f.isFile ()) {if (f.getPath () .substring (f.getPath (). Length ()-Extension.length ()) .equals (Extension)) / / determine the extension apklist.add (f.getPath ()) If (! IsIterative) break / / if you do not enter the subset directory, jump out of} else if (f.isDirectory () & & f.getPath (). IndexOf ("/.") = =-1) / / ignore point files (hidden files / folders) GetFiles (f.getPath (), Extension, IsIterative) / / here we begin to recurse}} catch (Exception e) {/ / TODO: handle exception e.printStackTrace ();} return apklist } / * install apk * @ param apk_url * / public static void installApkFromLocalPath (Context context,String apk_url) {try {Intent intent = new Intent (Intent.ACTION_VIEW) according to the local path Intent.setDataAndType (Uri.fromFile (new File (apk_url)), "application/vnd.android.package-archive"); context.startActivity (intent);} catch (Exception e) {/ / TODO: handle exception e.printStackTrace () }} / * Uninstall the application * @ param context * @ param apk_pkg package name * / public static void unInstallApkFromPackage (Context context,String apk_pkg) {try {Intent intent = new Intent (Intent.ACTION_DELETE) Intent.setData (Uri.parse ("package:" + apk_pkg)); context.startActivity (intent);} catch (Exception e) {/ / TODO: handle exception e.printStackTrace () }} / * Open another application according to the package name * @ param context * @ param apk_pkg package name * / public static void openApkFromPackage (Context context,String apk_pkg) {try {Intent intent = new Intent (Intent.ACTION_VIEW) Intent.setComponent (new ComponentName (context, apk_pkg)); context.startActivity (intent);} catch (Exception e) {/ / TODO: handle exception e.printStackTrace () }} Thank you for reading this article carefully. I hope the article "how to get the Information of applications installed in android phones" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Files applications articles folders information mobile phones extensions directories paths values interests at the same time suffixes subsets more friends knowledge types results tape Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker OPPO Reno Shulou Technology Huawei Apple