@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.test_cur_location); mLocationViewModel = new GoogleCurrentLocation(this); mLocationViewModel.onCreate(savedInstanceState); FrameLayout frameLayout = (FrameLayout) findViewById(R.id.main_frame); frameLayout.addView(mLocationViewModel.getView(), 0); // the second Location View Model doesn't have UI, and use multiple // source providers mLocationModel2 = new GoogleLocationModel(this); mTextView = (TextView) findViewById(R.id.textView); GlobalARData.addLocationListener(mLocationListener); // use a LocationView to show the LocationModel data mLocationView = new LocationView(this); mLocationView.onCreate(savedInstanceState); FrameLayout frameLayout2 = (FrameLayout) findViewById(R.id.frame2); frameLayout2.addView(mLocationView.getView()); GlobalARData.addLocationListener(mLocationView); }
@Override protected void onResume() { super.onResume(); mLocationViewModel.onResume(null); mLocationModel2.registerLocationUpdates(); }
@Override protected void onPause() { super.onPause(); mLocationViewModel.onPause(); mLocationModel2.unregisterLocationUpdates(); GlobalARData.removeLocationListener(mLocationListener); GlobalARData.removeLocationListener(mLocationView); }
@Override protected void onDestroy() { super.onDestroy(); mLocationViewModel.onDestroy(); }
@Override protected void onStop() { super.onStop(); mLocationViewModel.onStop(); }