WutWut
WutWut

Reputation: 1234

Android- Main Activity is not a concrete class

my main activity shows the following errors -

class MainActivity must either be declared abstract or implement abstract method OnConnectionSuspended(int) in ConnectionCallbacks

due to this method -

public class MainActivity extends ActionBarActivity implements    GoogleApiClient.ConnectionCallbacks,
     GoogleApiClient.OnConnectionFailedListener,
     View.OnClickListener{

so when I add abstract to the class declaration like this

public abstract class MainActivity

I get the following error in my AndroidManifest.xml

com.myfork.myfork.MainActivity is not a concrete class

here android:name=".MainActivity"

When I try to run after adding abstract I get the message the unfortunately the app has stopped

What could be the problem?

Upvotes: 3

Views: 8169

Answers (1)

Gennadii Saprykin
Gennadii Saprykin

Reputation: 4573

When you implement an interface you should implement all its methods. In your case error says that you should implement OnConnectionSuspended(int) in your MainActivity. This is what you probably want to do..

Other option would be to make MainActivity abstract, but in this case you cannot instantiate it, i.e. you can't start it. In this case you will have to create other activity that will extend MainActivity and that activity will implement OnConnectionSuspended(int).

Upvotes: 7

Related Questions