Android App StartApp Ads Error

I made a game and used an ads company on it (StartApp). I wanna use Interstitial Ads on it. I followed the step they show but can't achieve it. I'm getting error. Here is the LogCat:

http://i.stack.imgur.com/SaIXE.png

Here is the codes:

GameActivity.java

public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws IOException
{ 
     StartAppAd.init(this, "10254544", "20454573");
}

MenuScene.java

private StartAppAd startAppAd = new StartAppAd(activity);
@Override
public void createScene() {
      startAppAd.showAd();
      startAppAd.loadAd();
}

Answers


Check the Manifest.xml file. Be sure you wrote the right package name in there.


Try This code and u should update manifest file also

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    StartAppSearch.showSearchBox(this);
    StartAppAd.init(this, "107181003", "211487617");
    StartAppSearch.init(this, "107181003", "211487617");
    btnnext.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            startAppAd.showAd(); // show the ad
            startAppAd.loadAd();  //load next add

            Intent intent=new       Intent(getApplicationContext(),Second.class);
            startActivity(intent); 
        }
    }); 
}
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        boolean _active = true;
    }
    return true;
}


@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    startAppAd.onPause();
}

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    startAppAd.onResume();

}

@Override
protected void onRestart() {
    // TODO Auto-generated method stub
    super.onRestart();

}

@Override
protected void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();

}

private StartAppAd startAppAd = new StartAppAd(this);

@Override
public void onBackPressed() {
    startAppAd.onBackPressed();
    super.onBackPressed();
}

and update in manifest file also


You can not use the

startAppAd.showAd();
startAppAd.loadAd();

inside the Scene class (MenuScene). Instead you can try below method. In GameActivity class you must be having KeyEvent method. put the code to show the startApp ads in there as below,

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) 
{  
    if (keyCode == KeyEvent.KEYCODE_BACK)
    {


        if(SceneManager.getInstance().getCurrentSceneType().toString() == "SCENE_MENU"){
            try{
                startAppAd.showAd(); // show the ad
                startAppAd.loadAd(); // load the next ad
            }catch(Exception e){

            }
        }
            try{
                SceneManager.getInstance().getCurrentScene().onBackKeyPressed();
            }catch(Exception e){

            }

    }
    return false; 
}

Regards, Deepak


Need Your Help

launching an external program from asp.net

c# asp.net .net-4.0 launching-application

I have a question regarding launching an external application from an asp.net website. Now I think there are security measures in place to prevent that and I know it's not a good practice, but for an

Form a matrix using MySql data in C#

c# mysql

I have a Table in MySQL with thousands rows of data and 3 columns as follows: