0

Is there a way to open one app from another app in Air? Example: I open app A which contains a button that opens app B when clicked. Suppose both A and B are separated apps that are installed in the device and that this device could be a PlayBook, an Ipad or an Android tablet.

Thanks.

edsv14
  • 9
  • 1
  • 5
  • Do you want to open apps cross device; ( I.E. an app on a Playbook opens an app on an iPad); or are you assuming both App A and app b are on the same device? I assume there is a way to use "URL Syntax" to launch another app--similar to how we may do this on the desktop--but I honestly don't know. – JeffryHouser May 07 '12 at 19:44
  • Thanks for your answer. Assuming both app A and app B are on the same device. If by using "URL Syntax" you mean something like this http://www.riaspace.com/2011/08/defining-custom-url-schemes-for-your-air-mobile-applications/, i think is not possible, since at the end of the post it says "One caveat is that invoking other apps with the custom URL schemes from AIR apps is not possible. The AIR security model is more restrictive and it limits schemes to: http:, https:, sms:, tel:, mailto:, file:, app:, app-storage:, vipaccess: and connectpro:". – edsv14 May 07 '12 at 20:11

2 Answers2

1

You'd have to go the Air Native Extension(ANE) route. Either create one ANE solution for iOS and Android each, or one ANE that abtracts the functionality into one solution. How to launch app A from app B on Android is not the same as on iOS. See this answer in SO.

To implement it on Android, you'd wraps the native Android Java solution in a ANE. The native Java code uses the package name of app B to launch app B from app A:

Intent intent = getPackageManager().getLaunchIntentForPackage("com.yourdoman.yourapp");
startActivity(intent);

Here is a video tutorial on how to launch an Activity through an ANE which you can build on to create your ANE. You'd have to tailor the solution to launch by domain instead of Activity.

Community
  • 1
  • 1
Gunnar Karlsson
  • 28,350
  • 10
  • 68
  • 71
  • Thanks for the answer, but what about PlayBook? is it possible to open one app from another in PlayBook even using ANE? – edsv14 May 08 '12 at 13:51
  • I'm not very familiar with the Playbook platform. You can repackage Android apps for it, as well as Air apps, but I doubt that includes intent functionality since intents are part of the Android system. – Gunnar Karlsson May 08 '12 at 14:29
0

Since I really don't know the specifics of what you are trying to do, I think I should point you here: http://www.riaspace.com/2011/08/defining-custom-url-schemes-for-your-air-mobile-applications/ It is the best answer to the question that I am aware of.

        private function getHostName() : void
        {
            if (NativeProcess.isSupported)
            {
                var OS : String = Capabilities.os.toLocaleLowerCase();
                var file : File;

                if (OS.indexOf('win') > -1)
                {
                    // Executable in windows
                    file = new File('C:\\Windows\\System32\\hostname.exe');
                }
                else if (OS.indexOf('mac') > -1 )
                {
                    // Executable in mac
                }
                else if (OS.indexOf('linux'))
                {
                    // Executable in linux
                }

                var nativeProcessStartupInfo : NativeProcessStartupInfo = new NativeProcessStartupInfo();
                nativeProcessStartupInfo.executable = file;

                var process : NativeProcess = new NativeProcess();
                process.addEventListener(NativeProcessExitEvent.EXIT, onExitError);
                process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutput);
                process.start(nativeProcessStartupInfo);
                process.closeInput();
            }
        }

        private function onOutput(event : ProgressEvent) : void
        {
            var strHelper : StringHelper = new StringHelper();
            formStationID.text = event.target.standardOutput.readUTFBytes(event.target.standardOutput.bytesAvailable);
            formStationID.text = strHelper.trimBack(formStationID.text, "\n");
            formStationID.text = strHelper.trimBack(formStationID.text, "\r");
        }

This code gets the workstation name. I have heard this can be done on IOS and Android, but I haven't found any proof of that yet.

powelljf3
  • 119
  • 4
  • Thanks for your answer. But i think what i'm trying to do is not possible using URL Schemes. At the end of post it says "One caveat is that invoking other apps with the custom URL schemes from AIR apps is not possible." – edsv14 May 07 '12 at 20:36
  • I tend to agree. On the desktop it is quite easy using NativeApplications, if you would like try that out... I will edit and add the appropriate code above. The code will open and run a command on the native stack, which in my case is to get the host name. – powelljf3 May 07 '12 at 20:43