Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Friday, May 27, 2011

Android WebView Orientation Changes

We know, Android destroys the current activity and re-creates the same activity all over again.So for the webview it has to reload the page during orientation changes.

This can be resolved by overriding onSaveInstanceState(Bundle outState) in your activity and calling saveState from the Webview:

@Override


protected void onSaveInstanceState(Bundle outState) {


webView.saveState(outState);


}


Then rewrite your onCreate :

public void onCreate(final Bundle savedInstanceState) {


super.onCreate(savedInstanceState);


setContentView(R.layout.blah);


if (savedInstanceState != null)


((WebView)findViewById(R.id.webview)).restoreState(savedInstanceState);


else
webview.loadUrl("yourUrl");


}


And set the android:configChanges attribute in the manifest:

android:label="@string/appName"
android:configChanges="keyboardHidden|orientation"

Thursday, April 28, 2011

How to create a new Virtual SD card in ANDROID Emulator


Change directory to the sdk tools directory say

cd ~/android-sdk-windows/tools/


1) List the avd target

 android list targets


and you will see

id: 1 or "android-8"
     Name: Android 2.2
     Type: Platform
     API level: 8
     Revision: 2
     Skins: HVGA (default), QVGA, WQVGA400, WQVGA432, WVGA800, WVGA854

2) create avd witth andorid 2.2 and sdcard 500M

android create avd -n android-8 -t 1 -c 500M


3) List avds

android list avds


4) Start emulator

emulator -avd android-8 &