0

i want to implement Appbrain interstitial ad on my live wallpaper settings,
i followed steps given on - http://www.appbrain.com/info/sdk-docs/interstitial.html

@Override
public void onBackPressed() {
    AppBrain.getAds().maybeShowInterstitial(this);
    finish();
} 

Note: eclipse red underline on onBackPressed()

The eclipse is giving error:

The method onBackPressed() of type SBLiveWallpaper must override or implement a supertype method

One quick fix is: Remove @override annotation

What is the solution?

Update: Here is the screenshot: http://prntscr.com/558my0

Raj
  • 11
  • 2

4 Answers4

1

As eclipse itself provide you hint to catch solution of your exception

The method onBackPressed() of type SBLiveWallpaper must override or implement a supertype method

your class SBLiveWallpaper must extend an Activity class which has onBackPressed() method so you can override that method only if you extend Activity class directly or indirectly.

Like :

public SBLiveWallpaper extends Activity {

    @Override
    public void onBackPressed() {
        AppBrain.getAds().maybeShowInterstitial(this);
        finish();
    }

}
SilentKiller
  • 6,944
  • 6
  • 40
  • 75
1

Call super.onBackPressed(); do not remove @override.

@Override
public void onBackPressed() {
super.onBackPressed();
    AppBrain.getAds().maybeShowInterstitial(this);
    finish();
} 

As mentioned on the link you have provided.

Piyush
  • 1,973
  • 1
  • 19
  • 30
0

All that @Override annotation is doing is letting you know that the method is supposed to override a super class implementation of that method. If you are getting an error, that means it is not overriding anything and it is just a normal method. Check that you are implementing the correct interfaces or extending the correct super class that contains the onBackPressed method.

Nick H
  • 8,897
  • 9
  • 41
  • 64
0

Add super.onBAckPress(); in place of finish().

vs.thaakur
  • 619
  • 3
  • 13