当前位置:首页 » 安卓系统 » 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);
}

热点内容
pythonrst 发布:2025-09-18 19:28:50 浏览:404
页面访问在线升级 发布:2025-09-18 19:13:46 浏览:773
相机存储满 发布:2025-09-18 19:12:19 浏览:754
如何搭载我的世界服务器 发布:2025-09-18 19:02:39 浏览:426
c语言组框 发布:2025-09-18 19:02:23 浏览:942
如何看见真我手机的全部配置 发布:2025-09-18 18:48:10 浏览:975
战地5默认是什么服务器 发布:2025-09-18 17:59:32 浏览:310
安卓变ios系统主题怎么弄 发布:2025-09-18 17:54:07 浏览:889
linux出口ip 发布:2025-09-18 17:51:57 浏览:950
androidbitmap使用 发布:2025-09-18 17:49:20 浏览:244