请问如何获取安卓正在前台运行的应用程序的包名

请问如何获取安卓正在前台运行的应用程序的包名,第1张

在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="androidpermissionRESTART_PACKAGES" /> 主要是前面的amkillBackgroundProcesses(packageName);方法要这个权限。

以上就是关于请问如何获取安卓正在前台运行的应用程序的包名全部的内容,包括:请问如何获取安卓正在前台运行的应用程序的包名、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/9485832.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-28
下一篇 2023-04-28

发表评论

登录后才能评论

评论列表(0条)

保存