Skip to content

Instantly share code, notes, and snippets.

@omnifroodle
Created March 3, 2011 04:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save omnifroodle/852341 to your computer and use it in GitHub Desktop.
simple webview activity which takes an image url as an argument
public void onClick(View v) {
Intent i;
switch (v.getId()) {
....
case R.id.east_map_button:
i = new Intent(this, MapZoom.class);
i.putExtra(MAP_URL, "file:///android_res/drawable/east.png");
startActivity(i);
break;
case R.id.west_map_button:
i = new Intent(this, MapZoom.class);
i.putExtra(MAP_URL, "file:///android_res/drawable/west.png");
startActivity(i);
break;
case R.id.expo_map_button:
i = new Intent(this, MapZoom.class);
i.putExtra(MAP_URL, "file:///android_res/drawable/expo_floor.png");
startActivity(i);
break;
}
}
package com.usefuldevelopment.usitt2011;
import static com.usefuldevelopment.usitt2011.Constants.MAP_URL;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebView;
public class MapZoom extends Activity {
private String map;
private WebView browser;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_zoom);
browser = (WebView) findViewById(R.id.web_view);
map = (savedInstanceState == null) ? null :
(String) savedInstanceState.getSerializable(MAP_URL);
if (map == null) {
Bundle extras = getIntent().getExtras();
map = extras != null ? extras.getString(MAP_URL)
: null;
}
loadMap();
}
private void loadMap() {
Log.d("LoadMap", map);
if (map != null) {
browser.loadUrl(map);
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putSerializable(MAP_URL, map);
}
@Override
protected void onResume() {
super.onResume();
loadMap();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment