Android应用嵌入有米SDK教程
2010-07-03 00:02
369 查看
欢迎使用有米广告平台的android端SDK,以下将为您介绍如何在android程序中嵌入有米广告。
步骤一:将youmiad-android.jar导入您的工程中。
Ø右键您的工程根目录,选择“Properties”
Ø在左面板中选择“Java Build Path”
Ø然后选择“Libraries”标签
Ø点击“Add External JARs…”
Ø选择youmiad-android.jar的目录路径
Ø点击“OK”即导入成功
步骤二:在工程中的AndroidManifest.xml中添加以下代码,并写入您的App ID和App Secret。
<!– 该应用程序的 App ID and App Seceret
–>
<meta-data android:value=“abcdef1234567890″ android:name=“UmAd_APP_SEC” />
<meta-data android:value=“1234567890abcdef”
android:name=“UmAd_APP_ID” />
</application>
<!– 有米广告 SDK permissions –>
<uses-permission android:name=“android.permission.INTERNET” />
注意:UmAd_APP_ID就是你应用程序的发布ID,在value那里填上你的发布ID就行了,如此处为”1234567890abcdef“。千万不可改变”UmAd_APP_ID” ,程序需要这个Key来查找对应的Value。”UmAd_APP_SEC“同理。UmAd_APP_ID和 UmAd_APP_SEC这两个ID是在 平台网站上提交应用时产生的发布ID和应用密码,而且每个应用的这两个ID都是唯一的。
步骤三:在res/values文件夹中添加attrs.xml。如果你没有添加这个文件,那你将不能在layout中设置AdView的属性。
attrs.xml文件的内容如下:
<?xml version=“1.0″ encoding=“utf-8″?>
<resources>
<declare-styleablename=“net.youmi.android.AdView”>
<attr name=“testing” format=“boolean” />
<attr name=“backgroundColor” format=“color” />
<attr name=“textColor” format=“color” />
<attr name=“keywords” format=“string” />
<attr name=“refreshInterval” format=“integer” />
<attr name=“isGoneWithoutAd” format=“boolean” />
<attr name=“changeAdAnimation” format=“boolean”/>
</declare-styleable>
</resources>
说明:
ØTesting:测试模式,如果是在调试程序中,建议设置为“true”,但是在发布程序前,一定要设置为false。默认为false。
ØbackgroundColor:设置广告视图的背景颜色
ØtextColor:设置广告文字的颜色
ØrefreshInterval:设置广告刷新率。默认为30s,设置范围为30s-200s
ØchangeAdAnimation:换广告的效果,true为翻转,false为淡入淡出
步骤四:在main.xml中布局有米广告视图。
以下为一个实例:
<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:umadsdk=”http://schemas.android.com/apk/res/net.youmi.HelloYouMi”
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
>
<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:textSize=”20px”
android:text=”@string/hello”
/>
<net.youmi.android.AdView
android:id=”@+id/ad”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
umadsdk:refreshInterval=”30″
umadsdk:changeAdAnimation=”true”
/>
</LinearLayout>
注意:
xmlns:umadsdk=“http://schemas.android.com/apk/res/net.youmi.HelloYouMi”
这句一定要加上,不然会提示错误。其中net.youmi.HelloYouMi是你应用程序包名
以下图示为成功添加有米广告的效果图:
步骤一:将youmiad-android.jar导入您的工程中。
Ø右键您的工程根目录,选择“Properties”
Ø在左面板中选择“Java Build Path”
Ø然后选择“Libraries”标签
Ø点击“Add External JARs…”
Ø选择youmiad-android.jar的目录路径
Ø点击“OK”即导入成功
步骤二:在工程中的AndroidManifest.xml中添加以下代码,并写入您的App ID和App Secret。
<!– 该应用程序的 App ID and App Seceret
–>
<meta-data android:value=“abcdef1234567890″ android:name=“UmAd_APP_SEC” />
<meta-data android:value=“1234567890abcdef”
android:name=“UmAd_APP_ID” />
</application>
<!– 有米广告 SDK permissions –>
<uses-permission android:name=“android.permission.INTERNET” />
注意:UmAd_APP_ID就是你应用程序的发布ID,在value那里填上你的发布ID就行了,如此处为”1234567890abcdef“。千万不可改变”UmAd_APP_ID” ,程序需要这个Key来查找对应的Value。”UmAd_APP_SEC“同理。UmAd_APP_ID和 UmAd_APP_SEC这两个ID是在 平台网站上提交应用时产生的发布ID和应用密码,而且每个应用的这两个ID都是唯一的。
步骤三:在res/values文件夹中添加attrs.xml。如果你没有添加这个文件,那你将不能在layout中设置AdView的属性。
attrs.xml文件的内容如下:
<?xml version=“1.0″ encoding=“utf-8″?>
<resources>
<declare-styleablename=“net.youmi.android.AdView”>
<attr name=“testing” format=“boolean” />
<attr name=“backgroundColor” format=“color” />
<attr name=“textColor” format=“color” />
<attr name=“keywords” format=“string” />
<attr name=“refreshInterval” format=“integer” />
<attr name=“isGoneWithoutAd” format=“boolean” />
<attr name=“changeAdAnimation” format=“boolean”/>
</declare-styleable>
</resources>
说明:
ØTesting:测试模式,如果是在调试程序中,建议设置为“true”,但是在发布程序前,一定要设置为false。默认为false。
ØbackgroundColor:设置广告视图的背景颜色
ØtextColor:设置广告文字的颜色
ØrefreshInterval:设置广告刷新率。默认为30s,设置范围为30s-200s
ØchangeAdAnimation:换广告的效果,true为翻转,false为淡入淡出
步骤四:在main.xml中布局有米广告视图。
以下为一个实例:
<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:umadsdk=”http://schemas.android.com/apk/res/net.youmi.HelloYouMi”
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
>
<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:textSize=”20px”
android:text=”@string/hello”
/>
<net.youmi.android.AdView
android:id=”@+id/ad”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
umadsdk:refreshInterval=”30″
umadsdk:changeAdAnimation=”true”
/>
</LinearLayout>
注意:
xmlns:umadsdk=“http://schemas.android.com/apk/res/net.youmi.HelloYouMi”
这句一定要加上,不然会提示错误。其中net.youmi.HelloYouMi是你应用程序包名
以下图示为成功添加有米广告的效果图:
相关文章推荐
- 使用admob移动广告SDK在Android应用中集成插页式广告教程
- Android教程-从零开始一步一步接入SDK
- Android基础入门教程——1.2.1 使用Eclipse + ADT + SDK开发Android APP
- 百度地图植入android应用系列教程四实现引入离线地图功能
- Android高手进阶教程(三)之----Android 中自定义View的应用.
- Android应用盈利广告平台的嵌入方法详解
- 【Android Studio使用教程5】使用SDK Manager时, SDK下载更新不了的解决方案(eclipse 也适用)
- Vuforia ARSDK-Unity3D在Android下开发高通增强现实的小应用
- [置顶] 微信sdk应用消息的接入(android)
- 【eoe教程】创建支持多种屏幕尺寸的Android应用
- 使用友盟SNS_SDK为Android应用加入SNS分享、同步功能
- Windows系统部署 Android 开发环境以及验证之傻瓜式教程(SDK+Eclipse+ADT)
- Android进阶之android应用的SDK版本之间的切换
- Android[初级教程]第十二章 Notification的应用
- 3G手机Android应用开发视频教程_黎活明老师的视频(第三天课程)总共有八天课程
- 在Android原生应用中嵌入ReactNative页面
- Android 开发环境配置图文教程(jdk+eclipse+android sdk)
- Android 开发环境配置图文教程(jdk+eclipse+android sdk)
- Android基础教程(5)之----单选项框RadioGroup的综合应用
- Android简易实战教程--第十一话《获取手机所有应用信息Engine类详解》