I want to make a button that links to websites like google.com. I used jquery mobile + eclipse and tried with this Google, it works fine in android virtual device, but when i transferred the app (apk file) to my phone, it doesn't work that way. It just shows me the link with no button like I wanted. Why is that so? What code should I add on the java or xml or androidfest.xml files? PLEASE HELP!!
In addition, I transferred my final apk file through bluetooth instead of using cables. could that be the problem? :/
my MainActivity.java code:
package com.example.testing;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
WebView webView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("file:///android_asset/index.html");
return;
}
}
my activity_main.xml:
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none" />
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testing"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Note: My heading and footer also did not show as it was supposed to in my real phone. I need help on that too: header, footer, and button functions.
The html file:
<!DOCTYPE html>
<html>
<head>
<title>Home Page</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css" />
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/event.css" />
</head>
<body>
<div data-role="page" data-theme="c" id="home">
<div data-role="header">
<h1>Hello</h1>
</div>
<div data-role="content">
<p>
<a href="https://www.google.com.sg/" rel="external" data-role="button">Google</a>
<a href="http://www.channelnewsasia.com/" rel="external" data-role="button">CNA</a>
</p>
</div>
<div data-role="footer">
<h4>Bye</h4>
</div>
</div>
</body>
</html>