how to open an Instagram page by as3 in android ai

2019-07-10 17:00发布

问题:

i want open an instagram page by clicking on a button in my app, for example "instagram/mypage" in Instagram app. whats the code?

mybuttun.addEventListener(MouseEvent.CLICK, open_instagram_page);
function open_instagram_page(event:MouseEvent)
{
    //what should i write here?
}

i found this code that open "setting" page of android device,how change it to open specific page on instagram app:

var url:String = ("intent:#Intent;" +
                  "action=android.intent.action.MAIN;" +
                  "category=android.intent.category.LAUNCHER;" +
                  "component=com.android.settings/.Settings;" +
                  "end");
navigateToURL(new URLRequest(url));

回答1:

You can use the Share ANE to do open the Instagram app to a specific page. The following works on Android and iOS:

var app:Application = new Application( "com.instagram.android", "instagram://" );

var options:ApplicationOptions = new ApplicationOptions();
options.action = ApplicationOptions.ACTION_VIEW;
options.data = "http://instagram.com/_u/distriqt";
options.parameters = "user?username=distriqt";

if (Share.service.applications.isInstalled( app ))
{
    Share.service.applications.launch( app, options );
}

I'm one of the developers of this ANE.



回答2:

You have to choose Air Native Extension (ANE),
that's very simple, first verify that Instagram is Installed, then just write native codes for that purpose and let AIR communicate between AS3 and Android machine.

the native code could be Java (for Android) and Objective-c (for IOS)

for beginning take a look at this official tutorial
also there is another Documentation around ANE