My Android Case-Banner

Source: Internet
Author: User

The 2015 Android Case tour

Case 11: Banner

Many advertising service providers, such as rice, gold, multi-union, wide-point pass and so on, developers can choose a better word of mouth, can bring better revenue for developers advertising channels.
This is also based on the use of embedded in the rice ads, the process to share to everyone.

    1. First we go to a Meter Admin center to create your own should and get to the release ID and app key
    2. Select the appropriate ad type according to your needs, then download the SDK with the meter

      Download the SDK to extract the following folders and files (specific files See version OK)

      The demo corresponds to the sample project, which developers can use to quickly implement the integration SDK.
      Doc Correspondence Development Documentation
      Libs the libraries required for integration
    3. The development tool adds a library with a meter ad dependency, as the method for adding external Lib is as follows:

      You can also refer to this: http://www.cnblogs.com/neozhu/p/3458759.html, which describes the illustrations will be easier to understand points.
    4. The next step is to customize your ad performance exactly as you would with the M-Ad Android SDK documentation, which uses the banner ad, which is configured as follows:
      In the Androidmanifest.xml file, you need to declare the permissions and the components that are required by the meter:
      Androidmanifest.xml
<?xml version= "1.0" encoding= "Utf-8"?><manifest xmlns:android="Http://schemas.android.com/apk/res/android"  package ="Test.fun">        <uses-permission android:name="Android.permission.INTERNET" />    <uses-permission android:name="Android.permission.READ_PHONE_STATE" / >    <uses-permission android:name="Android.permission.ACCESS_NETWORK_STATE" />    <uses-permission android:name="Android.permission.ACCESS_WIFI_STATE" />     <uses-permission android:name="Android.permission.WRITE_EXTERNAL_STORAGE" / >    <uses-permission android:name="Android.permission.GET_TASKS" />    <uses-permission android:name="Com.android.launcher.permission.INSTALL_ SHORTCUT " />    <uses-permission android:name="Android.permission.ACCESS_FINE_LOCATION" />     <applicationandroid:allowbackup="true"android:icon="@drawable/ Th_topple6 "android:label=" @string/app_name "android:theme=" @style/ Theme.AppCompat.Light.NoActionBar " >                                        <activityandroid:name="test.fun.activity.SplashActivity"Android:label ="@string/app_name" >                                    <intent-filter>                <action android:name="Android.intent.action.MAIN" />                <category android:name="Android.intent.category.LAUNCHER" />            </intent-filter>        </activity>        <activity android:name="test.fun.activity.MainActivity"></activity>        <activity android:name="test.fun.activity.GuideActivity"></activity>        <activity android:name="test.fun.activity.FunCity"></activity>        <!--the components that you must add for a meter advertisement--        <!--Add Required components--        <activityandroid:name="Net.youmi.android.AdBrowser"android:configchanges ="Keyboard|keyboardhidden|orientation|screensize"android:theme="@android: style/ Theme.Light.NoTitleBar " >                                            </activity>        <serviceandroid:name="Net.youmi.android.AdService"android:exported= "false" >                                </Service>        <receiver android:name="Net.youmi.android.AdReceiver" >            <intent-filter>                <action android:name="Android.intent.action.PACKAGE_ADDED" />                <data android:scheme="package" />            </intent-filter>        </receiver>        <!--has a meter channel number (optional configuration) channel number cannot have spaces, type is integer--        <meta-dataandroid:name= "youmi_channel"android:value="0 " >                                </meta-data>    </Application></manifest>

The components that need to be declared in the layout file that references the ad banner
Activity_main.xml:

<!--广告--><LinearLayout    android:id="@+id/fun_adLayout"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:gravity="center_horizontal"    android:orientation="horizontal"></LinearLayout>

Finally, add the Initadview method in the Mainactivity.java file to initialize the ad:
Mainactivity.java:

  Public void Initad(){//Initialize interface, invoke when application starts        //Parameters: AppId, Appsecret, debug modeAdmanager.getinstance ( This). Init ("Eff1d9d92e715abe","d6ce90949e52b39e",false);//instantiation of the ad barAdView AdView =NewAdView ( This, Adsize.fit_screen);//Get the layout to embed the ad barLinearLayout adlayout= (linearlayout) Findviewbyid (r.id.fun_adlayout);//Add an ad strip to the layoutAdlayout.addview (AdView); Adview.setadlistener (NewAdviewlistener () {@Override             Public void Onswitchedad(AdView AdView) {//Switch ads and show}@Override             Public void Onreceivedad(AdView AdView) {//Request Advertising Success}@Override             Public void Onfailedtoreceivedad(AdView AdView) {//Request AD failed}        }); }

5. The final step is to pack the apk in as to upload to a meter to pass the audit
(1) Android Studio menu Build->generate signed APK

(2) Pop-up window

(3) Create KeyStore and key, automatically select the KeyStore and key you just created after creation (already has keystore skipped)
Click on the "Create New ..." button to create the KeyStore

Key Store Path: The address of the KeyStore file
Password/confirm: Password for KeyStore
Key:
Alias: Key Name
Password/confirm: Key Password
Validity (years): Key validity time
First and last name: Key issuer Name
Organizational Unit: Key-issuing organization
City or Locality: cities
Country Code (XX): Country
(4) Select the existing KeyStore and key (skip this step after creating the KeyStore in (3))
Click the "Choose existing ..." button to locate the KeyStore file
Key Store password Enter the password for the selected KeyStore file
Click the "..." button after the key alias to select or create a key

(5) Click "Next" button, select Save Path, click "Finish" button to complete

My Android Case-Banner

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.