最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android ApplicationInfo 應(yīng)用程序信息的詳解

 更新時(shí)間:2017年10月09日 09:27:18   投稿:lqh  
這篇文章主要介紹了Android ApplicationInfo 應(yīng)用程序信息的詳解的相關(guān)資料,希望通過本文能幫助到大家,需要的朋友可以參考下

Android ApplicationInfo 應(yīng)用程序信息

1、簡述

1 ApplicationInfo是android.content.pm包下的一個(gè)實(shí)體類,用于封裝應(yīng)用的信息,flags是其中的一個(gè)成員變量public int flags = 0;用于保存應(yīng)用的標(biāo)志信息。

2 ApplicationInfo 通過它可以得到一個(gè)應(yīng)用基本信息。
   這些信息是從AndroidManifest.xml的< application >標(biāo)簽獲取的

3 ApplicationInfo對(duì)象里保存的信息都是<application>標(biāo)簽里的屬性值

4 ApplicationInfo與ResolveInfo比較:前者能夠得到Icon、Label、meta-data、description。后者只能得到Icon、Label


2、獲取ApplicationInfo

2.1 、獲取手機(jī)上安裝所有程序?qū)?yīng)的 ApplicationInfo

/**
* 獲取手機(jī)上安裝的所有的程序?qū)?yīng)的 ApplicationInfo
* 它是通過解析AndroidManifest.xml的< application>標(biāo)簽中得到的,所以它能得到所有的app
*
* 獲取手機(jī)上的所有的安裝的應(yīng)用程序信息
* 參數(shù)為 標(biāo)識(shí)  一般為 PackageManager.GET_UNINSTALLED_PACKAGES
*/
List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);

2.2 、獲取指定包名對(duì)應(yīng)的 ApplicationInfo

 /**
* 獲取指定應(yīng)用程序 ApplicationInfo
* 參數(shù)一對(duì)應(yīng)應(yīng)用程序的包名
* 參數(shù)二 應(yīng)用程序?qū)?yīng)的標(biāo)識(shí) 通常為 0
*/

      ApplicationInfo applicationInfo = packageManager.getApplicationInfo("com.androidlongs.contactsapplication", 0);


3、通過ApplicationInfo來獲取應(yīng)用程序的 基本信息

3.1 、獲取應(yīng)用程序?qū)?yīng)的包名、應(yīng)用名稱

//獲取應(yīng)用圖標(biāo)
Drawable drawable = applicationInfo.loadIcon(packageManager);

//獲取應(yīng)用程序的 包名
String appPackageName = applicationInfo.packageName;

//獲取應(yīng)用名
//參數(shù) packageManager 是應(yīng)用管理者對(duì)象 
String appName =applicationInfo.loadLabel(packageManager).toString();

3.2 、獲取應(yīng)用程序?qū)?yīng)數(shù)據(jù)的目錄以及占用的空間大小

//獲取應(yīng)用存放數(shù)據(jù)目錄
String dir = applicationInfo.sourceDir;
Log.d("app ","應(yīng)用存放數(shù)據(jù)目錄 " +dir);

 //獲取應(yīng)用數(shù)據(jù)大小
ong length = new File(dir).length();

//轉(zhuǎn)換為 M
float size = length*1f/1024/1024;
Log.d("app ","應(yīng)用數(shù)據(jù)大小 " +length+"\t"+size);

3.3 、判斷是否安裝在外置儲(chǔ)存空間存

//判斷是否安裝在外存
int flags = applicationInfo.flags;
if((flags&ApplicationInfo.FLAG_EXTERNAL_STORAGE)==ApplicationInfo.FLAG_EXTERNAL_STORAGE){
  Log.d("app "," 安裝在 外置存儲(chǔ)空間 ");
}else {
  Log.d("app "," 安裝在 內(nèi)置存儲(chǔ)空間 ");
}

3.4 、判斷應(yīng)用程序是否是系統(tǒng)應(yīng)用

//判斷是否是系統(tǒng)應(yīng)用
if((flags&ApplicationInfo.FLAG_SYSTEM)==ApplicationInfo.FLAG_SYSTEM){
  Log.d("app "," 是系統(tǒng)應(yīng)用 ");
}else{
  Log.d("app "," 不是系統(tǒng)應(yīng)用 ");
}

3.5 、manageSpaceActivityName

/**
 * 從”android:manageSpaceActivity“屬性得到
 * 用于指定一個(gè)Activity來管理數(shù)據(jù),
 * 它最終會(huì)出現(xiàn)在設(shè)置->應(yīng)用程序管理中,
 * 默認(rèn)為按鈕為”清除數(shù)據(jù)”,指定此屬性后,該按鈕可點(diǎn)擊跳轉(zhuǎn)到該Activity, 讓用戶選擇性清除哪些數(shù)據(jù)。若不設(shè)置則為null.
 */
String activityName = applicationInfo.manageSpaceActivityName;
Log.i("applicationInfo", "activityName: " + activityName);

3.6 、獲取應(yīng)用程序運(yùn)行的進(jìn)程

/**
 * 從”android:process“屬性得到,注明應(yīng)用運(yùn)行的進(jìn)程名?;虿辉O(shè)置則默認(rèn)為應(yīng)用包名。
 */
String processName = applicationInfo.processName;
Log.i("applicationInfo", "processName: " + processName);

3.7 、其他配置信息簡述

// 配置文件中的android:backupAgent屬性值,用于備份
      String backupAgentName = applicationInfo.backupAgentName;
      Log.i("applicationInfo", "backupAgentName: " + backupAgentName);
      // 獲取繼承Application類的對(duì)象,維護(hù)全局的Application狀態(tài)
      //但一般都不用繼承的方式,可以通過Context.getApplicationContext()方法得到
      String className = applicationInfo.className;
      Log.i("applicationInfo", "className: " + className);




      /**
       * 可選項(xiàng),訪問當(dāng)前應(yīng)用所有組件需要聲明的權(quán)限,從”android:permission“屬性得到。
       */
      String permisson = applicationInfo.permission;
      Log.i("applicationInfo", "permisson: " + permisson);
      // 創(chuàng)建對(duì)象時(shí),傳入的是GET_SHARED_LIBRARY_FILES該屬性才有值
      String[] files = applicationInfo.sharedLibraryFiles;
      Log.i("applicationInfo", "files: " + files);
      // 存放數(shù)據(jù)的路徑 應(yīng)用數(shù)據(jù)目錄。
      String dataPath = applicationInfo.dataDir;
      Log.i("applicationInfo", "dataPath: " + dataPath);
      // 本地路徑 JNI本地庫存放路徑。
      String nativePath = applicationInfo.nativeLibraryDir;
      Log.i("applicationInfo", "nativePath:" + nativePath);
      // 公共資源路徑
      String punlicSourcePath = applicationInfo.publicSourceDir;
      Log.i("applicationInfo", "punlicSourcePath: " + punlicSourcePath);
      // 資源路徑 應(yīng)用APK的全路徑
      String sourcePath = applicationInfo.sourceDir;
      Log.i("applicationInfo", "sourcePath: " + sourcePath);

      /**
       * 當(dāng)前應(yīng)用所有Activity的默認(rèn)task密切性。
       * 可以參考ActivityInfo的taskAffinity,從”android:taskAffinity“屬性得到。
       * 具體taskAffinity是怎么影響到Activity在task的啟動(dòng), 后面會(huì)在Activity啟動(dòng)模式中細(xì)講
       */
      String taskAffinity = applicationInfo.taskAffinity;
      Log.i("applicationInfo", "taskAffinity: " + taskAffinity);
      // 如果是false,代表application里的所有組件都禁用
      boolean enable = applicationInfo.enabled;
      Log.i("applicationInfo", "enable: " + enable);
      // 表述資源文件的標(biāo)識(shí)
      int descriRes = applicationInfo.descriptionRes;
      Log.i("applicationInfo", "descriRes: " + descriRes);
      int flag = applicationInfo.flags;
      Log.i("applicationInfo", "flag: " + flag);
      // 指定smallest screen width的值,超過這個(gè)值,就要開啟屏幕兼容
      int compatibleWidth = applicationInfo.compatibleWidthLimitDp;//android:compatibleWidthLimitDp屬性
      Log.i("applicationInfo", "compatibleWidth: " + compatibleWidth);
      // 同上,只是這時(shí)候用戶無法禁止屏幕兼容模式,說明是強(qiáng)制啟動(dòng)屏幕兼容
      int largestWidth = applicationInfo.largestWidthLimitDp;//android:largestWidthLimitDp屬性
      Log.i("applicationInfo", "largestWidth: " + largestWidth);
      // 所需屏幕空間的最短尺寸,
      int samllestWidth = applicationInfo.requiresSmallestWidthDp;//android:requiresSmallestWidthDp屬性
      Log.i("applicationInfo", "samllestWidth: " + samllestWidth);
      // 應(yīng)用所需的最小sdk版本
      int sdkVersion = applicationInfo.targetSdkVersion;
      Log.i("applicationInfo", "sdkVersion: " + sdkVersion);
      int theme = applicationInfo.theme;
      Log.i("applicationInfo", "theme: " + theme);//android:theme=
      int uid = applicationInfo.uid;
      Log.i("applicationInfo", "uid: " + uid);
      // 配置文件中的uiOptions屬性的值
      int uiOptions = applicationInfo.uiOptions;
      Log.i("applicationInfo", "uiOptions: " + uiOptions);

如有疑問請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

  • Android組件之BroadcastReceiver廣播接收者

    Android組件之BroadcastReceiver廣播接收者

    這篇文章主要為大家介紹了Android組件之BroadcastReceiver廣播接收者實(shí)現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-04-04
  • android基本控件ToggleButton&Switch使用指南

    android基本控件ToggleButton&Switch使用指南

    本文給大家匯總介紹了android的2個(gè)基本控件ToggleButton和Switch的使用方法,非常的詳細(xì),有需要的小伙伴可以參考下。
    2016-01-01
  • Android深入分析屬性動(dòng)畫源碼

    Android深入分析屬性動(dòng)畫源碼

    這篇文章主要給大家介紹了關(guān)于Android動(dòng)畫系列教程之屬性動(dòng)畫的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-08-08
  • Android GridView添加頭部問題的解決

    Android GridView添加頭部問題的解決

    這篇文章主要介紹了Android GridView添加頭部問題的解決,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-04-04
  • 揭秘雙十一手機(jī)淘寶圖標(biāo)如何被動(dòng)態(tài)更換

    揭秘雙十一手機(jī)淘寶圖標(biāo)如何被動(dòng)態(tài)更換

    這篇文章主要介紹了每到雙十一十二的時(shí)候Android手機(jī)動(dòng)態(tài)更換手機(jī)圖標(biāo)的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-08-08
  • Android中Fragment與Activity的生命周期對(duì)比

    Android中Fragment與Activity的生命周期對(duì)比

    這篇文章主要介紹了Android中Fragment與Activity的生命周期對(duì)比,Fragment是在Activity的基礎(chǔ)之上進(jìn)行設(shè)計(jì)的,比Activity多出幾個(gè)控制生命周期的回調(diào)函數(shù),需要的朋友可以參考下
    2016-02-02
  • Flutter WillPopScope攔截返回事件原理示例詳解

    Flutter WillPopScope攔截返回事件原理示例詳解

    這篇文章主要為大家介紹了Flutter WillPopScope攔截返回事件原理示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-09-09
  • kotlin的函數(shù)forEach示例詳解

    kotlin的函數(shù)forEach示例詳解

    在 Kotlin 中,forEach 是一個(gè)高階函數(shù),用于遍歷集合中的每個(gè)元素并對(duì)其執(zhí)行指定的操作,它的核心特點(diǎn)是 簡潔、函數(shù)式,適用于需要遍歷集合且無需返回值的場景,這篇文章主要介紹了kotlin的函數(shù)forEach示例詳解,需要的朋友可以參考下
    2025-03-03
  • 詳細(xì)介紹Android-Room數(shù)據(jù)庫的使用

    詳細(xì)介紹Android-Room數(shù)據(jù)庫的使用

    這篇文章主要介紹了詳細(xì)介紹Android-Room數(shù)據(jù)庫的使用,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-03-03
  • 基于Android 錯(cuò)誤信息捕獲發(fā)送至服務(wù)器的詳解

    基于Android 錯(cuò)誤信息捕獲發(fā)送至服務(wù)器的詳解

    本篇文章是對(duì)Android中錯(cuò)誤信息捕獲發(fā)送服務(wù)器進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06

最新評(píng)論

松桃| 波密县| 萨嘎县| 鄂州市| 禄劝| 永德县| 濮阳市| 惠东县| 蒙山县| 五华县| 壤塘县| 清水县| 景谷| 芮城县| 屏南县| 察隅县| 萨嘎县| 任丘市| 无棣县| 西贡区| 锡林郭勒盟| 嘉定区| 丹棱县| 嵩明县| 万宁市| 兴宁市| 容城县| 宝兴县| 磴口县| 炉霍县| 阿鲁科尔沁旗| 锡林浩特市| 义马市| 伊金霍洛旗| 鄂伦春自治旗| 思茅市| 龙南县| 尚义县| 泗水县| 綦江县| 青浦区|