当前位置:首页 » 安卓系统 » 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-05-14 14:28:50 浏览:255
定期预算法的 发布:2025-05-14 14:24:08 浏览:894
interbase数据库 发布:2025-05-14 13:49:50 浏览:691
微商海报源码 发布:2025-05-14 13:49:42 浏览:347
分布式缓存部署步骤 发布:2025-05-14 13:24:51 浏览:611
php获取上一月 发布:2025-05-14 13:22:52 浏览:90
购买云服务器并搭建自己网站 发布:2025-05-14 13:20:31 浏览:689
sqlserver建立视图 发布:2025-05-14 13:11:56 浏览:485
搭建httpsgit服务器搭建 发布:2025-05-14 13:09:47 浏览:256
新电脑拿回来我该怎么配置 发布:2025-05-14 13:09:45 浏览:241