title: Android Activity Flow - From Base Superclass to Subclass to Baseclass again
body: <p>As a N00bie to android, I'm trying to build a simple map-app. I started out doing everything in the same class, but for obvious reasons that got out of hand, fast. So I wanted to split the class, with the base class as the main flow for the activity, and the subclass as the 'utility' class. </p>
  
  <p>So I instantiate an Subclass object, and in the subclass's onCreate I start calling methods. These methods never run though. What am I doing wrong? As soon as I create the subclass object, the sub's onCreate should fire, no? And, is it even the smart way of doing this in a subclass, instead of a whole other class?</p>
  
  <p>Thanks in advance!</p>
  
  <p>Base class:</p>
  
  <pre><code>package com.example.TestMap;
  
  import android.app.Activity;
  import android.location.Location;
  import android.os.Bundle;
  import android.util.Log;
  import com.google.android.gms.maps.CameraUpdateFactory;
  import com.google.android.gms.maps.GoogleMap;
  import com.google.android.gms.maps.MapFragment;
  import com.google.android.gms.maps.model.CameraPosition;
  import com.google.android.gms.maps.model.LatLng;
  
  public class MyActivity extends Activity  {
  
      private GoogleMap mMap;
  
      @Override
      public void onCreate(Bundle savedInstanceState){
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          LocationClass locationClass = new LocationClass();
  
  
  
      }
  
      public void setMap(){
          Log.i("TestMap", "setMap");
          mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
          mMap.setMyLocationEnabled(true);
  
      }
  
  
  
      public void setCamera(Location location) {
  
          Log.i("TestMap", "setCamera");
  
          final LatLng locationLatLng = new LatLng( (location.getLatitude() ), location.getLongitude() );
  
  
          CameraPosition cameraPosition = new CameraPosition.Builder()
                  .target(locationLatLng)      // Sets the center of the map to Mountain View
                  .zoom(17)                   // Sets the zoom
                  .bearing(90)                // Sets the orientation of the camera to east
                  .tilt(30)                   // Sets the tilt of the camera to 30 degrees
                  .build();                   // Creates a CameraPosition from the builder
  
          mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
      }
  
  }
  </code></pre>
  
  <p>Subclass</p>
  
  <pre><code>package com.example.TestMap;
  
  import android.content.Context;
  import android.location.Criteria;
  import android.location.Location;
  import android.location.LocationListener;
  import android.location.LocationManager;
  import android.os.Bundle;
  import android.util.Log;
  import android.widget.Toast;
  
  import java.util.List;
  
  
  public class LocationClass extends MyActivity implements LocationListener {
  
      private LocationManager locationManager;
      private String provider;
      private List&lt;String&gt; providers;
  
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          Log.i("TestMap", "LocationClass OnCreate");
          GetProivder();
      }
  
  
      public void GetProivder (){
          Log.i("TestMap", "LocationClass GetProivder");
  
  
          locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  
          Criteria criteria = new Criteria();
          criteria.setAccuracy(2);
          provider = locationManager.getBestProvider(criteria, false);
          providers = locationManager.getProviders(true);
  
          Location location = locationManager.getLastKnownLocation(provider);
  
          Log.i("TestMap", "providerlist = " + providers);
          Log.i("TestMap", "getBestProvider = " + provider);
          Log.i("TestMap", "Location = " + location);
  
          if (location != null) {
              Log.i("TestMap", "Provider " + provider + " has been selected.");
              super.setCamera(location);
              super.setMap();
  
          } else {
              Log.i("TestMap", "location is null.");
  
          }
      }
  
  
      @Override
      public void onLocationChanged(Location location) {
          Log.i("TestMap", "onLocationChanged");
      }
  
      @Override
      protected void onResume() {
          super.onResume();
          locationManager.requestLocationUpdates(provider, 400, 1, this);
      }
  
      @Override
      protected void onPause() {
          super.onPause();
          locationManager.removeUpdates(this);
      }
  
      @Override
      public void onStatusChanged(String provider, int status, Bundle extras) {
          Log.i("TestMap", "onStatusChanged");
      }
  
      @Override
      public void onProviderEnabled(String provider) {
          Toast.makeText(this, "Enabled new provider " + provider,
                  Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onProviderDisabled(String provider) {
          Log.i("TestMap", "onProviderDisabled");
          Toast.makeText(this, "Disabled provider " + provider,
                  Toast.LENGTH_SHORT).show();
      }
  
  
  }
  </code></pre>