Android app add advertisement tutorial

Source: Internet
Author: User

Android app add advertisement tutorial
To obtain the Android Advertisement Management Library and display advertisements in mobile apps, you must add an advertisement management library in the app, the current version of the Keymob ad management library is 20150801. After downloading and decompressing the library, you can see the directory structure of the android project. Most of the general android project files and directories are related to the Keymob management library. Download the ad management library README. md keymob quick English integration documentation README_zh.md keymob quick Chinese integration documentation libskeymobad. jar keymob core library assetscom_keymob_sdks keymob backup platform biduad_plugin keymob resources required by Baidu platform gdt_plugin keymob resources note: the three folders under the assets Directory and the files under the folder cannot be modified. The com_keymob_sdks directory contains an AdmobAdapter. jar indicates that Keymob uses admob as the standby ad platform when Keymob cannot be connected. If you want to use another platform, you can download more backup platforms. In addition to the resources downloaded above, use the platform officially supported by keymob, you do not need to add the code of each platform to add the Management Library to the eclipse project. To use the Advertisement Management Library, follow these steps to copy the downloaded keymobad. jar to the libs of your android project and copy the downloaded com_keymob_sdks to the assets of your android project. If you want to use the Baidu advertising platform, copy the downloaded biduad_plugin to the assets of your android project. If you want to use the broad-point platform, copy the downloaded gdt_plugin to the assets of your android project and add the java code related to the advertisement. 1. first, import the keymob-related class import com. keymob. ads. adManager; import com. keymob. core. *; import com. keymob. sdk. core. adTypes; 2. initialize Keymob to initialize Ke The ymob Management Library is the prerequisite for calling other ad functions. You must initialize the library before calling other functions. The following describes how to use the Keymob.com service initialization method AdManager. getInstance (). initFromKeymobService (this, "1", new AdEventListener (), false); the parameter indicates that the first parameter of this is the advertising context, and the second parameter of non-null "1" is the Keymob Application ID, the IDAdEventListener advertisement event processing class obtained after the application is registered and created at Keymob.com. The IAdEventListener interface is implemented. If you do not plan to process the advertisement event, you can set nullfalse to the test mode, and set it to true during development and debugging, set false when publishing. 3. the following is an example of AdManager showing the absolute position of a banner ad (0,200. getInstance (). showBannerABS (BannerSizes. BANNER, 0,200); parameter description BannerSizes. BANNER's first parameter advertisement size, all the default supported ad banners are in the BannerSizes class. The second parameter is the ad position x "200" and the second parameter is the ad position y4. add ad permission to edit AndroidManifest. xml to add the required permissions to the application, such as network requests. Below are the permissions required by most advertising platforms

<! -- Base permission --> <uses-permission android: name = "android. permission. INTERNET "/> <uses-permission android: name =" android. permission. ACCESS_NETWORK_STATE "/> <uses-permission android: name =" android. permission. ACCESS_WIFI_STATE "/> <uses-permission android: name =" android. permission. READ_PHONE_STATE "/> <! -- Base permission for location --> <uses-permission android: name = "android. permission. ACCESS_COARSE_LOCATION "/> <uses-permission android: name =" android. permission. ACCESS_FINE_LOCATION "/> <! -- Base permission required by chartboost and baidu --> <uses-permission android: name = "android. permission. WRITE_EXTERNAL_STORAGE"/> <! -- Permission required by mmedia --> <uses-permission android: name = "android. permission. RECORD_AUDIO "/> <uses-feature android: name =" android. hardware. microphone "android: required =" false "/> 5. add ad Activity and other configuration information to edit AndroidManifest. if you add an advertisement platform Activity to an application in xml format, the activity that does not add the platform cannot display the platform advertisement <meta-data android: name = "com. google. android. gms. version "android: value =" 7327000 "type =" codeph "text ="/codeph "/> <activity android: name =" com. google. android. gms. a Ds. adActivity "android: configChanges =" keyboard | keyboardHidden | orientation | screenLayout | uiMode | screenSize | smallestScreenSize "android: theme =" @ android: style/Theme. translucent "/> <! -- Amazon Mobile Ads --> <activity android: name = "com. amazon. device. ads. AdActivity" android: configChanges = "keyboardHidden | orientation | screenSize"/> <! -- InMobi --> <activity android: name = "com. inmobi. android SDK. IMBrowserActivity "android: configChanges =" keyboardHidden | orientation | keyboard | smallestScreenSize | screenSize "android: theme =" @ android: style/Theme. translucent. noTitleBar "android: hardwareAccelerated =" true "/> <! -- Millenrix Media --> <activity android: name = "com. millennialmedia. android. MMActivity "android: theme =" @ android: style/Theme. translucent. noTitleBar "android: configChanges =" keyboardHidden | orientation | keyboard | screenSize "> </activity> <! -- Keymob --> <activity android: name = "com. keymob. sdk. core. keymobActivity "android: theme =" @ android: style/Theme. dialog "android: configChanges =" keyboard | keyboardHidden | orientation | screenLayout | uiMode | screenSize | smallestScreenSize "/> <! -- Baidu --> <activity android: name = "com. baidu. mobads. AppActivity" android: configChanges = "keyboard | keyboardHidden | orientation"/> <! -- Adcolony --> <activity android: name = "com. jirbo. adcolony. adColonyOverlay "android: configChanges =" keyboardHidden | orientation | screenSize "android: theme =" @ android: style/Theme. translucent. noTitleBar. fullscreen "/> <activity android: name =" com. jirbo. adcolony. adColonyFullscreen "android: configChanges =" keyboardHidden | orientation | screenSize "android: theme =" @ android: style/Theme. black. noTitleBar. fullscreen" /> <Activity android: name = "com. jirbo. adcolony. adColonyBrowser "android: configChanges =" keyboardHidden | orientation | screenSize "android: theme =" @ android: style/Theme. black. noTitleBar. fullscreen "/> <! -- Guang dian tong --> <service android: name = "com. qq. e. comm. downloadService "android: exported =" false "/> <activity android: name =" com. qq. e. ads. ADActivity "android: configChanges =" keyboard | keyboardHidden | orientation | screenSize "/>

 


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.