Problem with getActionBar()

  • Replies:3
Ben Hutchinson
  • Forum posts: 13

Apr 13, 2016, 9:04:06 AM via Website

Running any line of code in which getActionBar() is use, causes the app to crash. And yes, I did remember to change:

public class MainActivity extends ActionBarActivity{

to:

public class MainActivity extends Activity{

And I also remembered to remove the import:

import android.support.v7.app.ActionBarActivity;

I don't know if there's something else I need to import to get getActionBar() to work correctly, but I was under the impression that the changes I already made are all I needed to do to get that function working correctly. I'm trying to avoid at all cost the use of getSupportActionBar(), because that is based on an older version of android (3.x.x) that most people don't even still have. Most people have 4.x.x or 5.x.x now. And from my understanding getActionBar has a lot more features available than getSupportActionBar does. The getSupportActionBar() function is ONLY for backward compatibility. And I'm trying to develop all my apps to be compatible for 4.0.0 at the earliest.

Reply
Ashish Tripathi
  • Forum posts: 211

Apr 14, 2016, 6:53:49 AM via Website

May be you are using v4 use v7

Reply
Ben Hutchinson
  • Forum posts: 13

Apr 20, 2016, 8:21:21 PM via Website

Version 4 or 7 of what? Android? I think they are only up to version 5 of Android now.

Reply
Vladimir S.
  • Forum posts: 266

Apr 20, 2016, 8:59:42 PM via Website

There are support library v4 and v7, it was meant. Nevertheless, Android also have version 4, 5, 6 and 7 now...

Reply