How to invoke an app from another app in flex mobile

半世苍凉 提交于 2019-12-08 11:09:19

问题


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.


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/10487933/how-to-invoke-an-app-from-another-app-in-flex-mobile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!