android - 获取正在运行的应用程序 flutter

标签 android ios flutter background-process

我想知道我的flutter应用程序中当前在手机中运行的应用程序的包,例如“Forest”应用程序,当您打开某些应用程序时会弹出错误或调用函数。 我怎样才能做到这一点?

最佳答案

转到下面的链接并阅读它,然后你就会了解 flutter 背景是如何工作的。

Background with Flutter

编辑:

代码打击是你在android中想要的,现在只需搜索并找到在Flutter中执行此操作的库或方法即可。

ActivityManager activitymanager = 
(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);

 RAP = activitymanager.getRunningAppProcesses();
for(ActivityManager.RunningAppProcessInfo processInfo: RAP ){

Log.e("TAG",processInfo.processName);


 }

此打印 Logcat 中后台应用程序的列表。

希望对您有所帮助。

关于android - 获取正在运行的应用程序 flutter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58361469/

相关文章:

flutter/Dart : How to use async callback with Dart FFI?

flutter - 如何使用 Google Maps Plugin Flutter 为另一个类的相机制作动画

java - Jsch ssh 到 Raspberry Pi 不执行任何操作

Java - String.split不会用分号分隔

java - 安卓工作室 : Using ImageButton to start new activity crashes the app

android - 人行横道 web View 中的文件接受和捕获标签失败

ios - NSTimeZone 初始化结果为 "unable to read data"

ios - 将 Adob​​e Air App 交付到 AppStore 失败

ios - 无法向 UIView 添加两个手势

android - 将 JSON 嵌套到 flutter 中