The following will mapView I demonstrated the use of the android.
in the example project, I use the build target is the Google APIs 2.1 (on any version of the android is usually always there are two, namely the Android version of its own [* Android 2.1] and the other version I call the banality that is the complete version of his version of the Google APIs).
- google map
1. as usual, is a rare early UI design in res / layout / main.xml
2. Now we create a script to run our application folder
3. The final step is setting the permissions on AndroidManifest.xml
- Displays web pages in android
1. first we will design the UI xml his (res / layout / main.xml).
2. after we make a simple design, then we will begin to make the main script
3. Last step is setting the permissions on the Internet for applications that are located on the "AndroidManifest.xml"
Spoiler for AndroidManifest.xml:
in the example project, I use the build target is the Google APIs 2.1 (on any version of the android is usually always there are two, namely the Android version of its own [* Android 2.1] and the other version I call the banality that is the complete version of his version of the Google APIs).
- google map
1. as usual, is a rare early UI design in res / layout / main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent"
android:orientation="vertical" >
<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0fxNRcieQrs_eyjIV6eNWt48wW0hOlCbBsBx3Mw"
android:background="@android:color/transparent"
android:clickable="true"
android:enabled="true" />
</LinearLayout> 2. Now we create a script to run our application folder
package com.postedpage.LoadMap;
import com.google.android.maps.MapActivity;
import android.os.Bundle;
public class LoadMapActivity extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView)findViewById(R.id.mapView);
mapView.displayZoomControls(true);
mapView.getController().setZoom(8);
String context = Context.LOCATION_SERVICE;
LocationManager locationManager = (LocationManager) getSystemService(context);
String provider = locationManager.GPS_PROVIDER;
Location location = locationManager.getLastKnownLocation(provider);
double lat = location.getLatitude();
double lang = location.getLongitude();
mapView.getController().setCenter(
new GeoPoint((int) (lat * 1E6),
(int) (lang * 1E6)));
mapView.invalidate();
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
} 3. The final step is setting the permissions on AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.postedpage.LoadMap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".LoadMapActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-library android:name="com.google.android.maps"/>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest> - Displays web pages in android
1. first we will design the UI xml his (res / layout / main.xml).
PHP Code:
<?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" >
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mywebview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout> 2. after we make a simple design, then we will begin to make the main script
PHP Code:
package com.postedpage.WebviewExample;
import android.app.Activity; import android.os.Bundle; import android.webkit.WebView;
public class WebviewExampleActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView webView = (WebView) findViewById(R.id.mywebview); //deklarasi yg akan merujuk ke UI xml kita
webView.getSettings().setJavaScriptEnabled(true); //setting untuk meperbolehkan javascript pada webview untuk page yg akan di load
webView.loadUrl("http://www.postedpage.com"); //webview load halaman dari postedpage.com
}
} 3. Last step is setting the permissions on the Internet for applications that are located on the "AndroidManifest.xml"
Spoiler for AndroidManifest.xml:
PHP Code:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.postedpage.WebviewExample"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".WebviewExampleActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
0 comments:
Post a Comment