com.google.android.maps
Class MapActivity

java.lang.Object
  extended by android.content.Context
      extended by android.content.ContextWrapper
          extended by android.view.ContextThemeWrapper
              extended by android.app.Activity
                  extended by com.google.android.maps.MapActivity
All Implemented Interfaces:
android.content.ComponentCallbacks, android.content.ComponentCallbacks2, android.view.KeyEvent.Callback, android.view.LayoutInflater.Factory, android.view.LayoutInflater.Factory2, android.view.View.OnCreateContextMenuListener, android.view.Window.Callback

public abstract class MapActivity
extends android.app.Activity

Base class with code to manage the boring necessities of any activity that displays a MapView. Activity responsibilities include:

A subclass should create its own MapView in onCreate(android.os.Bundle), either with the MapView constructor (then add it to a layout View with ViewGroup.addView(View)) or leave the construction (and layout) up to inflation from the layout XML.

This is not a standard package in the Android library. In order to use it, you must add the following XML element, as a child of the application element, in your AndroidManifest.xml file:

<uses-library android:name="com.google.android.maps" />

Only one MapActivity is supported per process. Multiple MapActivities running simultaneously are likely to interfere in unexpected and undesired ways.


Field Summary
protected static int MAP_DATA_SOURCE_CHINA
          This data source uses data generally accepted by Chinese authorities, thus we recommend you use it if your product will be marketed within China.
protected static int MAP_DATA_SOURCE_DEFAULT
          The default data source.
 
Fields inherited from class android.app.Activity
DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, FOCUSED_STATE_SET, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OK
 
Fields inherited from class android.content.Context
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BACKUP_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_NOT_VISIBLE, BIND_WAIVE_PRIORITY, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, COUNTRY_DETECTOR, DEVICE_POLICY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_POLICY_SERVICE, NETWORK_STATS_SERVICE, NETWORKMANAGEMENT_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, SCHEDULING_POLICY_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, SERIAL_SERVICE, SIP_SERVICE, STATUS_BAR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, THROTTLE_SERVICE, UI_MODE_SERVICE, UPDATE_LOCK_SERVICE, USB_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
 
Fields inherited from interface android.content.ComponentCallbacks2
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
 
Constructor Summary
MapActivity()
           
 
Method Summary
protected  boolean isLocationDisplayed()
          For accounting purposes, the server needs to know whether or not you are currently displaying any kind of sensor-based estimation of the device's current location.
protected abstract  boolean isRouteDisplayed()
          For accounting purposes, the server needs to know whether or not you are currently displaying any kind of route information, such as a set of driving directions.
protected  void onCreate(android.os.Bundle icicle)
          Here we initialize static factories, create the map object and the traffic service, but do not begin any threads.
protected  void onDestroy()
          Stops all our threads and frees all our resources.
protected  int onGetMapDataSource()
          This method will be called once, during onCreate(Bundle), and its return-value will determine the map data source that the MapView will display for the lifetime of this Activity.
 void onNewIntent(android.content.Intent newIntent)
           
protected  void onPause()
          Pauses threads such as the traffic service, because we don't want it running forever in the background.
protected  void onResume()
          Here we tell the map to "predraw", which front-loads fetching and decoding, so that the first draw will appear more "atomic".
 
Methods inherited from class android.app.Activity
addContentView, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, dump, findViewById, finish, finishActivity, finishActivityFromChild, finishAffinity, finishFromChild, getActionBar, getActivityToken, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMenuInflater, getParent, getParentActivityIntent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWindow, getWindowManager, hasWindowFocus, invalidateOptionsMenu, isChangingConfigurations, isChild, isFinishing, isImmersive, isResumed, isTaskRoot, managedQuery, managedQuery, moveTaskToBack, navigateUpTo, navigateUpToFromChild, onActionModeFinished, onActionModeStarted, onActivityResult, onApplyThemeResource, onAttachedToWindow, onAttachFragment, onBackPressed, onChildTitleChanged, onConfigurationChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateNavigateUpTaskStack, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onCreateView, onDetachedFromWindow, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onLowMemory, onMenuItemSelected, onMenuOpened, onNavigateUp, onNavigateUpFromChild, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onPreparePanel, onRestart, onRestoreInstanceState, onRetainNonConfigurationInstance, onSaveInstanceState, onSearchRequested, onStart, onStop, onTitleChanged, onTouchEvent, onTrackballEvent, onTrimMemory, onUserInteraction, onUserLeaveHint, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, openContextMenu, openOptionsMenu, overridePendingTransition, recreate, registerForContextMenu, removeDialog, requestWindowFeature, runOnUiThread, setContentView, setContentView, setContentView, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setImmersive, setIntent, setPersistent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, shouldUpRecreateTask, showDialog, showDialog, startActionMode, startActivities, startActivities, startActivity, startActivity, startActivityForResult, startActivityForResult, startActivityFromChild, startActivityFromChild, startActivityFromFragment, startActivityFromFragment, startActivityIfNeeded, startActivityIfNeeded, startIntentSender, startIntentSender, startIntentSenderForResult, startIntentSenderForResult, startIntentSenderFromChild, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenu
 
Methods inherited from class android.view.ContextThemeWrapper
attachBaseContext, getTheme, getThemeResId, setTheme
 
Methods inherited from class android.content.ContextWrapper
bindService, bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getObbDir, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSharedPrefsFile, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendStickyBroadcast, sendStickyOrderedBroadcast, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiver
 
Methods inherited from class android.content.Context
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAP_DATA_SOURCE_DEFAULT

protected static final int MAP_DATA_SOURCE_DEFAULT
The default data source.

See Also:
Constant Field Values

MAP_DATA_SOURCE_CHINA

protected static final int MAP_DATA_SOURCE_CHINA
This data source uses data generally accepted by Chinese authorities, thus we recommend you use it if your product will be marketed within China.

See Also:
Constant Field Values
Constructor Detail

MapActivity

public MapActivity()
Method Detail

onCreate

protected void onCreate(android.os.Bundle icicle)
Here we initialize static factories, create the map object and the traffic service, but do not begin any threads. The subclass should create (or inflate) its MapView object after calling through to super.onCreate().

Overrides:
onCreate in class android.app.Activity

onNewIntent

public void onNewIntent(android.content.Intent newIntent)
Overrides:
onNewIntent in class android.app.Activity

onResume

protected void onResume()
Here we tell the map to "predraw", which front-loads fetching and decoding, so that the first draw will appear more "atomic". Start our threads: the traffic service and resume the MapView which will register for the updates.

Overrides:
onResume in class android.app.Activity

onPause

protected void onPause()
Pauses threads such as the traffic service, because we don't want it running forever in the background. Also saves preferences.

Overrides:
onPause in class android.app.Activity

onDestroy

protected void onDestroy()
Stops all our threads and frees all our resources.

Overrides:
onDestroy in class android.app.Activity

isRouteDisplayed

protected abstract boolean isRouteDisplayed()
For accounting purposes, the server needs to know whether or not you are currently displaying any kind of route information, such as a set of driving directions. Subclasses must implement this method to truthfully report this information, or be in violation of our terms of use. TODO: provide link

Returns:
True if route information is displayed; false otherwise.

isLocationDisplayed

protected boolean isLocationDisplayed()
For accounting purposes, the server needs to know whether or not you are currently displaying any kind of sensor-based estimation of the device's current location. By default, this method returns true if a subclass of MyLocationOverlay has been added through MapView.getOverlays() and has location enabled; however, subclasses which display the location by any other means must override this method to truthfully report this information, or be in violation of our terms of use. TODO: provide link

Returns:
True if user location information is displayed; false otherwise.

onGetMapDataSource

protected int onGetMapDataSource()
This method will be called once, during onCreate(Bundle), and its return-value will determine the map data source that the MapView will display for the lifetime of this Activity. The default value is undefined and may change from system to system. If your activity requires a specific map data source, you should override this method to return it. If an unrecognized or unsupported value is returned, the system default will be used.

See Also:
MAP_DATA_SOURCE_DEFAULT, MAP_DATA_SOURCE_CHINA