Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Dan_B_2
Beginner
40 Views

Android: Using Intents with Intel XDK Buttons

Hello,

I've downloaded and created an android application with multiple graphic buttons.  The idea is to click on a button and have the system prompt for a user to select one of the installed web browsers on the device to open a hard-coded URL.  From what I've read the best way to do this is by using Intents but it doesn't seem to work.   I can get the default browser to open by specifying

window.open('http://www.google.ca','_system','location=yes');

but this is not the desired behaviour.   When I select the action for the button and edit script I use the following

 function register_event_handlers()
 {
    
    
     /* graphic button  Button */
    $(document).on("click", ".uib_w_2", function(evt)
    {
        /* your code goes here */ 
        
        String myURL= "http://www.google.ca";
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(myURL));
        intent.setType("application/browser");
        startActivity(Intent.createChooser(intent, null));
         return false;
    });
    
    }
 document.addEventListener("app.Ready", register_event_handlers, false);
})();

But this throws a number of errors stating Intent, myURL are not defined and "expected an assignment or function call and instead saw an expression".   I'm not sure what I'm doing wrong here.  Can someone please advise?  I have installed the InAppBrowser for Cordova and http://*/* whitelisted for allowed-intent.

Thank you.

Tags (1)
0 Kudos
1 Reply
Dan_B_2
Beginner
40 Views

To add to this, I've tried removing the settype line - unfortunately there's no change in behavior.

Reply