Ad Mob and Nexus 7 Issue

AllyAndroid

Member
Licensed User
Longtime User
I have a problem that I can't figure out.

I have an application that has two modes in it. Normal Mode and Kid Mode.

The Kid Mode is mainly for my grandkids where I remove the ads from Ad Mob. I don't want them accidently opening ads and having Google think I was doing it to increase my revenue and disable my account.

I have a menu option "Switch Mode" that allows the user to toggle between the two modes.

The menu option works fine on my Motorola Droid 4.

However, on my Nexus 7, If I go into Kid Mode first and then switch to Normal Mode, it works fine. But if I go into Normal Mode first and then switch to Kid Mode, the ad still shows on the screen.

I have tried a dozen different variations but nothing seems to make a difference. I am hoping someone could give me some direction.

I could always create another class but was hoping to keep from duplicating the code since only the ad is what gets changed.

B4X:
Sub Activity_Resume
   If KidMode = False Then
      AdView1.Initialize("Ad", "000000000000000")
      Activity.AddView(AdView1, (0 0, 320dip, 50dip) 
      AdView1.LoadAd
   End If
End Sub

B4X:
Sub HomeMenu_Click
   this_page = Sender

   If this_page = "Switch Mode" Then
      If KidMode = False Then
         KidMode = True
      Else
         KidMode = False
      End If
   End If

   Activity_Resume
End Sub

I've tried adding both AdView1.RemoveView, AdView1.Enabled = false, and AdView1.Visible = false but none of them work on the Nexus 7.
 
Last edited:

AllyAndroid

Member
Licensed User
Longtime User
You could also change the AdMob visibility, that's the easiest solution.

I tried AdView1.Visible = false and received the same results. Works fine on Droid 4 but not on the Nexus.

For now, I am going to split it up into two activities. It's only duplicating 84 lines of code so it isn't too much extra code to deal with.

But it is going to bug me until I figure out why it doesn't work right on the Nexus.

Edit: I did notice after I posted this that it is only one activity that gives me issues. The activity only contains a ListView (for selecting game options) and the AdView. The splash screen and game board correctly hides the ad when in Kid Mode.
 
Last edited:
Upvote 0

NJDude

Expert
Licensed User
Longtime User
No idea why you're having this issue, I have a Nexus 7 and what I mentioned to you works.

Look at the attached sample, it works fine on my devices including my Nexus 7.
 

Attachments

  • AdMobSample.zip
    23.8 KB · Views: 167
Last edited:
Upvote 0

AllyAndroid

Member
Licensed User
Longtime User
That works on my Nexus as well.

I have something similar to that on my Splash activity, except I am using a check box instead of buttons. It works the same as your button example.

B4X:
Sub CheckBoxMode_CheckedChange(Checked As Boolean)
   KidMode = CheckBoxMode.Checked

   If KidMode = True Then
      If AdView1.IsInitialized = True Then
         AdView1.Visible = False
      End If
   Else
      AdView1.Visible = True
   End If
End Sub

If a user selects the mode on the splash screen, everything works okay. It isn't until they get to the options screen, where they select the game they want to play that issues arise.

I'll have to see if I can get an example uploaded but it won't be tonight. Got an early start in the morning.

Thanks for the replies.
 
Upvote 0
Top