Search code examples
androidactionscript-3air

how to open an Instagram page by as3 in android air application?


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));

Solution

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