Discussion Forums  >  Startapp Integration

Replies: 4    Views: 217

Ricardo Vio
Android Fan
Profile
Posts: 13
Reg: Jul 22, 2013
NYC
3,380
08/07/13 11:06 AM (12 years ago)

Exit Ad Integration Trouble

Would anyone have a clue what the below directions mean? Trying to figure out where/what file to add the instructions into. -------- 4. Initialize the In-App SDK A. On your activity, create a member variable private StartAppAd startAppAd = null; B. Override the onResume() method and initialize startAppAd: if (startAppAd == null) { startAppAd = new StartAppAd(this); startAppAd.load(); } NOTES: a.The parameter of StartAppAd constructor is the context (activity). b.startAppAd.load()can get an implementation of AdEventListener as a parameter. In case you want to get a callback for the ad load, pass the object which implements AdEventListener (this can be your activity) as a parameter of the method. This object should implement the following methods: @Override public void onReceiveAd(Ad ad) { } @Override public void onFailedToReceiveAd(Ad ad) { } 5. Show the ad upon exiting your application by pressing the 'back' button Override the onBackPressed() method and add a call to startAppAd.show(): @Override public void onBackPressed() { if (startAppAd != null) { startAppAd.show(); startAppAd = null; } super.onBackPressed(); } 6. Show the Ad when pressing the ‘home’ button (Optional) The Home button functionality will improve results and revenue. Override the onPause() method and add a call to startAppAd.doHome(): @Override public void onPause() { super.onPause(); if ( startAppAd != null) { boolean showAd = startAppAd.doHome(); if (showAd) { startAppAd = null; } } } NOTES: a.There are two extra permissions required to run this. b.If you would like to show ads in more than one activity, you can repeat points 4 and 6 in each activity you would like the ad to be shown in. ---- I have tried plugging in the above code into my androidmanifest.xml activity but it doesn't work. Thanks
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
08/07/13 12:16 PM (12 years ago)
Hi Ricardo Vio, If you go to the "How To" section here and look at other ones, like Scringo, then you might get an idea on how to add the code. LA
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
08/07/13 08:35 PM (12 years ago)
Which activity would you like to have the startapp integrated? If the mainscreen of your app is menu list screen then follow the following steps- 1. First create a member variable. Look for about the line number 97 or something which is above the onCreate method and add following code there. private StartAppAd startAppAd = null; 2. The next bit of code goes in the onResume method which you will find it around about line number 260 or something around. The original code is- //onResume @Override public void onResume() { super.onResume(); Now put the following code just below the code given above- if(startAppAd == null) { startAppAd = new StartAppAd(this); startAppAd.load(); } Now the code should look like below in whole- //onResume @Override public void onResume() { super.onResume(); if(startAppAd == null) { startAppAd = new StartAppAd(this); startAppAd.load(); } 3. The following line of code is important to include in your menu list plugin activity considering it is the homescreen of your app to trigger the exit ads when user clicks either back or home button. Search for onDestroy method on line number 320 or around about it. This is where the life cycle activity ends. Now put the following code just below where the onDestroy method ends. @Override public void onBackPressed() { if(startAppAd != null) { startAppAd.show(); startAppAd = null; } super.onBackPressed(); } Thats it, now you can test your app to see whether the ads show up properly as you desired.
 
Ricardo Vio
Android Fan
Profile
Posts: 13
Reg: Jul 22, 2013
NYC
3,380
like
08/08/13 11:02 AM (12 years ago)
@sandeep - "If the mainscreen of your app is menu list screen then follow the following steps- " I added the code to BT_screen_menuListSimple.java is that correct? or is it supposed to go on BT_activity_base.java. I think it should be working just waiting on google to republish new APK. Thanks, R
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
08/08/13 11:04 AM (12 years ago)
Yes it should be BT_screen_menuListSimple.java. Dont put your codes in BT_activity_base.java or BT_activity_root.java it will mess up.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.