How to make money from Android App Tutorial
Building Android Apps is fun, morethan that it is highly useful for earning something from it.
Through google adsense linked admob world wide ads website, we can monetize our apps & earn some bucks from it.
How it works ?
As the user install your app from google play or any other famous methods, you are not going to get paid.But when the user open your app and click on the ads appeared on it, the ads redirect to websites or their apps on google play with your id registered with admob, and so you get paid for it. Remember that you won't get 1$ for a single click, rather it depends on from where the user click and what type of ad it was.
NOTE: Don't try yourself to click on the ads to earn, it may take out your Adsense account for the lifetime.
Easy Method
Download the full source code below
How to do ?
Well, here's the complete setup in tutorials with exact vocal explanation.
Part 1 (setting ads on admob website)
Part 2 (Adding the ad to android app in Android Studio)
Here is a screenshot of banner ad
How to ?
Let's start by adding google play service dependency in gradle and sync it.
build.gradle
dependencies {
compile 'com.google.android.gms:play-services:9.6.1'
}
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services:9.6.1'
}
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services:9.6.1'
}
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services:9.6.1'
}
Add google banner in activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.sabithpkcmnr.sampleadsapp.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<com.google.android.gms.ads.AdView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_id"
android:id="@+id/adView" />
</RelativeLayout>
we have added the google banner ad at the button of windowMainActivity
com.sabithpkcmnr.admobsample;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
public class MainActivity extends AppCompatActivity {
private AdView mAdView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.build();
mAdView.loadAd(adRequest);
}
}
Strings
<string name="banner_id">ca-app-pub-9985211134479428/9045934992</string>
In the strings I have my banner ad id like this ca-app-pub-9985211134479428/9045934992you can find your own from admob website after creating a ad (see the first part video on above)
finally add the app Permission to use internet in Android Manifiest
AndroidManifiest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sabithpkcmnr.admobsample">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
That's it.
Finally we have ads on our app. Now share it maximum to the world and earn for each click.
Thanks for your time
No comments: