In Android, how do I add advertisements?

Source: Internet
Author: User

I have always wanted to know how to add advertisements to Android apps. I used my spare time to find a very useful advertisement platform in China called "universal Century" (you can click to learn more ), A small application was added to the advertisement. The advertisements of the S are divided into push ads, interactive ads, and integral wall ads. The advertising benefits are good, and an effective click can get 0.8rmb.

 

To add an advertisement, follow these steps:

The first is to download the SDK for the advertisement of the century,

Then add the jar package to your project.

Put the appoffer_1.5.3.jar package into the lib directory specified by the project.

2

Modify the androidmanifest. xml file

(1) Ensure that the application has the following permission permissions:

<Uses-Permission Android: Name = "android. Permission. Internet"/>
<Uses-Permission Android: Name = "android. Permission. access_network_state"/>
<Uses-Permission Android: Name = "android. Permission. read_phone_state"/>
<Uses-Permission Android: Name = "android. Permission. write_external_storage"/>
<Uses-Permission Android: Name = "android. Permission. get_tasks"/>
<! -- The following permissions are newly added to 1.5.3 -->
<Uses-Permission Android: Name = "android. Permission. access_wifi_state"/>
<Uses-Permission Android: Name = "com. Android. launcher. Permission. install_shortcut"/>

(2) Add the following content in the <Application> section:

<Activity Android: Name = "com. WAPs. offerswebview"
Android: configchanges = "keyboardhidden | orientation"/>
<Meta-data Android: Name = "waps_id" Android: value = "*** waps_id ***"/>
<! -- The following attributes are the distribution channel ID. You can select -->
<Meta-data Android: Name = "waps_pid" Android: value = "WAPs"/>

Waps_id is the Application ID. This value is automatically generated after the application is added to the hichina platform. Click "application details" to obtain the value;
Waps_pid is the distribution channel identifier. Fill in "WAPs" for the version uploaded to the hichina platform, and fill in the corresponding values (such as "google") for other versions for distribution, and then repackage them; different distribution packages should be marked by different channels to distinguish data from different channels on the hichina statistics platform. The value must consist of letters and numbers. It cannot be a pure number or contain spaces or Chinese characters. For the common waps_pid encoding table, see subsequent documents.

3

Add interface code

  1. Data Statistics Interface
    This interface is the basis for the normal use of all other interfaces. When an application starts, you must call the modified interface immediately to obtain accurate statistics.
    Step 1: In the application's first activity class (the first class started), add the following line of code: (required)

    Appconnect. getinstance (this );

    Step 2: Add the following line of code in the exit handling method: (required)

    Appconnect. getinstance (this). Finalize ();

     

  2. Virtual currency Interface
    A reasonable virtual currency and consumption mechanism can be set up in applications to promote users' participation in-APP purchase or advertising activities, enhance application stickiness, and greatly increase profits. If your application has enabled the virtual currency function, you must use this interface to synchronize your virtual currency balance with the server.

    (1) Obtain users' virtual currency
    Step 1: obtain user points/virtual currency balance from the server:

    Appconnect. getinstance (this). getpoints (this );

    Step 2: Ensure that the updatepointsnotifier interface is implemented in this class. The following two methods are implemented to receive responses from the server:

    Public void getupdatepoints (string currencyname, int pointtotal); // get successful
    Public void getupdatepointsfailed (string error); // retrieval failed

    (2) User Virtual currency
    Interface for spending (deduct) Users' virtual currency:

    Appconnect. getinstance (this). spendpoints (INT amount, this );

    The response result of calling this method will be returned through the updatepointsnotifier interface implemented in this

    (3) Reward users' virtual currency
    Grant (ADD) The user virtual currency interface.

    Appconnect. getinstance (this). awardpoints (INT amount, this );

    The response result of calling this method is returned through the updatepointsnotifier interface implemented in this.
    Note that all virtual currencies obtained through the universal recommendation list, interactive ads, and push ads are automatically assigned to users without calling this interface. This interface is only used to grant virtual currency to users when the user completes other tasks specified by the developer. Developers can disable this interface through the management background.

     

  3. Recommendation list Interface
    The recommendation list (also called offer, advertising wall) is a centralized display advertisement provided by the universal platform. Developers can add similar features such as "recommendation application" and "earn points for free" to an appropriate place in the application to obtain higher advertising benefits or participate in traffic exchanges.
    Add the following code to display the recommended applications on the universal platform:

    Appconnect. getinstance (this). showoffers (this );

     

  4. Interactive ad Interface
    An interactive advertisement is an advertisement with a fixed position height of 50 pixels in the application. The advertisement provided by the universal platform is automatically displayed. Combined with the virtual currency function, you can get the best advertising effect and user experience.

    Step 1: copy the following code to the layout file of the corresponding Activiy and place it in the appropriate location:

    <Linearlayout
    Android: Id = "@ + ID/adlinearlayout"
    Android: layout_width = "fill_parent"
    Android: layout_height = "wrap_content"
    Android: gravity = "center_horizontal"/>

    Step 2: Add the following code to the activity class that calls the style file:

    Linearlayout Container = (linearlayout) findviewbyid (R. Id. adlinearlayout );
    New adview (this, container). displayad (20); // rotate the advertisement every 20 seconds; the minimum is 20

     

  5. Push ad Interface
    Push advertisement is a new type of advertisement displayed in the notification bar of the Android phone. The feature is that it does not occupy the advertising space, there is a prompt sound when the ad is played, the ad click rate is very high (the average CTR exceeds 20%), there are very few false clicks, no fees for household traffic, better user experience, it is significantly higher than traditional advertising forms.
    The hichina push advertisement adopts the pure green push mode and receives the advertisement only when the application is enabled. The content and billing method of the advertisement are the same as that of the original interactive advertisement. The CPA and CPC modes coexist, users can also obtain virtual currency by pushing ads to download applications.
    The push advertisement is divided into two modes: automatic mode and manual call mode. The default mode is automatic playback mode. developers can enable and disable the automatic push advertisement at any time through the "advertisement Settings" of the wanpu management platform, set parameters such as the playback frequency and latency of the push ad. You can also manually call the API to obtain the push advertisement.

    (1) Optimize the advertisement display style
    Copy the layout/push_layout.xml file in the demo project that comes with the SDK to the layout directory of the current project and use the optimized push advertisement style to display the icon in the advertisement; use the optimized style to increase the ad click rate.
    (2) custom icons and sounds
    You can customize the notification bar icon. The res_id parameter is the resourceid value of the icon. For example, if res_id is set to R. drawable. Icon, the icon of the current application can be used as the notification bar icon.

    Appconnect. getinstance (this). setpushicon (INT res_id );

    The developer can customize whether to play a prompt for the push advertisement. The on_off parameter is set to true, and the false parameter is disabled.

    Appconnect. getinstance (this). setpushaudio (Boolean on_off );

    (3) manually obtain the push Advertisement
    Manually obtain a new push advertisement. This method immediately gets a push advertisement (no custom notification is displayed), which is not affected by frequency control settings. developers can also disable this interface at any time through the management background.

    Appconnect. getinstance (this). getpushad ();

     

  6. Other common interfaces

    (1) user feedback Interface
    The added user feedback function in the application can collect user feedback to improve the user experience. developers can view user feedback through the management background. Add the following code to collect user feedback:

    Appconnect. getinstance (this). showfeedback ();

    (2) Home Application List
    The Application List can be similar to the recommendation list to list all applications released by developers on the universal platform for users to download. This allows developers to easily recommend their own applications. Add the following code to display the list of developers' own applications:

    Appconnect. getinstance (this). showmore (this );

The following is the result of my project:

 

 

 

Click to download the instance (3D beauty wallpaper)

Click to download Xiaomei Monroe

Click Register to download the SDK

 

Related Article

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.