Download Source Code
1.Structure :
2.Statique Page Web : /assets/demo.html
In this page, write the contacts you want to call, and thier phone numbers.
Follow this format :
<tr><td><!--
اسم
المتصل به --></td><td><a
href="javascript:demo.startPhone(<!-- Phone Number-->)"><!--PhoneNumber--></a></td></tr>
Example :
<!DOCTYPE
html PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta
http-equiv="Content-Type"
content="text/html;
charset=UTF-8">
<title>Insert
title here</title>
<script
type="text/javascript">
function
show(content){
document.getElementById("countent").innerHTML=
"Js
Call :"+content;
}
</script>
</head>
<body>
<table
align="center">
<tr><td>Name</td><td>Phone</td></tr>
<tr><td>Abdennour</td><td><a
href="javascript:demo.startPhone(123)">123</a></td></tr>
<tr><td>Abdesslem
Brother</td><td><a
href="javascript:demo.startPhone(456)">456</a></td></tr>
</table>
<p
id="countent">الحمد لله الذي أعاننا</p>
</body>
</html>
3.Layout : WebView In LinearLayout:
<?xml
version="1.0"
encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Call
javascript"
/>
</LinearLayout>
4.Main Activity : CallFromWebViewActivity.java
package slm.abdennour.android.webkit;
|
5.Required Permissions & Configuration :
Manifest File :
<?xml
version="1.0"
encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="slm.abdennour.android.webkit"
android:versionCode="1"
android:versionName="1.0"
>
<uses-sdk
android:minSdkVersion="8"
/>
<uses-permission
android:name="android.permission.CALL_PHONE"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
>
<activity
android:name=".CallFromWebViewActivity"
android:label="@string/app_name"
>
<intent-filter>
<action
android:name="android.intent.action.MAIN"
/>
<category
android:name="android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
</application>
</manifest>
No comments:
Post a Comment