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

热点内容
scratch少儿编程课程 发布:2025-04-16 17:11:44 浏览:626
荣耀x10从哪里设置密码 发布:2025-04-16 17:11:43 浏览:356
java从入门到精通视频 发布:2025-04-16 17:11:43 浏览:71
php微信接口教程 发布:2025-04-16 17:07:30 浏览:296
android实现阴影 发布:2025-04-16 16:50:08 浏览:787
粉笔直播课缓存 发布:2025-04-16 16:31:21 浏览:337
机顶盒都有什么配置 发布:2025-04-16 16:24:37 浏览:202
编写手游反编译都需要学习什么 发布:2025-04-16 16:19:36 浏览:798
proteus编译文件位置 发布:2025-04-16 16:18:44 浏览:355
土压缩的本质 发布:2025-04-16 16:13:21 浏览:582