Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android PhoneGap to open a new Activity

I have an html page loaded with PhoneGap. The html is mine and is on the phone, so I have full control of it.

I would like to click on a link on the html page to open a new activity.

For Example:

index.html

...    
<a class="FullText" href="http://LinkToOpenPage" >Click me to open an activity</a>
...

MainActivity.java

...
public void OnReceiveLink(string Link)
{
if (Link=="LinkToOpenPage")
    {
    Intent myIntent = new Intent(view.getContext(), CalledActivity.class);
    startActivity(myIntent);
    }
}
...

Can someone help me?

like image 613
Redax Avatar asked Jun 18 '11 10:06

Redax


1 Answers

Take a look at this plugin: http://smus.com/android-phonegap-plugins

This how-to is about exposing additional Android functionality to the web with PhoneGap plugins. Intents are a fundamental part of the Android ecosystem, allowing a sort of message-passing mechanism between applications, but they are not exposed to web applications. The sample Android plugin I wrote is called WebIntent, which lets you create a first class Android applications in JavaScript...

This architecture is the key to unlock any Android functionality to your PhoneGap-wrapped mobile web application...

like image 153
Jivings Avatar answered Oct 18 '22 09:10

Jivings