1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

62
1 Mobile Computing Monetizing An App right 2014 by Janson Industries

Transcript of 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Page 1: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

1

Mobile ComputingMonetizing An App

Copyright 2014 by Janson Industries

Page 2: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries2

Objectives▀ Learn about:

The various ad companies

Ad measurements

AdViews

Define an ad using XML and java

Page 3: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries3

Ad Companies▀ AdMob, Inmobi, Mopub,

Jumptap, Tapit, Smaato, Mobfox, AdSense

▀ They provide code that you add to your app

▀ Their code figures out size of ad to display based on the device

Page 4: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries4

Measurements▀ CTR – click through rate

% of people who click on an ad► If the ad is displayed 100 times and is

clicked twice, the ctr is 2% or .02

▀ CPC – cost per click

How much advertiser will pay you for each click

►47 cents for each click through

Page 5: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries5

Measurements▀ eCPM – effective cost per thousand

ad views (impressions)

How much you should make for a thousand ads being displayed

Need to multiply CPC (.47) by 1000 by CTR (.02)

► .47 * 1000 * .02 = $9.40

▀ Ad companies track all these measurements (and report them to you)

Page 6: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries6

Admob provides reports

Page 7: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries7

Notice reported stats

Page 8: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries8

Detailed stats

Page 9: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries9

My sad, unpopular app

Page 10: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries10

Measurements▀ Most of the ad companies won’t let

you post these numbers

▀ Also, if they see unusual numbers:

A CTR of 57%

Clicks are done by a small % of users or locations

►They may shut down your app

• People have their friends, relatives, and neighbors download app and click ads

Page 11: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries11

Going to use AdMob (owned by Google) http://www.google.com/ads/admob/

Page 12: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries12

Sign up using your google account

Page 13: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries13

If you are at the same computer that you created the account on they will know who you are!

If so, fill in the password

Page 14: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries14

Page 15: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries15

Specify info for an Admob account then click Continue

Page 16: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries16

Scroll down, accept Terms, click Submit

Page 17: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries17

Click Add Your First App

Page 18: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries18

Specify tax and payment info, the click Submit

Page 19: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries19

Click Sites and Apps then Android App

Page 20: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries20

Fill in app info and click Continue

Page 21: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries21

Go to https://apps.admob.com/#home click Monetize new app

Page 22: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries22

Specify Project name and Android

Page 23: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries23

Specify Ad type and give it a name

Page 24: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries24

You can change some ad formatting

Page 25: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries25

You need the add unit ID and you can have them info email to you

Page 26: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries26

Specify email address to send to

Page 27: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries27

The Ad unit ID that you will need to get ads

Page 28: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries28

Go back to Home, scroll down, and the project(s) should be displayed

Page 29: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries29

Creating From Scratch▀ Must create a new project

(AdProj) with a min target of 3.2, package (my.ad.com), activity (AdProjActivity), and layout (main) Example will be 4.X

▀ Need to: Add a reference to the Google play

services library

Modify the Manifest

Page 30: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries30

Page 31: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries31

Must import google-play-services_lib into the workspace (Should already be there from MapProj but if not…)

File, Import, expand the Android folder and select Existing Android Code Into WorkSpace, then click Next

Page 32: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries32

Click the Browse button then navigate to the sdk/extras/google/google_play_services/libproject/google-

play-services_lib, click OK then Finish

Page 33: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries33

Click Android

Right click AdProj and select Properties

Page 34: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries34

Scroll down, click Add, then select the library and click OK

•c

Page 35: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries35

Setup▀ Manifest have:

The following meta tag in the application element

The following activity defined

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>

<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

Page 36: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries36

Page 37: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries37

Setup The following permissions

outside the application tags

<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Page 38: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries38

Page 39: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries39

Defining an Ad▀ Use an AdView component

▀ Two ways to define an AdView

With xml in the layout

With java in the activity

▀ Will define an AdView component in xml

Page 40: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adUnitId="ca-app-pub-6333216089167186/1679833953" ads:adSize="BANNER"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /></LinearLayout>

40

Don’t forget to substitute your Ad Unit ID in the adUnitId parameter

main.xml

Page 41: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries41

AdProjActivity.java▀ Need to import

▀ Need an AdView variable and object in onCreate then After setContentView, create an

AdRequest and add a test device

Load ad into adView

import com.google.android.gms.ads.*;

// Look up the AdView as a resource and load a request. AdView adView = (AdView)this.findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice("abc") .build(); adView.loadAd(adRequest);

Page 42: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries42

AdProjActivity.java▀ You will get a test ad

Google doesn't want you to download real ads while testing

▀ To get a real add

// Look up the AdView as a resource and load a request. AdView adView = (AdView)this.findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder() //.addTestDevice(AdRequest.DEVICE_ID_EMULATOR) //.addTestDevice("abc") .build(); adView.loadAd(adRequest);

Page 43: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries43

AdProjActivity.java

▀ Have to run to get a real TestDevice number

▀ Find in logcat

Page 44: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries44

AdProjActivity.java

▀ Substitute for abc

// Look up the AdView as a resource and load a request. AdView adView = (AdView)this.findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder(). .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice("B3EEABB8EE11C2BE770B684D95219ECB") .build(); adView.loadAd(adRequest);

Page 45: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries45

Page 46: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries46

ads:adSize="SMART_BANNER"

Page 47: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries47

ads:adSize="MEDIUM_RECTANGLE"

Page 48: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries48

Other Types of Ad

Interstitial Ads

Full screen ads with a close button

More expensive, therefore there are often display limits

Page 49: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries49

Go back to AdMob and add an Interstatial add to the app

Page 50: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries50

Specify timeout and ad name

Page 51: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries51

Page 52: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries52

Page 53: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries53

Page 54: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries54

Interstitial Need class level variables

In onCreate, create an InterstitialAd object, set the Ad Unit ID, create the AdRequest and load the ad

private InterstitialAd interstitial;private static final String AD_UNIT_ID = "ca-app-pub-6333216089167186/1679833953";

interstitial = new InterstitialAd(this);interstitial.setAdUnitId(AD_UNIT_ID);

// Create ad request.AdRequest adRequest = new AdRequest.Builder().build();

// Begin loading the interstitialinterstitial.loadAd(adRequest);

Page 55: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries55

Interstitial Ads Can take a while to load

If you try to display before loaded will get an error

So we will put a button on the screen and show the ad after the button is touched

Page 56: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginLeft="100px"> <Button android:id="@+id/Btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="doClick"

android:text="Show Ad" /> </LinearLayout></LinearLayout>

56

main.xml

Page 57: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries57

doClick in AdProjActivity

Time to test

import android.view.View; : : :public void doClick(View arg0) {

interstitial.show();}

Page 58: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries58

Check in logcat that ad has loaded

Page 59: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries59

Click Show Ad

Page 60: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries60

AdListeners In java, Activity can implement

the AdListener interface

Then tie the ad listener to the adView

adView.setAdListener(this);

Page 61: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries61

AdListeners Activity can implement onAdxxx

methods that are called when ad is: Successfully and unsuccessfully

received onAdLoaded, onAdFailedToLoad

When ad is overlaid on the screen onAdOpened

Ad dismissed and returning to app onAdClosed

When ad clicked onAdLeftApplication

Page 62: 1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.

Copyright 2014 by Janson Industries62

AdListeners So instead of having a button to

display the ad

Create onAdLoaded method and have it display the ad

And if ad doesn't load

Create onFailedToLoad method to retry to load the ad