Reputation:
I am making a splash screen for my app and I am following this tutorial: Android Programming Tutorial - 4 - Adding a Splash Screen. But for some reason, when I create the splash screen activity, it throws errors!
package com.haziqhussain.hazgames;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class SplashScreen {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.splash_screen, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Everything seems normal however some code is not having it.
Upvotes: 1
Views: 12762
Reputation: 3754
Need not necessarily be ActionBarActivity. Whenever your class is using the life cycle states of an Activity(OnCreate(), OnStart(), OnPause, etc.)you have to extend Activity because all of the activity classes are subclasses of android.app.Activity.
Upvotes: 1
Reputation: 585
You need to extend the ActionBarActivity
class. The ActionBarActivity
contains the methods which you are trying to override.
Upvotes: 4