Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 23    Views: 213

miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
07/12/16 05:26 AM (8 years ago)

Revmob in Android Studio

Can anybody tell how to implement Revmob ad in Android Studio?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
07/14/16 06:35 AM (8 years ago)
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
07/14/16 06:54 AM (8 years ago)
Thanks Smug, it is really old, for BT 2.0 only, for full screen, not banner. It would be very useful if someone tell how to do it for Android Studio.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
07/14/16 07:28 AM (8 years ago)
I've done Admob, but not revmob. Dusko does just about everything. Have you checked his website? He has a lot of Android pearls there. I think it's duskosavic.com Otherwise, good luck. If I run across anything, I'll let you know. Cheers! -- Smug
 
Dusko
Veteran developer
Profile
Posts: 998
Reg: Oct 13, 2012
Beograd
22,680
like
07/14/16 08:20 AM (8 years ago)
@smug Thanks for mentioning me and for reminding me of RevMob ads. I did implement revmob ads last year but ended up using StartApp ads instead. I still use StartApp to this day in one "good" app. To implement revmob in an Android app is not easy for us using Buzztouch framework. We must use frames and the documentation generally is for activities. There are substantial problems to bridge from what you read on the Internet to what needs to be coded in a BT app. Having said that, be sure to put the basic statements into the BT_activity_base.java class ... // revMob import com.revmob.RevMob; ... //revMob private static String APPLICATION_ID = "xxxxxxxxxxxxxxxxxxxxxxxx"; private RevMob revmob; and then into the onCreate method, something like this: // Starting RevMob session revmob = RevMob.start(this, APPLICATION_ID); revmob.showFullscreen(this); You will probably need to implement some other revmob code in the plugins you want to show their ads in. That is beyond the scope of a forum answer but feel free to contact me here through private messages if you cannot install it on your own.
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
11/15/16 02:55 AM (8 years ago)
I found revmob banner ad integration very easy add the following code to BT_activity_host.java import com.revmob.RevMob; import com.revmob.RevMobAdsListener; import com.revmob.ads.link.RevMobLink; import android.util.Log; import android.view.ViewGroup; import android.widget.LinearLayout; import com.revmob.ads.banner.RevMobBanner; private RevMob revmob; RevMobBanner banner; LinearLayout layout; under //onCreate @Override public void onCreate(Bundle savedInstanceState) { find this line ---> setContentView(R.layout.bt_activity_host); and under it add startRevMobSession(); then after //configure the app's environment... configureEnvironment(); } put the following public void startRevMobSession() { //RevMob's Start Session method: revmob = RevMob.startWithListener(this, new RevMobAdsListener() { @Override public void onRevMobSessionStarted() { loadBanner(); // Cache the banner once the session is started Log.i("RevMob","Session Started"); } @Override public void onRevMobSessionNotStarted(String message) { //If the session Fails to start, no ads can be displayed. Log.i("RevMob","Session Failed to Start"); } }, "<YOUR_ID_HERE>"); } public void loadBanner(){ banner = revmob.preLoadBanner(this, new RevMobAdsListener(){ @Override public void onRevMobAdReceived() { showBanner(); Log.i("RevMob","Banner Ready to be Displayed"); //At this point, the banner is ready to be displayed. } @Override public void onRevMobAdNotReceived(String message) { Log.i("RevMob","Banner Not Failed to Load"); } @Override public void onRevMobAdDisplayed() { Log.i("RevMob","Banner Displayed"); } }); } public void showBanner(){ runOnUiThread(new Runnable() { @Override public void run() { ViewGroup view = (ViewGroup) findViewById(R.id.bannerLayout); view.addView(banner); banner.show(); //This method must be called in order to display the ad. } }); } then your BT_activity_host.xml should look like the following <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/containerView" android:background="@android:color/white" android:padding="0dip" android:layout_margin="0dip" android:layout_width="fill_parent" android:layout_height="fill_parent" > <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/backgroundSolidColorView" android:background="@android:color/transparent" android:padding="0dip" android:layout_margin="0dip" android:layout_width="fill_parent" android:layout_height="fill_parent"> </RelativeLayout> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/backgroundImageBox" android:background="@android:color/transparent" android:padding="0dip" android:layout_margin="0dip" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/backgroundImageView" android:layout_width="fill_parent" android:layout_height="fill_parent"> </ImageView> </RelativeLayout> <!-- Full screen linear layout, fragments (plugins) run in this "box" --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/fragmentBox" android:orientation="vertical" android:background="@android:color/transparent" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/bannerLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal" android:orientation="vertical"> </LinearLayout> </LinearLayout> </FrameLayout> using this code successfully added rev mob banner ad to top of every plugin. Hope this helps! Kristan Halls Immaculate Apps
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
11/15/16 11:36 PM (8 years ago)
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
11/17/16 04:08 AM (8 years ago)
It works, banner shows only on first time starting app, on device and emulator. I tried 3 different apps. When you close app and then load it again, no ad is present. How about interstitial Revmob ads?
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
11/18/16 03:01 AM (8 years ago)
Ok so I worked out something to do with the banner being destroyed and when the app is resumed the banner isn't being re-displayed. I managed to fix this add the following public boolean sessionStarted = false; public boolean sBanner = false; update the following public void startRevMobSession() { //RevMob's Start Session method: revmob = RevMob.startWithListener(this, new RevMobAdsListener() { @Override public void onRevMobSessionStarted() { loadBanner(); // Cache the banner once the session is started Log.i("RevMob", "Session Started"); } @Override public void onRevMobSessionNotStarted(String message) { //If the session Fails to start, no ads can be displayed. Log.i("RevMob","Session Failed to Start"); } }, "<YOUR_ID>"); } public void loadBanner(){ banner = revmob.preLoadBanner(this, new RevMobAdsListener(){ @Override public void onRevMobAdReceived() { if (!sBanner) { showBanner(); sBanner = true; } Log.i("RevMob","Banner Ready to be Displayed"); //At this point, the banner is ready to be displayed. } @Override public void onRevMobAdNotReceived(String message) { Log.i("RevMob","Banner Not Failed to Load"); } @Override public void onRevMobAdDisplayed() { Log.i("RevMob","Banner Displayed"); } @Override public void onRevMobAdDismissed() { Log.i("RevMob", "Fullscreen dismissed."); sessionStarted = false; } }); } public void showBanner(){ runOnUiThread(new Runnable() { @Override public void run() { ViewGroup view = (ViewGroup) findViewById(R.id.bannerLayout); view.addView(banner); banner.show(); //This method must be called in order to display the ad. } }); } then find ---> public void onResume() { and under the following -- > super.onResume(); add if(!sessionStarted) { loadBanner(); } then find ---> public void onDestroy() { and under ---> super.onDestroy(); add ---> sessionStarted = false; Now it checks to see if session is started and if banner isn't loaded to loadBanner. Hope this makes sense and works for you. I will get back to you about the interstitial. Thank You Kristan Halls
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
11/18/16 03:03 AM (8 years ago)
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
11/18/16 04:17 AM (8 years ago)
It works fine now, THANKS. Interstital would be very welcome, also. I would really want to know option to integrate interstitial only to CustomHTML plugin, not to whole app. Why? I have plenty of menus on home screen (menu with image plugin). If interstital shows every time it would be disruptive, so best way would be to interstital shows only in CustomHTML.
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
11/18/16 04:59 PM (8 years ago)
Im glad it worked for you! Took me bout an hour but think I've got interstitial working correctly only on customHTML plugin. Still add the loadfullscreen() and showfullscreen() in BT_activity_host. Then in BT_activity_host where it loads the fragment for the plugin you just need to check that its a customHTML plugin then request loadfullscreen() if (theScreenData.getItemType().equals("BT_screen_customHTML")) { loadFullscreen(); } Its hard to explain exactly where and what to do so i will just give you the whole code again. You also need to add <activity android:name="com.revmob.FullscreenActivity" android:theme="@android:style/Theme.Translucent" android:configChanges="keyboardHidden|orientation"> </activity> to you Androidmanifest before the bottom </application> full code here ---> http://pheds.com.au/sca/BT_activity_host.java I am only a beginner app maker with no previous java experience, the hardest part to editing buzz touch code is just understanding how the app is built and run. Adding code in the correct position is very important. I hope this helps get your apps closer to release! :) Thank you Kristan Halls
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
11/18/16 05:30 PM (8 years ago)
If you wanted it to work for selected screens change if (theScreenData.getItemType().equals("BT_screen_customHTML")) { loadFullscreen(); } to if (theScreenData.getItemId().equals("<screen_id1_here>")) { loadFullscreen(); } else if (theScreenData.getItemId().equals("<screen_id2_here>")) { loadFullscreen(); } else if (theScreenData.getItemId().equals("<screen_id3_here>")) { loadFullscreen(); } and so on.
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
11/19/16 03:42 AM (8 years ago)
I followed your help and got errors in Activity_host: Error:(150, 3) error: cannot find symbol variable fullscreen Error:(154, 5) error: cannot find symbol variable fullscreenIsLoaded Error:(176, 6) error: cannot find symbol variable fullscreenIsLoaded Error:(177, 4) error: cannot find symbol variable fullscreen I also added: import com.revmob.ads.interstitial.RevMobFullscreen;
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
11/19/16 12:30 PM (8 years ago)
you have not added the variables at top, if you followed/read the file a linked to you would see you need to declare the variables and also import revmobfullscreen. public RevMobFullscreen fullscreen; public boolean fullscreenIsLoaded; its all there in the file import com.revmob.RevMob; import com.revmob.RevMobAdsListener; import com.revmob.ads.link.RevMobLink; import android.util.Log; import android.view.ViewGroup; import android.widget.LinearLayout; import com.revmob.ads.banner.RevMobBanner; import com.revmob.ads.interstitial.RevMobFullscreen; public RevMobFullscreen fullscreen; public boolean fullscreenIsLoaded; private RevMob revmob; RevMobBanner banner; LinearLayout layout;
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
11/20/16 01:12 AM (8 years ago)
It works now perfect. Thank you very much.
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
11/20/16 01:22 AM (8 years ago)
Im glad its all working. Your welcome
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
11/24/16 09:39 AM (8 years ago)
Kristan, maybe you have any experience with Revmob in iOS. I use this procedure: - Framework SDK - appdelegate: #import <RevMobAds/RevMobAds.h> //didFinishLaunchingWithOptions... -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ [BT_debugger showIt:self message:[NSString stringWithFormat:@"didFinishLaunchingWithOptions%@", @""]]; ———————————————————— [RevMobAds startSessionWithAppID:@"MyID"]; [[RevMobAds session] showBanner]; [[RevMobAds session] showFullscreen]; ————————————— //when app becomes active again - (void)applicationDidBecomeActive:(UIApplication *)application{ [BT_debugger showIt:self message:[NSString stringWithFormat:@"applicationDidBecomeActive%@", @""]]; ————————————————— [[RevMobAds session] showBanner]; [[RevMobAds session] showFullscreen]; ——————————————————————— It works, but problem is that every time that app loads from scratch, ads aren't present. If I go out of app and then return back, ads are loaded. Any solution? Here is little video of problem: https://www.dropbox.com/s/eyt8ymk5wn3hjxo/Revmob_test.mp4?dl=0 Thanks Milan
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
11/24/16 11:29 PM (8 years ago)
Ive never actually used revmob before. I only tried implementing it to answer your question. Sort of like a challenge to myself. Like i said I'm only really learning as well but I am getting very confident editing buzztouch apps. I will download my current project for Xcode and try to implement Revmob for you. So I know what you require from the start - banner on all screens, and fullscreen on all screens or just customHTML ? get back to you soon hopefully
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
11/24/16 11:33 PM (8 years ago)
Banner and full screen on all screens.
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
11/25/16 12:18 AM (8 years ago)
And what is your other code to show the ads? [[RevMobAds session] showBanner]; [[RevMobAds session] showFullscreen]; ? Are you using test ads for your testing? You should never view your own revmob ads or you might get banned.
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
11/25/16 01:09 AM (8 years ago)
Ok pretty straight forward with this one. Try this let me know how it works. BT_viewcontroller.m & BT_viewcontroller.h under BT_layout are the files that you want to put your code in as this is where your fragment plugins are displayed. so in both BT_viewcontroller.m & BT_viewcontroller.h i have put #import <RevMobAds/RevMobAds.h> #import <RevMobAds/RevMobAdsDelegate.h> then in BT_viewcontroller.h your @interface should look like the following @interface BT_viewController : UIViewController <UIAlertViewDelegate, RevMobAdsDelegate, ADBannerViewDelegate, MFMailComposeViewControllerDelegate, NSFileManagerDelegate, MFMessageComposeViewControllerDelegate>{ } in the same file add the following properties @property (nonatomic, strong) RevMobBannerView *bannerView; @property (nonatomic, strong)RevMobFullscreen *fullscreen; in BT_viewcontroller.m under /viewDidLoad... -(void)viewDidLoad{ [BT_debugger showIt:self theMessage:@"viewDidLoad (super)"]; [super viewDidLoad]; put [RevMobAds startSessionWithAppID:@"<YOUR_ID>" withSuccessHandler:^{ [[RevMobAds session] showFullscreen]; [self showBanner]; [RevMobAds session].userAgeRangeMin = 10; } andFailHandler:^(NSError *error) { //For now we don't need this }]; then before //viewWillAppear... put - (void)showBanner { RevMobBannerView *banner = [[RevMobAds session] bannerView]; banner = [[RevMobAds session] bannerView]; [banner loadWithSuccessHandler:^(RevMobBannerView *bannerV) { [banner showAd]; } andLoadFailHandler:^(RevMobBannerView *banner, NSError *error) { // Ad failed [BT_debugger showIt:self theMessage:@"AD FAILED"]; } onClickHandler:^(RevMobBannerView *banner) { // Ad clicked }]; } - (void)loadFullscreen { _fullscreen = [[RevMobAds session] fullscreen]; _fullscreen.delegate = self; [_fullscreen loadAd]; } - (void)showLoadedFullscreen{ if (_fullscreen) [_fullscreen showAd]; } -(void) revmobUserDidClickOnFullscreen:(NSString *)placementId{ NSLog(@"[RevMob Sample App] User clicked in the Fullscreen."); } -(void) revmobFullscreenDidReceive:(NSString *)placementId{ NSLog(@"[RevMob Sample App] Fullscreen loaded."); [self showLoadedFullscreen]; } -(void) revmobFullscreenDidFailWithError:(NSError *)error onPlacement:(NSString *)placementId{ NSLog(@"[RevMob Sample App] Fullscreen failed: %@. ID: %@", error, placementId); } -(void) revmobFullscreenDidDisplay:(NSString *)placementId{ NSLog(@"[RevMob Sample App] Fullscreen displayed."); } -(void) revmobUserDidCloseFullscreen:(NSString *)placementId{ NSLog(@"[RevMob Sample App] User closed the fullscreen."); } Loads banner and fullscreen to plugins. Hope this helps Kristan Halls Immaculate Apps P.S - Feel free to check out the first game I have made after learning to create apps android - https://play.google.com/store/apps/details?id=com.crossycolours iOs - https://itunes.apple.com/au/app/crossy-colours/id1099564306?mt=8
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
11/25/16 01:52 PM (8 years ago)
When I close fullscreen ad, it closes banner too: look video: <a href="https://www.dropbox.com/s/fxacuiulyq91dw8/revmob_test2.mp4" target="_blank" rel="nofollow">https://www.dropbox.com/s/fxacuiulyq91dw8/revmob_test2.mp4</a>
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
11/26/16 04:48 PM (8 years ago)
Ok it seems as though the banner is loading and displaying but then it gets hidden once the plugin is fully visible. This code should fix that problem. in BT_viewcontroller.m under /viewDidLoad... -(void)viewDidLoad{ [BT_debugger showIt:self theMessage:@"viewDidLoad (super)"]; [super viewDidLoad]; put [RevMobAds startSessionWithAppID:@"<YOUR_ID>" withSuccessHandler:^{ [[RevMobAds session] showFullscreen]; [RevMobAds session].userAgeRangeMin = 10; } andFailHandler:^(NSError *error) { //For now we don't need this }]; [RevMobAds session].testingMode = RevMobAdsTestingModeWithAds; then scroll down to //show view... [self fadeInOnEntry]; and put [[RevMobAds session] showBanner]; Now it should hopefully only show the banner after page has fully appeared.
 

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.