应用内的应用 [英] App inside an app

查看:78
本文介绍了应用内的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从另一个应用程序内部运行一个应用程序?我要做的是编写一个应用程序,使您可以选择一个应用程序来启动,然后在视图中显示该应用程序的活动.

Is it possible to run an application from inside another application? What I want to do is write an app which allows you to chose an app to start, and then displays the activities of this app inside a view.

因此在横向模式下,它应该看起来像这样:

So in landscape mode, it should look something like this:

其背后的想法是:

我希望能够在自己的活动旁边启动和运行第三方活动,并且希望能够通过控制第三方活动的活动来创建单独的Makros.

I want to be able to start and run a third party activity next to my own activity, and I want to be able to create individual makros with my activity that are controlling the third party activity.

基本上是这样的:

Basically, something like this:

  • 从我的应用程序内部开始第三方活动
  • 开始进行makro录制
  • 在第三方活动中做某事
  • 停止录制makro
  • 随时随地使用makro

那我该如何从自己的活动中启动和控制另一个活动?

So how can I start and control another activity from inside my own activity?

推荐答案

无根:
可悲的是,如果不扎根手机,您想要实现的目标似乎是不可能的,因为您只能通过意图与其他应用程序进行交互.由于开发人员决定了他们的应用如何对特定意图做出反应,因此以这种方式创建宏几乎是不可能的.

Unrooted:
Sadly, what you want to achieve does not seem to be possible without rooting the phone, because you can only interact with other apps via intents. Since developers decide how their apps react on specific intents, creating macros this way is nearly impossible.

使用扎根手机:

  1. 您可能要创建所有已安装应用程序的列表,可以使用

  1. You may want to create a list of all installed apps, you can use

getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA);

检索所有已安装应用程序的列表.

to retrieve a list of all installed apps.

现在出现了需要扎根电话的部分(权限

Now comes the part where you need a rooted phone (the permission INJECT_EVENTS). Launch the app and inject the events so your macro gets executed. Samplecode:

Instrumentation m_Instrumentation = new Instrumentation();
m_Instrumentation.sendPointerSync(motionEvent);

您可以找到有关注入(以及关键事件)的更多信息

You can find more information about injecting (also keyevents) here.

如果您需要编译应用程序的帮助,这两个链接将为您提供帮助: Android INJECT_EVENTS权限

If you need help to compile your app, these 2 links will help you: How to compile Android Application with system permissions, Android INJECT_EVENTS permission

这篇关于应用内的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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