简体   繁体   English

我怎么知道那个特定的应用程序。 在android中通过我的应用程序启动

[英]how can I know that certain app. in android is launched through my Application

I want do design App. 我要设计App。 which will able to detect that the a particular app. 它将能够检测到特定的应用程序。 is launched and I want to kill it( if it is in a block list). 被启动,我想杀死它(如果它在阻止列表中)。 How can I implement this? 我该如何实施?

Hello you can use the PackageManager clas for this: 您好,您可以使用PackageManager类别:

    List<PackageInfo> pInfos = getPackageManager().getInstalledPackages(PackageManager.GET_ACTIVITIES);
for (PackageInfo pInfo : pInfos) {
  ActivityInfo[] aInfos = pInfo.activities;
  if (aInfos != null) {
    for (ActivityInfo activityInfo : aInfos) {
      Log.i("ACT", activityInfo.name);
      // do whatever else you like... 
    }
  }
}

I guess you need to look at the ActivityManager ( http://developer.android.com/reference/android/app/ActivityManager.html ). 我想您需要查看ActivityManager( http://developer.android.com/reference/android/app/ActivityManager.html )。 This will help you to find the running process. 这将帮助您找到正在运行的过程。 Perhaps this helps: 也许这会有所帮助:

boolean ProcessRunning(String name) {
        ActivityManager manager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
        List<RunningProcess> processes = manager.getRunningAppProcesses();
        for (RunningProcess process : processes) {
            if (name.equals(process.name)) {
                return true;
            }
        }
        return false;
}

I didn't test this, but this link could also be helpful: Automate closing of applications in Android 我没有对此进行测试,但是此链接也可能会有所帮助: 在Android中自动关闭应用程序

您只能看到已启动的应用程序列表,并且不能通过自己的应用程序杀死其他应用程序,因为它是由OS处理的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android:如何知道是否可以启动应用 - Android: How to know if an app can be launched 我怎么知道我的应用是由 Google 助理打开的,而不是正常启动的 - How can I know that my app was opened by Google Assistant, instead of just normally launched 我如何知道何时启动和销毁Android应用程序? - How do I know when an Android app is launched and destroyed? 我的 android 应用程序中出现了联系人列表。 我想创建一个搜索框。 如何遍历列表视图并删除项目? - I have the list of contacts appear in my android App. I want to create a seachbox. How can I iterate through the list view and remove items? 我的 Android 应用程序中有大约 1000 个不同的活动。 如何跳转到随机活动? - I have around 1000 different activities in my Android App. How can I jump to a random activity? 开始我的第一个Android应用程序 如何轻松测试服务器是否收到消息? - Starting my first android app. How can I easily test if the server has received a message? 如何通过Android应用程序从应用商店下载应用程序? - How can I download application from app store through my android application? 我怎么知道我的应用程序的应用程序信息屏幕已打开 - How can I know that App info screen of My Application is opened Android:如何在我自己的应用程序中启动某个应用程序的快捷方式? - Android: How can I launch shortcut of a certain app in my own application? 我如何知道要显示或不显示通知的Android应用程序的应用程序状态? - How can I know the application state of an Android App to display or not a notification?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM