Saturday, 3 January 2015

Interstitial Ad in Android application.

Banners are small ads that when touched typically take the user to some form of full-screen in-app browsing experience.
Interstitials, on the other hand are  full page ad experience at natural transition points, such as a page change, an app launch, or a game level load. Interstitials use a close button that removes the ad from the user's experience. Ads are displayed in an iFrame that floats over the web page or app.
At the end of this tutorial you will able to display an full page ad as shown in the image
                         
Full page ad/Interstitial Ad

In the previous post we have seen 

a.)how to create an account in adMob 

b.) how to generate an adUnit Id.

c.)how to create an banner ad in your android application.

If you missed the previous post click here to visit the post as this post is continuation for how get live ad's in your android application.

Now in this post we will see how to display an Interstitial ad on load of an activity in our sample android application.

Step-1:

Login to your adMob account and click on Monitize tab you will see the list of apps on the left side of the page which you have created earlier  you can select any of those application or an new app.

 
step1(a).
As show in the image click on Interstitial tab and fill the required details once you submit you will see an Ad unit ID: ca-app-pub-xxxxxxxxxxx/xxxxxxxxx created.

Step-2:

refer Step:2 and Step:3 in this link. click here

Step-3:


Now add the lines highlighted in blue color in your Manifest.xml:
-------------------------------------------------------------------------------------------------------------

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        
    //add the above two lines before <application> tag     

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        
        <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"
            android:theme="@android:style/Theme.Translucent" />
        
        <activity
            android:name="com.example.demoad.activity.DemoActivity"
            android:label="@string/app_name" 
            android:configChanges="orientation|keyboardHidden|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

AdMob tutorial


In this tutorial, you will learn how to integrate the new Google Admob with banner and interstitial ads into your Android application. The new AdMob is a streamlined user interface, to make it even easier for you to monetize and promote your apps in minutes. Maximize your earnings with the new AdMob improved tools to help app developers build their business. We will create a simple app where we will have an banner ad and Interstitial ad.So lets begin…

So at end of this post you will find some live ad shown in your layout in the following picture.

If you're a developer and you're looking for a way to make money on your own app or game while still keeping it free, you can make decent money using the AdMob system.


            
Live Banner Ad.


Step 1:

Sign up as an Admob Publisher here. Log in to your dashboard once you have your account approved.

Once you have created your account you can find your publisher id at top right of your dashboard.


                       
Now click on  Monetize tab and create an ad unit for your application. You should be able to see your ad unit after selecting an app on your left panel.                                                             
step-1(a)
                                                       
step-1(b)


                             
step-1(c)

Saturday, 18 October 2014

ExpandableListView


>extends ListView

>This differs from the ListView by allowing two levels: groups which can individually be expanded to show its children. The items come from the ExpandableListAdapter associated with this view.

>Following is an demo application: Click Here to download source code

Main Activity

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.Toast;

public class MainActivity extends Activity {

ExpandableListAdapter expandableListAdapter;
ExpandableListView expandableListView;
List<String> parentListHeader;
HashMap<String, List<String>> childListData;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
initializeDisplayElements();
prepareExpandableListData();

expandableListAdapter = new ExpandableListAdapter(this,
parentListHeader, childListData);
expandableListView.setAdapter(expandableListAdapter);

expandableListView.setOnChildClickListener(new OnChildClickListener() {

@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
Toast.makeText(
getApplicationContext(),
parentListHeader.get(groupPosition)
+ " : "
+ childListData.get(
parentListHeader.get(groupPosition))
.get(childPosition), Toast.LENGTH_SHORT)
.show();
return false;
}
});

}

/**
* This method is used to prepare the expandable list data parent and
* corresponding child items.
*/
private void prepareExpandableListData() {
parentListHeader = new ArrayList<String>();
childListData = new HashMap<String, List<String>>();

// adding parent data
parentListHeader.add("Micromax");
parentListHeader.add("Moto");
parentListHeader.add("Samsung");

// adding child data
List<String> micromax = new ArrayList<String>();
micromax.add("micromax Canvas Nitro");
micromax.add("micromax Canvas Knight");
micromax.add("micromax gold");

List<String> moto = new ArrayList<String>();
moto.add("moto-G");
moto.add("moto-E");
moto.add("moto-G2");

List<String> samsung = new ArrayList<String>();
samsung.add("samsung grand");
samsung.add("samsung Note 2");
samsung.add("samsung Galaxy");

childListData.put(parentListHeader.get(0), micromax);
childListData.put(parentListHeader.get(1), moto);
childListData.put(parentListHeader.get(2), samsung);
}

/**
* This method is used to initialize display elements present on layout
*/
private void initializeDisplayElements() {
expandableListView = (ExpandableListView) findViewById(R.id.expandableListView1);

}
}

Tuesday, 15 July 2014

Android APL Levels And Versions

What is API Level?


API Level is an integer value that uniquely identifies the framework API revision offered by a version of the Android platform.
The Android platform provides a framework API that applications can use to interact with the underlying Android system. The framework API consists of:
  • A core set of packages and classes
  • A set of XML elements and attributes for declaring a manifest file
  • A set of XML elements and attributes for declaring and accessing resources
  • A set of Intents
  • A set of permissions that applications can request, as well as permission enforcements included in the system
Platform Version
API Level
VERSION_CODE
Notes
9
8
7
6
5
4
3
2
Android 1.0
1