有米官网:http://www.youmi.net/register?r=MTI0MDg=

国内的广告,我觉得万普和有米还不错,我也只试了这两个,其他的都是看评价的,呵呵~~~首先我们去有米官网注册一个账号http://www.youmi.net/register?r=MTI0MDg=;然后添加一个应用,添加成功后会给你一个ID和密钥,在我们的程序中会用到。

在从官网下载jar包,目前有三个jar包,一个是广告条的,另一个是积分墙的,及推送广告。还有就是导入unity的class.jar。

其他都就写代码啦,首先在eclipse下建立一个android工程,把下载的两个jar包导入工程。我们只需要写他的主activity,AndroidManifest.xml和proguard-Projector.txt文件。

MainActivity.java:

注:注意把Activity改成UnityPlayerActivity哦!

  1. package com.dlnu.goddess;
  2. import com.unity3d.player.UnityPlayerActivity;
  3. import net.youmi.android.AdManager;
  4. import net.youmi.android.AdView;
  5. import net.youmi.android.appoffers.YoumiOffersManager;
  6. import net.youmi.android.appoffers.YoumiPointsManager;
  7. import net.youmi.push.android.YoumiPush;
  8. import android.os.Bundle;
  9. import android.content.Context;
  10. import android.view.ViewGroup.LayoutParams;
  11. import android.widget.LinearLayout;
  12. public class MainActivity extends UnityPlayerActivity {
  13. Context context =null;
  14. protected void onCreate(Bundle savedInstanceState) {
  15. super.onCreate(savedInstanceState);
  16. context = this;
  17. //推送广告
  18. YoumiPush.startYoumiPush(this, "f6e5dc3a6da84ca0", "98fb0492fd253f61", true);
  19. //banner广告
  20. AdManager.init(this,"9a96b4725e1947e6", "dbf605c63c57e21c", 30, false);
  21. LinearLayout layout=new LinearLayout(this);
  22. addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
  23. AdView adView = new AdView(this);
  24. LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
  25. layout.addView(adView, params);
  26. //积分墙
  27. YoumiOffersManager.init(this, "9a96b4725e1947e6", "dbf605c63c57e21c");
  28. }
  29. //打开积分墙
  30. void open1(){
  31. YoumiOffersManager.showOffers( MainActivity.this,YoumiOffersManager.TYPE_REWARD_OFFERS);
  32. }
  33. //打开推荐列表
  34. void opne2(){
  35. YoumiOffersManager.showOffers(MainActivity.this,YoumiOffersManager.TYPE_REWARDLESS_APPLIST);
  36. }
  37. //打开单个推荐
  38. void open3(){
  39. YoumiOffersManager.showOffers(MainActivity.this,YoumiOffersManager.TYPE_REWARDLESS_FEATUREDAPP);
  40. }
  41. //获取积分
  42. int getpoint(){
  43. return YoumiPointsManager.queryPoints(this);
  44. }
  45. }

AndroidManifest.xml:

注:注意主Aactivity哦,我这里是android:name="com.dlnu.goddess.MainActivity",就是我们上面的那个Activity,其实就是你第一个看到的页面,个人理解哦,呵呵~~~

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.dlnu.goddess"
  4. android:versionCode="1"
  5. android:versionName="1.0" >
  6. <uses-sdk
  7. android:minSdkVersion="8"
  8. android:targetSdkVersion="17" />
  9. <uses-permission android:name="android.permission.INTERNET"/>
  10. <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
  11. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  12. <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
  13. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  14. <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
  15. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  16. <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
  17. <uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"/>
  18. <application
  19. android:allowBackup="true"
  20. android:icon="@drawable/ic_launcher"
  21. android:label="@string/app_name"
  22. android:theme="@style/AppTheme" >
  23. <activity
  24. android:name="com.dlnu.goddess.MainActivity"
  25. android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation">
  26. <intent-filter>
  27. <action android:name="android.intent.action.MAIN" />
  28. <category android:name="android.intent.category.LAUNCHER" />
  29. </intent-filter>
  30. </activity>
  31. <service android:name="net.youmi.push.android.YoumiService"></service>
  32. <activity android:name="net.youmi.push.android.YoumiActivity"></activity>
  33. <receiver android:name="net.youmi.push.android.YoumiReceiver">
  34. <intent-filter>
  35. <action android:name="android.intent.action.BOOT_COMPLETED" />
  36. </intent-filter>
  37. <intent-filter>
  38. <action android:name="android.intent.action.PACKAGE_ADDED"/>
  39. <action android:name="android.intent.action.PACKAGE_INSTALL"/>
  40. <data android:scheme="package"/>
  41. </intent-filter>
  42. </receiver>
  43. <activity android:name="net.youmi.android.appoffers.YoumiOffersActivity"
  44. android:configChanges="keyboard|keyboardHidden|orientation"/>
  45. <activity
  46. android:configChanges="keyboard|keyboardHidden|orientation"
  47. android:name="net.youmi.android.AdActivity" />
  48. <receiver android:name="net.youmi.android.YoumiReceiver">
  49. <intent-filter>
  50. <action android:name="android.intent.action.PACKAGE_ADDED"/>
  51. <action android:name="android.intent.action.PACKAGE_INSTALL"/>
  52. <data android:scheme="package"/>
  53. </intent-filter>
  54. </receiver>
  55. <meta-data android:name="YOUMI_CHANNEL" android:value="0"></meta-data>
  56. </application>
  57. </manifest>

proguard-Projector.txt:

  1. # To enable ProGuard in your project, edit project.properties
  2. # to define the proguard.config property as described in that file.
  3. #
  4. # Add project specific ProGuard rules here.
  5. # By default, the flags in this file are appended to flags specified
  6. # in ${sdk.dir}/tools/proguard/proguard-android.txt
  7. # You can edit the include path and order by changing the ProGuard
  8. # include property in project.properties.
  9. #
  10. # For more details, see
  11. #   http://developer.android.com/guide/developing/tools/proguard.html
  12. # Add any project specific keep options here:
  13. # If your project uses WebView with JS, uncomment the following
  14. # and specify the fully qualified class name to the JavaScript interface
  15. # class:
  16. #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  17. #   public *;
  18. #}
  19. -keep class net.youmi.push.android.** {
  20. *;
  21. }
  22. -keep class net.youmi.android.appoffers.** {
  23. *;
  24. }
  25. -keep class net.youmi.android.** {
  26. *;
  27. }

接下来的部分就得看雨松MOMO的了,先在unity下建立一个工程,安装雨松momo的做法,把我们android工程打包并且放入unity里面就行,注意:在Plugins/Android/下要建立一个libs文件夹,把从有米官方下载的两个jar包导入。Plugins/Android/libs/xxx.jar,yyy,jar;最后最重要的就是把工程的包名改成android工程下的,我这里是com.dlnu.nate;剩下的就是看你在unity下调用android里面open1,open2,open3函数了。

Unity下的脚本:

  1. using UnityEngine;
  2. using System.Collections;
  3. public class AdTest : MonoBehaviour {
  4. AndroidJavaClass jc;
  5. AndroidJavaObject jo;
  6. void Start()
  7. {
  8. jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
  9. jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
  10. }
  11. void Update ()
  12. {
  13. if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home) )
  14. {
  15. Application.Quit();
  16. }
  17. }
  18. void OnGUI()
  19. {
  20. if(GUILayout.Button("OPEN1",GUILayout.Height(100)))
  21. {
  22. jo.Call("open1");
  23. }
  24. if(GUILayout.Button("OPEN2",GUILayout.Height(100)))
  25. {
  26. jo.Call("open2");
  27. }
  28. if(GUILayout.Button("OPEN3",GUILayout.Height(100)))
  29. {
  30. jo.Call("open3");
  31. }
  32. }
  33. }

注:一定要记得把报名改成Android里面的一样哦!

unity3d插入android有米广告的更多相关文章

  1. Android牟利之道(一)--界面嵌入有米广告

    经过了一番折腾,忙忙碌碌了一下午,终于搞明白了Android软件界面嵌入广告的方法,以下我以嵌入有米广告为例小结一下: 我的新浪微博(wind瑞):http://weibo.com/tianrui19 ...

  2. Android应用开发-小巫CSDN博客client之嵌入有米广告

    Android应用开发-小巫CSDN博客client之嵌入有米广告 上一篇博客给大家介绍怎样集成友盟社会化组件,本篇继续带来干货,教大家怎样嵌入广告到应用中去.小巫自称专业对接30年,熟悉各大渠道SD ...

  3. 【Android】接入有米广告SDK

    测试:接入有米广告SDK(测试广告). 步骤: 1.注册并登录有米广告. 2.下载相应的SDK,这里我选了第一个[Android广告SDK ],如下图: 3.下好后,根据doc文档步骤进行操作,包括: ...

  4. Android应用盈利广告平台的嵌入方法详解

    一.如何学习Android  android开发(这里不提platform和底层驱动)你需要对Java有个良好的基础,一般我们用Eclipse作为开发工具.对于过多的具体知识详细介绍我这里不展开,我只 ...

  5. Unity3d与android通信

    原地址:http://www.cnblogs.com/alongu3d/p/3661077.html unity3d与android的通信,从网上搜索了一些文章,发现我的始终不成功!后来调试通了,现在 ...

  6. Android UI - 实现广告Banner旋转木马效果

    Android UI - 实现广告Banner旋转木马效果 前言 本篇博客要分享的一个效果是实现广告Banner轮播效果,这个效果也比較常见,一些视频类应用就常常有,就拿360影视大全来举例吧: 用红 ...

  7. Android Google AdMob 广告接入示例

    Android Google AdMob 广告接入示例 [TOC] 首先请大家放心,虽然 Google搜索等服务被qiang了,但是 广告服务国内还是可以用的,真是普天同庆啊~~~噗! 其实这篇文章也 ...

  8. Unity3d和Android之间互相调用

    摘抄博客 Unity3d Android SDK接入解析(一)Unity3d 与 Android之间的互相调用,一共四章,一定要看完 No1: 总体来说Unity3d与Android之间的互相调用,是 ...

  9. Unity3D调用android方法(非插件方式)

    关于Unity3Dproject与androidproject的转换与合并,请參考我的另外一篇博客.假设你对Unity3Dproject增加到androidproject的过程不熟悉.也请先看完以下这 ...

随机推荐

  1. CentOS7安装MinIO教程,并在C#客户端WPF中实现监控上传进度

    MinIO的详细介绍可以参考官网(https://min.io/product/overview). 简单来说它是一个实现了AWS S3标准的100%开源的,可商用的( Apache V2 licen ...

  2. 2020-07-10:sql如何调优?

    福哥答案2020-07-10:此答案来自群成员: SQL提高查询效率的几点建议 1.如果要用子查询,那就用EXISTS替代IN.用NOT EXISTS替代NOT IN.因为EXISTS引入的子查询只是 ...

  3. C#LeetCode刷题之#933-最近的请求次数(Number of Recent Calls)

    问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/4134 访问. 写一个 RecentCounter 类来计算最近的 ...

  4. C#LeetCode刷题之#819-最常见的单词(Most Common Word)

    问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3969 访问. 给定一个段落 (paragraph) 和一个禁用单 ...

  5. C#LeetCode刷题-数组

    数组篇 # 题名 刷题 通过率 难度 1 两数之和 C#LeetCode刷题之#1-两数之和(Two Sum) 43.1% 简单 4 两个排序数组的中位数 C#LeetCode刷题之#4-两个排序数组 ...

  6. Quartz.Net的基础使用方法,多任务执行

    接着上面单任务执行的代码做一下简单的扩展 主要看下面这段代码,这是Quartz多任务调度的方法,主要就是围绕这个方法去扩展: // // 摘要: // Schedule all of the give ...

  7. matlab使用libsvm入门教程——使用matlab安装配置libsvm以及一个svm分类实例

    前言 此教程专注于刚入门的小白, 且博客拥有时效性, 发布于2019年3月份, 可能后面的读者会发现一些问题, 欢迎底下评论出现的问题,我将尽可能更新解决方案. 我开始也在如何安装libsvm上出现了 ...

  8. golang 标准库

    前言 不做文字搬运工,多做思路整理 就是为了能速览标准库,只整理我自己看过的...... 最好能看看英文的 标准库 fmt strconv string 跳转 golang知识库总结

  9. google protocol buffer——protobuf的基本使用和模型分析

    这一系列文章主要是对protocol buffer这种编码格式的使用方式.特点.使用技巧进行说明,并在原生protobuf的基础上进行扩展和优化,使得它能更好地为我们服务. 1.什么是protobuf ...

  10. Python 常用的操作文件代码

    1:统计list中相同的个数,并按大小排序. original_list = ['a', 'b', 'b', 'a', 'd', 'd', 'b', 'z', 'c', 'b', 'r', 's', ...