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 introduce how to integrate friends of social components, this article continues to bring dry, 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, or only need 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, it is natural for their own hard work to get a little extra income, because in the country unless you do iOS pay software, or under the Android platform for charging software is very difficult to obtain revenue, Users just want to use what looks good and free, embedding ads is the only way to work, just not too outrageous. Advertising service providers are very many, for example, there are meters, gold, multi-union, wide-point pass and so on, developers can choose better word-of-mouth, can bring better revenue for developers advertising channels. The author here has chosen to have Rice as an experimental point, to provide a reference to everyone, nonsense not much to say, first to see the CSDN blog client today's benefits:

There is wood to see income ah, embarrassed, very sorry about this income, the Wizard of the client's ads hidden very deep, the user is not very much, so on the temporary just have this.
In the same way, the following are the integration processes with the Rice ads:to a meter advertising account, create an app in Admin Center to get the advertisement ID and app key:

after the app has been created, download the SDK and unzip it, for example, the following directories and files:
The demo sample project corresponding to the demo will enable developers to implement the integrated SDK at high speed through these demo sample projects. doc corresponding Development documentationLibs Libraries required for appropriate integrationto say that the integration SDK does not have any technical content, just want you to follow the development documents provided by the channel, 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 one 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:
<!--the components that must be added to the rice ads-        <!--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 advertisement ID and key, and sets the test mode        admanager.getinstance (this). Init ("Your app advertisement ID", "Your App key", false);

The wizard's blog client has been integrated with ad strips and interstitial ads, such as the following:


implementation in the code:
/** * Initialize AD * * @param view */public void Initad (view view) {//Initialize interface, invoke//number of applications when launching: 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 that needs to be displayed//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 for 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 (Specific information- > Business information, no points advertising services, advanced settings)//Since 4.03 version number add Cloud control whether to turn on anti-delay function, need to the developer Background Settings page (specific information, business information, no points advertising services, advanced settings)// Load in-stream resource Spotmanager.getinstance (Getactivity ()). Loadspotads ();//Set display timeout, 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 time interval//If you need to use your own active shutdown interstitial function, please uncheck the following method Spotmanager.getinstance (Getactivity ()). Setautoclosespot (TRUE);//set itself to actively close the interstitial switch spotmanager.getinstance (getactivity ()). Setclosetime (6000); Set close interstitial time}



code to display interstitial ads:
Display in-stream ads, can not call Loadspot Independent use Spotmanager.getinstance (Getactivity ()). 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 () {//Assuming 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 () {//cancels the Register monitor spotmanager.getinstance (getactivity ()). Unregistersceenreceiver (); Super.ondestroy ();}

The above is about embedded in the process of rice advertising, how long the formal yield, need to apply the audit through the state of execution, started billing. Just to make your app attractive enough, I don't think users would mind a few more reports, and see Flappy Bird is a very good example.

The Next blog post is a preview of how to use the ListView to present the specific content of the article, thank your friends for their patience to read, your support is the wizard's unlimited 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.