3

I have a notification app that never caught on at 99 cents. So I'm trying the free with ads model.

Problem is, Admob is slow. Its load times are as great as seven seconds after the activity displays. The activity is just a notification so the user will have closed the app before the ad had a chance to load.

I have a service that opens the activity.

Service:

    Intent notificationIntent = new Intent(this, FullScreen.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);

    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);

    NotificationManager nm = (NotificationManager) this
            .getSystemService(Context.NOTIFICATION_SERVICE);

    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    Notification notif;
    if (currentapiVersion >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
        Notification.Builder builder = new Notification.Builder(context)
                .setWhen(System.currentTimeMillis())
                .setContentIntent(contentIntent)
        notif = builder.build();
    } else {
        notif = new Notification.Builder(context)
                .setWhen(System.currentTimeMillis())
                .setContentIntent(contentIntent)
    }

Admob code in Activity's onCreate (cut n pasted from admob's documentation):

    AdView mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);

The activity is loading fast and I don't want to delay it until the AdView loads. Is there some way I can get the AdView to load during the service and then pass that to the activity? I'm guessing that there isn't. That this is by design so that people can't run up a bunch of fake ad impressions in their apps.

Tone Milazzo
  • 31
  • 1
  • 4
  • I'm not sure about Admob, but there are many other ad providers available, some of which I believe have a way to pre-load ads and may even pay better. – Reed Sep 03 '15 at 18:54
  • You also might be able to load your activity as a popup/overlay thing and make it invisible/transparent, and when the ad finishes loading, then change the styles of your activity so the notification and the ad can be seen. It might be wise in that case to tell your users that your app does that (like in the Terms and Conditions, for example). – Reed Sep 10 '15 at 19:29

3 Answers3

1

You probably don't want to hear this, but it sounds like your app is not a good fit for an ad revenue model.

You need a UI context in order to load an ad. You don't have a UI context except within a very limited temporal period.

And as you have noted loading the a takes time, which you do not have.

William
  • 20,150
  • 8
  • 49
  • 91
  • 1
    When i first wrote this app years ago, I didn't think so either. But i contacted out the idea to an iPhone developer and that's pulling in about $1000 a month. Same functionality. It's not Facebook money, but it pays my utilities. – Tone Milazzo Sep 04 '15 at 17:15
  • From ads? What ad providers are you using and how are you getting the ads loaded before your users quit? – William Sep 05 '15 at 04:15
0

AdMob (and many other ad providers) loads ad asynchronously. Method call mAdView.loadAd(adRequest) will just start asynchronous procedure of fetching the ad from server and will exit almost immediately.

The ad will be loaded later. You also have an ability to set your custom ad listener, which will be invoked once the ad is fetched and displayed (or in case of failure)

Denis Itskovich
  • 4,383
  • 3
  • 32
  • 53
  • Thanks Denis, I figured it was out of my hands. I guess all I can do is keep building my userbase and hope admob speeds up. – Tone Milazzo Sep 04 '15 at 17:12
  • Well you say it's async but I see it's laggin my main thread in method profiler. – Evren Ozturk May 16 '16 at 07:57
  • When created AdView initialize a WebView, and that happens in the main thread. This seems to be the cause of the delay. – P1x Aug 29 '16 at 15:12
0

if you have migrated to kotlin you can use GlobalScope.launch{} it helped a little for me. i don't know if it's available in java

Ayodele Kayode
  • 304
  • 4
  • 20