title: My class cannot be cast to android.app.Activity, how to solve this?
body: <p>In my <code>MapActivity</code> class, I set a button and that button needs to go back to a different class, can't seem to get <code>setOnClickListener</code> to work in <code>FragmentActivity</code>. Here's my code:</p>
  
  <pre><code>public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
      Button Live;
      private GoogleMap mMap;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_maps);
          SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
          mapFragment.getMapAsync(this);
          Live=  findViewById(R.id.GoToLive);   
          Live.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent startIntent = new Intent(getApplicationContext(), WorldTabBar.class);
                  startActivity(startIntent);            
              }
          });
      }
  }
  </code></pre>
  
  <p>When I click on a button inside MapActivity, the app crashes and I receive the following error in Android Monitor:</p>
  
  <pre><code> java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.marcuscarso.appstuff/com.example.marcuscarso.appstuff.WorldTabBar}: java.lang.ClassCastException: com.example.marcuscarso.appstuff.WorldTabBar cannot be cast to android.app.Activity
  </code></pre>
  
  <p>It extends <code>Fragment</code> you need to use <code>OnCreateView</code> and set a rootView. But in extends <code>FragmentActivity</code> it doesn't work. In <code>FragmentActivity</code> error when using <code>onCreateView</code> and <code>savedInstanceState</code> = "never used"</p>
  
  <p>I've seen solutions that worked for some people with <code>setOnClickListener</code> here on StackOverflow but I'm asking now because those solutions didn't work for me. So am I getting this error and what can I do to solve it?</p>