コード例 #1
0
  @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);
  }
コード例 #2
0
  @Override
  protected void onPause() {
    super.onPause();

    mLocationViewModel.onPause();

    mLocationModel2.unregisterLocationUpdates();

    GlobalARData.removeLocationListener(mLocationListener);
    GlobalARData.removeLocationListener(mLocationView);
  }