當前位置:首頁 » 安卓系統 » android獲取應用名稱

android獲取應用名稱

發布時間: 2024-12-03 01:50:27

❶ 請問如何獲取安卓正在前台運行的應用程序的包名

在framework中想添加這個功能,所以寫了個appliction來實現一下獲取正在運行的應用程序: 還是先看圖吧: 這個app主要是簡單的實現了獲取非系統的應用程序和一些常用的系統應用程序,顯示在一個listview中,並添加了點擊(回復到你打開的界面)和長按事件(關閉應用程序)。 看看代碼吧: 直接貼出來再加上注釋吧(直接寫在一個文件里): package andorid/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <ImageView android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:layout_width="40dip" android:layout_height="40dip" /> <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textStyle="bold" /> <TextView android:id="@+id/info" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> </LinearLayout> main: <?xml version="1/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <ListView android:id="@+id/list_view" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" ></ListView> </LinearLayout> 在manifest文件中要加以個許可權: <uses-permission android:name="android.permission.RESTART_PACKAGES" /> 主要是前面的am.killBackgroundProcesses(packageName);方法要這個許可權。

❷ Android開發怎麼獲取應用列表所有應用的中文名

Android應用只存在應用名,不存在應用中文名,你要獲取的是不是主界面圖標底下的名字?
ArrayList<AppInfo> appList = new ArrayList<AppInfo>(); //用來存儲獲取的應用信息數據
List<PackageInfo> packages = getPackageManager().getInstalledPackages(0);
for(int i=0;i<packages.size();i++) { PackageInfo packageInfo = packages.get(i); AppInfo tmpInfo =new AppInfo(); tmpInfo.appName =packageInfo.applicationInfo.loadLabel(getPackageManager()).toString(); tmpInfo.packageName = packageInfo.packageName; tmpInfo.versionName = packageInfo.versionName; tmpInfo.versionCode =packageInfo.versionCode; tmpInfo.appIcon = packageInfo.applicationInfo.loadIcon(getPackageManager()); appList.add(tmpInfo);
}

熱點內容
矩陣內的演算法 發布:2025-09-18 20:55:07 瀏覽:569
android網路優化 發布:2025-09-18 20:53:19 瀏覽:216
看交換機配置哪些是默認的 發布:2025-09-18 20:46:59 瀏覽:617
在釘釘上如何獲取自己的密碼 發布:2025-09-18 20:46:12 瀏覽:853
pythonifthenelse 發布:2025-09-18 20:33:19 瀏覽:911
熱血傳奇腳本怎麼做 發布:2025-09-18 20:29:06 瀏覽:609
軒逸手動經典有哪些配置 發布:2025-09-18 20:20:40 瀏覽:625
安卓手機下載軟體在哪裡設置密碼 發布:2025-09-18 20:10:08 瀏覽:608
net業務緩存框架 發布:2025-09-18 19:57:14 瀏覽:17
pythonrst 發布:2025-09-18 19:28:50 瀏覽:415