Android应用程序启动设备上的所有安装的应用程序 [英] Android App to launch all the installed apps on the device

查看:137
本文介绍了Android应用程序启动设备上的所有安装的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在测试应用程序的其他应用程序continuously.The后,将启动设备一个在每一个应用程序的工作主要是针对UI稳定性通过上下文switch.I测试是新来的Andr​​oid和试图找出沿东西way.I会深深AP preciate任何建议

I am working on a test app that will launch every app on the device one after the other continuously.The app is mainly intended for UI stability testing through context switch.I am new to Android and trying to figure out things along the way.I will deeply appreciate any suggestions

这是我的应用程序是假设做: -

This is what my app is suppose to be doing:-


  1. 查询设备,并获得设备上的所有应用程序的列表结果
    包括系统应用

  2. 现在,启动每个应用一前一后,直到所有设备上的应用程序正在启动

  3. 一旦它完成了通过列表一次去时,它从第一个应用程序再次启动了在列表中

  1. Query the device and get a list of all the apps on the device
    including system apps
  2. Now launch each app one after the other until all the apps on the device are launched
  3. Once it completes going through the list once,it starts over again from first app in the list

让我们称之为我的应用程序Launcher_app,说有5个应用程序A,B,C,D,E对device.Launcher应用程序将推出,则B,C,D,E的顺序,并推出一个重新开始。这是将继续下去,直到用户手动存在桌面应用

Lets call my app Launcher_app and say there are 5 apps A,B,C,D,E on the device.Launcher app will launch A,then B,C,D,E in that order and starts again by launching A.This is will continue until the user manually exist launcher app

我试图执行应用程序,但我有多么的Andr​​oid系统上的一些问题会允许这样的上下文切换。

I tried to implement the app,but I have a few questions on how android system will allow such a context switch.

这是一个code片段,自动启动每个应用程序

This is a code snippet that auto launches each app

ublic的AutoLaunch的Runnable =新的Runnable(){

ublic Runnable AutoLaunch = new Runnable() {

public void run()
{

   while(AppIndex < mAppsList.getCount())
   {


       //get the app name using index AppIndex
       //launch app using the appname
      App app = (App) mAppsList.getItemAtPosition(AppIndex);
     Intent i = getPackageManager().getLaunchIntentForPackage(app.getPackageName());
       try 
          {
             if (i != null) 
             {
                startActivity(i);

             } 
             else 
             {
                i = new Intent(app.getPackageName());
                startActivity(i);

             }
             for(int j=0;j<2000;j++)
                 for(int k=0;k<10000;k++)
                     continue;
             finish();

          } 
          catch (ActivityNotFoundException err) 
          {
             //Toast.makeText(ListInstalledApps.this, "Error launching app", Toast.LENGTH_SHORT).show();
          }

    if(AppIndex == mAppsList.getCount()-1)
          AppIndex = 0;
      else                
          AppIndex++;

   }

这是我的undertsanding: -

This is my undertsanding:-

桌面应用将是在开始的时候前台(FG)。
然后应用一个涉及到ForgroundñLauncher_app将进入背景(BG)。
现在,App B就涉及到FG和应用一进入BG与桌面应用一起。
继续这种方式,来当应用程序E为FG和应用程序,包括启动应用程序的其余均在BG时间。

Launcher app will be in foreground (FG) at the very beginning. then app A comes to Forground n Launcher_app will go into Background(BG). Now app B comes to FG and app A goes into BG along with Launcher app. Continuing this way there comes a time when app E is in FG and the rest of the apps including Launcher app are in BG.

当我尝试运行上面的实施应用,我看到了越来越的应用程序推出,但应用程序顺序randopm,另外,我不看得很应用ONT他设备入门推出,很可能这是发生得太快....不sure.I剪掉要继续,直到我knwo我在正确的轨道上。

When i try to run the app with above implementation ,I see the apps getting launched but the app order is randopm,also,I dont see very app ont he device getting launched,probably it's happening too fast....not sure.I didnt' want to proceed until I knwo I'm on the right track

在这种情况下,为下一次迭代,将Launhcer应用恢复应用程序A,B,C,D,E的顺序,或将它重新启动每个应用程序?也将桌面应用得到,如果系统需要在实际的场景记忆丧生其中,有接近50 ONT应用程序在运行BG.Or他设备将系统保持我的应用程序还活着,因为这是公司launchign所有其他应用程序的主应用程序。

In this situation for the next iteration ,will Launhcer app resume app A,B,C,D ,E in that order or will it restart each app ?Also will Launcher app get killed if the system needs memory in an actual scenario where there are close to 50 apps ont he device running in BG.Or will the system keep my app alive since this is the main app that's launchign all the other apps.

请帮我理解它是如何工作的,因为我真的wnat知道的是这样一个应用程序甚至是可行的?什么是解决上述issues.Will是任何类型的指针/建议表示感谢的最好方式。

Kindly help me understand how it works,as I really wnat to know is such an app is even feasible? What's the best way to address the above issues.Will be grateful for any kind of pointers /suggestions.

谢谢
迷你

推荐答案

这是什么:

for(int j=0;j<2000;j++)
    for(int k=0;k<10000;k++)
        continue;

如果你只是想引入的延迟,你可以简单地睡一会儿,或使用类似<一个href=\"http://developer.android.com/reference/android/os/Handler.html#postDelayed%28java.lang.Runnable,%20long%29\"相对=nofollow> postDelayed 空间了电话。

If you're just trying to introduce a delay, you could simply sleep for a while or use something like postDelayed to space out the calls.

我将与你的猜测一致认为,应用程序是简单的启动太快了。你基本上都推出他们全部一次,所以你会看到什么似乎是随机顺序(由于不同的启动时间),而有些甚至没有时间一个又一个争夺焦点前,以显示自己的UI。

I would agree with your guess that the apps are simply launching too fast. You're essentially launching all of them all at once, so you'll see what appears to be a random order (due to differing startup times) and some that don't even have time to display their UI before another one grabs focus.

修复您拖延code和这个最都要好得多。

Fix your delaying code and most of this should be much better.

这篇关于Android应用程序启动设备上的所有安装的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆