opening another Android app in a 'new window' from Air - android

This is a little involved, so bear with me.
I've got two Android apps - one built in Adobe Air (the 'launcher') and one downloaded from the google play store (the 'target.') At a certain point I want the 'launcher' to open the 'target' and switch to it. Currently I'm doing this via the 'intent' protocol, like so:
navigateToURL(new URLRequest('intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;component=com.magix.camera_mx/com.magix.android.cameramx.main.MainMenu;end'));
... and it works, but when the 'target' (CameraMX in this example) opens, it uses the same 'window' as the 'launcher' app. Here's two screenshots, before and after opening the 'target:'
That's inconvenient, but I could put up with it if it was consistent. However, when I try the exact same process, only launching an arbitrary other app like Kingsoft Office:
navigateToURL(new URLRequest('intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;component=cn.wps.moffice_eng/cn.wps.moffice.documentmanager.PreStartActivity;end'));
The 'target' and 'launcher' exist as nice separate windows.
Why is that? What dictates whether an app comes up as a separate window, or reuses the current one? I've tried it with a handful - notably SoulCraft and Starchart launch in a new windows, but mostly the others all reuse the current window.
Is that something I have control over from within my air app? What's going on here?

What you're calling a "window" is referred to in Android as a "task". You should be able to force the target application to open in a new task by setting appropriate flags, namely FLAG_ACTIVITY_NEW_TASK (note the launchFlags=0x10000000):
intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10000000;component=<your-package-name>/.<your-activity-name>;end

The difference between your two scenarios (scenario 1 remains in a single task, scenario 2 starts a new task) is due to each "target" app's intent-filter manifest definition.
If you do not require a result from the Intent you can add flags (http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_NEW_TASK) like below:
navigateToURL(new URLRequest('intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10000000;component=com.magix.camera_mx/com.magix.android.cameramx.main.MainMenu;end'));

Related

My app not launching in split screen - why?

I can manually open my two apps in Split screen view, using the Recent apps button.
I believe I have added the "split screen support" in my apps, as per How to enable split screen in my Android app?
My targetSdkVersion is 29 and I have set resizeableActivity="true" in tag
Now I want to have one launcher to open both apps. I am using this open source app SplitScreenLauncher to launch my app. Following are the observations:
When I launch my two apps, using SplitScreenLauncher, it attempts to open them in split screen but then it immediately closes the 2nd app (I tried swapping the apps). It shows no error/message.
I try YouTube and Instagram. It clearly says "Your app doesn't support split screen" for Instagram.
I tried YouTube and Google Maps, it works.
When I use YouTube as first and MyApp as second app in SplitScreenLauncher, then it works. And if I use MyApp as first and YouTube as second app, then it doesn't work (acts like step 1). This is true for both of my apps, I tried one by one.
I have tried some tweaking in the code of this open source app, I don't understand why it doesn't work for my app.
In my app, I have removed any orientation restrictions in all activities, so it is auto rotate able.
What could be the issue?
I found the problem. It was in my Apps, both apps unfortunately. After Splash screen, I was doing startActivity() after finish(). finish() was closing all activities before i could start new, so split screen was going away. Now I finish() after startActivity(), and it works.
Try adding this line in your activitiies in manifest file
android:resizeableActivity="true"

Iterate all activities in one android app recursively

If we look at one activity as a graph node, transition/calling from one activity to another as a graph edge, one android app can be conceptually converted into a graph. I am trying to see if there is any way to create such a graph starting from the first page/activity of an app.
Let us say we can use android UI test automator to help if needed.
I am trying to see if there is any way to create such a graph starting from the first page/activity of an app.
It would be exceptionally difficult.
I am assuming that you are trying to hack... er, I mean, "analyze"... somebody else's app. In that case:
You have no idea how many activities there are, unless you are reverse-engineering the APK. And even then, you have no idea how those activities will be used (e.g., legacy app that is putting activities in tabs and not using them as an ordinary activity).
You have no way to know what triggers the activities to appear. For example, a certain activity might only appear via an "Easter egg"-style bizarre set of inputs. Some might be triggered by things outside the app itself, like a Notification or a third-party invocation of ACTION_VIEW for some MIME type the app supports. And some of the triggers may be dependent upon other inputs (e.g., a disabled action bar item that becomes enabled only if you have set up an account elsewhere in the app).
With full source code, you could do static analysis to find all startActivity() and startActivityForResult() calls, and for simple variations you might be able to divine which activity starts which. Even that could get tricky in some cases, for complex Intent construction.

Can an Android app interact with another app?

I want to be able to tap the statusbar and the contents in the displayed app to be scrolled up to the top.
Is it technically possible that an app intercept my tap and send the appropriate command to the active app? I have noticed for example that AntTek quick settings shows a drop-down window when swiping down from statusbar. While using the app I did also notice that even by just tapping the statusbar (before beginning to move the finger down), the app seems to already interact with the touch as it dims the screen brightness in preparation to display it's "window" (sorry I use the MS Windows term), so clearly a statusbar tap CAN be sensed by an app.
Starting from this, I wonder if such an app could then send a message to the active program telling it to scroll up.
Is that possible? And if yes, the message must be customized to a particular app (let's say the browser as the most important) or is it standardized so the apps speak the same language between themselves?
I am not a programmer so answers with codesamples might be less helpful than a plain english explanation. Finding out that is possible would lead rather to pursuing a programmer to implement the idea rather than starting to develop it myself.
Thanks :-)
There is an XPosed-module which seems to do exactly what you want.
To use XPosed-modules, you'll need to root your phone and install the XPosed-framework.
The XPosed-module is called "Statusbar Scroll to Top" and its repository can be found here:
http://repo.xposed.info/module/com.mohammadag.statusbarscrolltotop
This will work for almost all app-lists, but for example won't work for browser-content.
If you want to scroll to the top of the page in a browser, then you'll probably do best to get a browser which can do that on its own. (For example Habit Browser has it built-in and respective plugins are available for Firefox.)
Yes it is possible. HiroMacro and Frep can do this, but it requires root. https://play.google.com/store/apps/details?id=com.prohiro.macro&hl=en
(how do they simulate mouse and keyboard interactions on other applications? i have no clue :/ anyone?)
Is it technically possible that an app intercept my tap and send the appropriate command to the active app?
No. One app cannot send fake input to another app, for security reasons.
An android app comprises of several activities. Each activity display a GUI that allows the user to perform a specific task. To take the user from one activity to another, app must use an Intent to define our app’s intent to do something.
An intent can be explicit in order to start a specific component (a specific Activity instance) or implicit in order to start any component that can handle the intended action.
Interacting one app to other app in android
google docs link

Android - creating custom launcher

I am intending to develop custom Launcher for Android phone. I have searched web, but I haven't found any valuable information regarding creating "launcher" project. What does an android app needs for being at the top of the GUI (aka launcher)?
I saw this thread a while ago, before creating my own launcher. Here are some crucial things I learned:
Declaring your app to be a launcher
David already mentioned the piece of code that determines your app as a launcher:
<category android:name="android.intent.category.HOME" />
Add this as an intent-filter to the activity your launcher will use for the home screen (in AndroidManifest.xml).
Launcher Issues
As a launcher will run all the time, you need to understand the activity livecycle to prevent issues (like this one).
If you want users (and yourself) to be able to constantly user the app (that's what you usually do with launchers), make sure it never crashes. In the case of a crash users will be taken back to the devices default launcher or other installed ones.
In short: Launchers are expected to be reliable.
Common launcher functions (users usually expect those)
1) A list of apps / appdrawer
From which all apps can be launched or modified. You can use packageManager to list the apps.
As generating such a list may take a while, I suggest you to do it asynchronously and save the list somewhere to speed everything up (which also is expected from launchers ^^)
2) Some settings to change the launcher
I had some users stuck in my launcher before implementing those ^^
You can open the devices launcher settings like this (in Kotlin):
// working in APIs newer than Lollipop
val callHomeSettingIntent = Intent(Settings.ACTION_HOME_SETTINGS)
startActivity(callHomeSettingIntent)
Bonus) An in-app tutorial
This may be useful if you have some features in your app that are not trivial, ways of launching apps that users don't know from other apps.
It also gets you way less messages from users asking how to interact with your software.
Resources:
The GitHub of the minimal launcher I created may be helpful: finnmglas/Launcher
Well, firstly you need to listen to the android.intent.category.HOME intent. Here are some links with full source code which you can have a look at:
Old launcher source code
New launcher source code
Or take a look at launcher plus.

How do I run another Android application/activity in a window inside my app

What I want to do is be able to start another Android sub application (which I have not written myself) to run inside a window within my main application. I would want certain touch events etc on the elements of the main app that are still visible to allow me to stop the sub application.
I've found examples of how to launch another activity using an Intent - but I have found nothing allowing me to specify that it runs in a certain window.
Is this possible at all?
The window metaphor does not exist under normal Android.
Some tablet makers have added it to their builds, but using windows would reduce the portability of your app.

Categories

Resources