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

热点内容
ftp服务器被动模式配置 发布:2025-07-04 05:17:32 浏览:331
电动车小龟有哪些配置 发布:2025-07-04 05:16:18 浏览:39
mysql同步存储过程 发布:2025-07-04 05:14:32 浏览:662
安卓手机如何控制空调 发布:2025-07-04 05:09:06 浏览:154
新洁尔灭用于物体表面怎么配置 发布:2025-07-04 05:03:28 浏览:829
生活中的云服务器 发布:2025-07-04 05:01:55 浏览:744
三星g6700c原始密码是多少 发布:2025-07-04 04:49:41 浏览:726
网页编程代码 发布:2025-07-04 04:47:25 浏览:805
发消息时用到什么密码 发布:2025-07-04 04:41:47 浏览:980
3个密码箱能装多少钱 发布:2025-07-04 04:39:36 浏览:11