Phonegap + Android - Error when linking to local HTML
I have been trying to link to a local HTML file from my Phonegap app but it is not working. This is what I have in my index.html (which works perfectly)
<!DOCTYPE HTML>
<html>
<head>
<title>PhoneGap</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
function onLoad(){
document.addEventListener("deviceready", onDeviceReady, true);
}
function onDeviceReady(){
navigator.notification.alert("PhoneGap is working");
}
</script>
</head>
<body onload="onLoad();">
<h1><a href="page2.html">Page 2</a></h1>
</body>
</html>
page2.html is stored in the same assets/www folder as the index.html, it works on my desktop browser but nothing happens when I click the link on my device, except for an error which appears in the Log.
09-23 16:12:33.314: INFO/System.out(6244): startActivityForResult(intent,-1)
09-23 16:12:33.314: INFO/System.out(6244): Error loading url into DroidGap - file:///android_asset/www/page2.html:android.content.ActivityNotFoundException: Unable to find explicit activity class {ir.markdunne.hellophonegap/com.phonegap.DroidGap}; have you decl开发者_运维问答ared this activity in your AndroidManifest.xml?
If this was a standard android App the solution would be to create an activity tag for page2 in the manifest but I cannot do that here.
What is going wrong? Any help would be apprechiated
This is due to a change in Phonegap 1.0.0. I solved it by adding the following to AndroidManifest.xml. Enter it as an additional activity block. Note that you need "intent-filter" as well. I tried the suggestion without "intent-filter" and it would not work.
<activity android:name="com.phonegap.DroidGap" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
<intent-filter>
</intent-filter>
</activity>
Add this activity into your AndroidManifest.xml
<activity android:name="com.phonegap.DroidGap"
android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
</activity>
精彩评论