Here is my code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
//android.support.v7.app.ActionBar actionBar = getSupportActionBar();
If you are extending AppCompatActivity then you are providing backward support for older Android versions and for that you have to use getSupportActionBar().
If you are importing android.app.ActionBar then you have to use getActionBar() and if you are importing android.support.v7.app.ActionBar then you have to use getSupportActionBar().
Note: By using android.support.v7.app.ActionBar, you can provide backward support for older Android versions.