Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android- Main Activity is not a concrete class

Tags:

java

android

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?

like image 425
WutWut Avatar asked Dec 06 '25 17:12

WutWut


1 Answers

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).

like image 162
Gennadii Saprykin Avatar answered Dec 08 '25 07:12

Gennadii Saprykin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!