Android app Development-Little witch CSDN blog client embedded with M ads

Source: Internet
Author: User

Android App Development-Little witch CSDN blog client embedded with M ads
on a blog to show you how to integrate the social components of friends, this article continues to bring dry goods, teach you how to embed ads into the application. The wizard calls itself professional docking for 30 years, familiar with the access and use of the major channel SDK, unless the channel provides the SDK is very pit, it takes less than half an hour to access the SDK to the application. About advertising, developers are more concerned about the topic, why to embed ads, nature is to get some extra income for their hard work, because in the country unless the iOS pay software, or under the Android platform for charging software is very difficult to obtain revenue, users only want to use looks good and free of things , embedding ads is the only way to work, as long as it's not too outrageous. 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. The author here has chosen to have a meter as the experimental point, to provide a reference to everyone, nonsense not much to say, first to see the wizard csdn Blog client now benefits:

There is wood to see income ah, embarrassed, I am sorry for this income, the small witch This client's ads hidden deep, users are not many, so for the moment only this.
In the same way, the following are the integration processes for the Rice ads:to have an account registered on the Rice advertising website, create an app in Admin center to get the release ID and app key:

after the app is created, download the SDK and unzip it to get the following folders and files:
The demo corresponds to the sample project, which developers can use to quickly implement the integration SDK. doc Correspondence Development DocumentationLibs The libraries required for integrationTo say that the Integration SDK does not have any technical content, as long as you follow the development documents provided by the channel, you try again, basically there is no doubt.
some of the following ad types are available in rice:
    • Advertising strips, also known as banners
    • Interstitial advertising
    • Integration Wall Advertising

However, there are two forms of banner advertising, one in the form of XML, and the other in the form of code layout.

configured with the meter permission:
    <!--have meter ads configure permissions-    <!--Configure permissions--    <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.SYSTEM_ALERT_WINDOW "/>    <uses-permission android:name= "Android.permission.GET_TASKS"/>    <!--The following are optional rights--    < Uses-permission android:name= "Com.android.launcher.permission.INSTALL_SHORTCUT"/>


there are meters necessary to configure:
<!--have rice ads you must add components--        <!--Add the necessary components--        <activity            android:name= " Net.youmi.android.AdBrowser "            android:configchanges=" Keyboard|keyboardhidden|orientation|screensize            " Android:theme= "@android: Style/theme.light.notitlebar" >        </activity>        <service            android: 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>        <!--channel number (optional) channels cannot have spaces, type integers---        <meta-data            android:name= " Youmi_channel "            android:value=" 0 ">        </meta-data>


There are rice ad initialization:
Initializes the app's release ID and key, and sets the test mode        admanager.getinstance (this). Init ("Your app Release id", "Your App key", false);

The wizard's blog client-to-integration advertising and interstitial ads, the effect is as follows:


implementation in the code:
/** * Initialize AD * * @param view */public void Initad (view view) {//Initialize interface, invoke//Parameters when application starts: AppId, Appsecret, debug mode Admanager.geti Nstance (Getactivity ()). Init ("8df70b90ebf86823", "b7659d08439c052b", false);/////ad-bar interface call (for applications)/// Add the ad strip AdView to the layout control you want to show//LinearLayout adlayout = (linearlayout)//View.findviewbyid (r.id.adlayout);//AdView AdView = new AdView (getactivity (), adsize.fit_screen);//Adlayout.addview (AdView);//general layout, suitable for Applications// Get the layout to embed mini-banner relativelayout adlayout = (relativelayout) View.findviewbyid (r.id.adlayout);//demo 1 Mini banner: Wide full screen, High 32dpDiyBanner banner = new Diybanner (getactivity (), diyadsize.size_match_screenx32);//adsize with a 32DP input height to define the mini-banner/ /Demo 2 Mini banner: Width 320dp, high 32dp//diybanner banner = new Diybanner (this,//diyadsize.size_320x32);//Adsize of incoming height of 32DP to define the fan You banner//the integration banner into the layout Adlayout.addview (banner);//monitor the Ad Bar interface//Adview.setadlistener (new Adviewlistener () {////@ override//public void Onswitchedad (AdView arg0) {//LOG.I ("Youmiaddemo", "banner Toggle");//}////@Override//public void Onreceivedad (AdView arg0) {//LOG.I ("Youmiaddemo", "Request advertisement Success");//}////@Override//public void onfailedtorecei Vedad (AdView arg0) {//LOG.I ("Youmiaddemo", "Request advertisement failed");//}//});//plug-in Interface call//developer can set the display frequency to the developer background, need to go to the Developer Background Settings page (details, Business information, no points advertising services, advanced settings)//Since the 4.03 version to increase the cloud control whether to open the anti-delay function, need to the developer Background Settings page (details, business information, no points advertising services, advanced settings)// Load the interstitial resource spotmanager.getinstance (Getactivity ()). Loadspotads ();//Set the display time-out time, load timeout does not show ads, default 0, The delegate does not set the timeout time Spotmanager.getinstance (Getactivity ()). Setspottimeout (5000);//Set 5 seconds spotmanager.getinstance (getactivity ()). Setshowinterval (20);//Set the 20-second display interval//If you need to use the auto-off interstitial function, uncomment the following method Spotmanager.getinstance (Getactivity ()). Setautoclosespot (TRUE);//Set auto-off interstitial switch spotmanager.getinstance (getactivity ()). Setclosetime (6000); Set close interstitial time}



code to display interstitial ads:
To display in-stream ads, you can use Spotmanager.getinstance (getactivity ()) independently without calling Loadspot. Showspotads (Getactivity (), New Spotdialoglistener () {@Overridepublic void onshowsuccess () {log.i ("Youmiaddemo", "show Success");} @Overridepublic void onshowfailed () {log.i ("Youmiaddemo", "Show Failed");});




handling of interstitial ads in the declaration cycle:
@Overridepublic void OnStop () {//If this method is not called, the icon cannot be displayed when the home key is pressed. Spotmanager.getinstance (Getactivity ()). DisMiss (false); Super.onstop ();} @Overridepublic void OnDestroy () {//unregister monitor spotmanager.getinstance (Getactivity ()). Unregistersceenreceiver (); Super.ondestroy ();}

The above is about the process of embedding a meter advertising, such as Elder Hammond formally generate revenue, need to apply the audit through the running state, began billing. As long as your application is attractive enough, I think the user would not mind a few more reports, see Flappy Bird is a good example.

The Next blog post is a preview of how to use the ListView to present the details of the article, thank your friends for their patience to read, your support is the wizard's infinite power.





Android app Development-Little witch CSDN blog client embedded with M ads

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.