Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App inside an app

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:

enter image description here

The idea behind this is:

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:

  • Start third party activity from inside my app
  • Start makro recording
  • Do something in third party activity
  • Stop makro recording
  • Use makro whenever you wish

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

like image 570
PKlumpp Avatar asked May 26 '14 11:05

PKlumpp


People also ask

What is an app within an app?

“In-app” refers to actions that take place within a mobile application. In-app actions commonly occur in paid apps, in the form of in-app purchases. The in-app purchase model enables free applications (mainly free games) to monetise their content and generate revenue.

How do I put an app in another app?

To take the user from one activity to another, your app must use an Intent to define your app's "intent" to do something. When you pass an Intent to the system with a method such as startActivity() , the system uses the Intent to identify and start the appropriate app component.


1 Answers

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.

With rooted phones:

  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.

  2. If the user now selects an app, launch it via an intent and create a system overlay to get all touch/key events (and let the user stop the macro). You can find a way to do this here. Store the x/y-values of the touch-events.
  3. You can recreate the events using MotionEvent#obtain.
  4. 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.

  5. 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

like image 89
Manuel Allenspach Avatar answered Oct 11 '22 15:10

Manuel Allenspach