unity3d插入android有米广告
有米官网: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哦!
- package com.dlnu.goddess;
- import com.unity3d.player.UnityPlayerActivity;
- import net.youmi.android.AdManager;
- import net.youmi.android.AdView;
- import net.youmi.android.appoffers.YoumiOffersManager;
- import net.youmi.android.appoffers.YoumiPointsManager;
- import net.youmi.push.android.YoumiPush;
- import android.os.Bundle;
- import android.content.Context;
- import android.view.ViewGroup.LayoutParams;
- import android.widget.LinearLayout;
- public class MainActivity extends UnityPlayerActivity {
- Context context =null;
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- context = this;
- //推送广告
- YoumiPush.startYoumiPush(this, "f6e5dc3a6da84ca0", "98fb0492fd253f61", true);
- //banner广告
- AdManager.init(this,"9a96b4725e1947e6", "dbf605c63c57e21c", 30, false);
- LinearLayout layout=new LinearLayout(this);
- addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
- AdView adView = new AdView(this);
- LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
- layout.addView(adView, params);
- //积分墙
- YoumiOffersManager.init(this, "9a96b4725e1947e6", "dbf605c63c57e21c");
- }
- //打开积分墙
- void open1(){
- YoumiOffersManager.showOffers( MainActivity.this,YoumiOffersManager.TYPE_REWARD_OFFERS);
- }
- //打开推荐列表
- void opne2(){
- YoumiOffersManager.showOffers(MainActivity.this,YoumiOffersManager.TYPE_REWARDLESS_APPLIST);
- }
- //打开单个推荐
- void open3(){
- YoumiOffersManager.showOffers(MainActivity.this,YoumiOffersManager.TYPE_REWARDLESS_FEATUREDAPP);
- }
- //获取积分
- int getpoint(){
- return YoumiPointsManager.queryPoints(this);
- }
- }
AndroidManifest.xml:
注:注意主Aactivity哦,我这里是android:name="com.dlnu.goddess.MainActivity",就是我们上面的那个Activity,其实就是你第一个看到的页面,个人理解哦,呵呵~~~
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.dlnu.goddess"
- android:versionCode="1"
- android:versionName="1.0" >
- <uses-sdk
- android:minSdkVersion="8"
- android:targetSdkVersion="17" />
- <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_COARSE_LOCATION"/>
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
- <uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"/>
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <activity
- android:name="com.dlnu.goddess.MainActivity"
- android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <service android:name="net.youmi.push.android.YoumiService"></service>
- <activity android:name="net.youmi.push.android.YoumiActivity"></activity>
- <receiver android:name="net.youmi.push.android.YoumiReceiver">
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.PACKAGE_ADDED"/>
- <action android:name="android.intent.action.PACKAGE_INSTALL"/>
- <data android:scheme="package"/>
- </intent-filter>
- </receiver>
- <activity android:name="net.youmi.android.appoffers.YoumiOffersActivity"
- android:configChanges="keyboard|keyboardHidden|orientation"/>
- <activity
- android:configChanges="keyboard|keyboardHidden|orientation"
- android:name="net.youmi.android.AdActivity" />
- <receiver android:name="net.youmi.android.YoumiReceiver">
- <intent-filter>
- <action android:name="android.intent.action.PACKAGE_ADDED"/>
- <action android:name="android.intent.action.PACKAGE_INSTALL"/>
- <data android:scheme="package"/>
- </intent-filter>
- </receiver>
- <meta-data android:name="YOUMI_CHANNEL" android:value="0"></meta-data>
- </application>
- </manifest>
proguard-Projector.txt:
- # To enable ProGuard in your project, edit project.properties
- # to define the proguard.config property as described in that file.
- #
- # Add project specific ProGuard rules here.
- # By default, the flags in this file are appended to flags specified
- # in ${sdk.dir}/tools/proguard/proguard-android.txt
- # You can edit the include path and order by changing the ProGuard
- # include property in project.properties.
- #
- # For more details, see
- # http://developer.android.com/guide/developing/tools/proguard.html
- # Add any project specific keep options here:
- # If your project uses WebView with JS, uncomment the following
- # and specify the fully qualified class name to the JavaScript interface
- # class:
- #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
- # public *;
- #}
- -keep class net.youmi.push.android.** {
- *;
- }
- -keep class net.youmi.android.appoffers.** {
- *;
- }
- -keep class net.youmi.android.** {
- *;
- }
接下来的部分就得看雨松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下的脚本:
- using UnityEngine;
- using System.Collections;
- public class AdTest : MonoBehaviour {
- AndroidJavaClass jc;
- AndroidJavaObject jo;
- void Start()
- {
- jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
- jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
- }
- void Update ()
- {
- if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home) )
- {
- Application.Quit();
- }
- }
- void OnGUI()
- {
- if(GUILayout.Button("OPEN1",GUILayout.Height(100)))
- {
- jo.Call("open1");
- }
- if(GUILayout.Button("OPEN2",GUILayout.Height(100)))
- {
- jo.Call("open2");
- }
- if(GUILayout.Button("OPEN3",GUILayout.Height(100)))
- {
- jo.Call("open3");
- }
- }
- }
注:一定要记得把报名改成Android里面的一样哦!


unity3d插入android有米广告的更多相关文章
- Android牟利之道(一)--界面嵌入有米广告
经过了一番折腾,忙忙碌碌了一下午,终于搞明白了Android软件界面嵌入广告的方法,以下我以嵌入有米广告为例小结一下: 我的新浪微博(wind瑞):http://weibo.com/tianrui19 ...
- Android应用开发-小巫CSDN博客client之嵌入有米广告
Android应用开发-小巫CSDN博客client之嵌入有米广告 上一篇博客给大家介绍怎样集成友盟社会化组件,本篇继续带来干货,教大家怎样嵌入广告到应用中去.小巫自称专业对接30年,熟悉各大渠道SD ...
- 【Android】接入有米广告SDK
测试:接入有米广告SDK(测试广告). 步骤: 1.注册并登录有米广告. 2.下载相应的SDK,这里我选了第一个[Android广告SDK ],如下图: 3.下好后,根据doc文档步骤进行操作,包括: ...
- Android应用盈利广告平台的嵌入方法详解
一.如何学习Android android开发(这里不提platform和底层驱动)你需要对Java有个良好的基础,一般我们用Eclipse作为开发工具.对于过多的具体知识详细介绍我这里不展开,我只 ...
- Unity3d与android通信
原地址:http://www.cnblogs.com/alongu3d/p/3661077.html unity3d与android的通信,从网上搜索了一些文章,发现我的始终不成功!后来调试通了,现在 ...
- Android UI - 实现广告Banner旋转木马效果
Android UI - 实现广告Banner旋转木马效果 前言 本篇博客要分享的一个效果是实现广告Banner轮播效果,这个效果也比較常见,一些视频类应用就常常有,就拿360影视大全来举例吧: 用红 ...
- Android Google AdMob 广告接入示例
Android Google AdMob 广告接入示例 [TOC] 首先请大家放心,虽然 Google搜索等服务被qiang了,但是 广告服务国内还是可以用的,真是普天同庆啊~~~噗! 其实这篇文章也 ...
- Unity3d和Android之间互相调用
摘抄博客 Unity3d Android SDK接入解析(一)Unity3d 与 Android之间的互相调用,一共四章,一定要看完 No1: 总体来说Unity3d与Android之间的互相调用,是 ...
- Unity3D调用android方法(非插件方式)
关于Unity3Dproject与androidproject的转换与合并,请參考我的另外一篇博客.假设你对Unity3Dproject增加到androidproject的过程不熟悉.也请先看完以下这 ...
随机推荐
- CentOS7安装MinIO教程,并在C#客户端WPF中实现监控上传进度
MinIO的详细介绍可以参考官网(https://min.io/product/overview). 简单来说它是一个实现了AWS S3标准的100%开源的,可商用的( Apache V2 licen ...
- 2020-07-10:sql如何调优?
福哥答案2020-07-10:此答案来自群成员: SQL提高查询效率的几点建议 1.如果要用子查询,那就用EXISTS替代IN.用NOT EXISTS替代NOT IN.因为EXISTS引入的子查询只是 ...
- C#LeetCode刷题之#933-最近的请求次数(Number of Recent Calls)
问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/4134 访问. 写一个 RecentCounter 类来计算最近的 ...
- C#LeetCode刷题之#819-最常见的单词(Most Common Word)
问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3969 访问. 给定一个段落 (paragraph) 和一个禁用单 ...
- C#LeetCode刷题-数组
数组篇 # 题名 刷题 通过率 难度 1 两数之和 C#LeetCode刷题之#1-两数之和(Two Sum) 43.1% 简单 4 两个排序数组的中位数 C#LeetCode刷题之#4-两个排序数组 ...
- Quartz.Net的基础使用方法,多任务执行
接着上面单任务执行的代码做一下简单的扩展 主要看下面这段代码,这是Quartz多任务调度的方法,主要就是围绕这个方法去扩展: // // 摘要: // Schedule all of the give ...
- matlab使用libsvm入门教程——使用matlab安装配置libsvm以及一个svm分类实例
前言 此教程专注于刚入门的小白, 且博客拥有时效性, 发布于2019年3月份, 可能后面的读者会发现一些问题, 欢迎底下评论出现的问题,我将尽可能更新解决方案. 我开始也在如何安装libsvm上出现了 ...
- golang 标准库
前言 不做文字搬运工,多做思路整理 就是为了能速览标准库,只整理我自己看过的...... 最好能看看英文的 标准库 fmt strconv string 跳转 golang知识库总结
- google protocol buffer——protobuf的基本使用和模型分析
这一系列文章主要是对protocol buffer这种编码格式的使用方式.特点.使用技巧进行说明,并在原生protobuf的基础上进行扩展和优化,使得它能更好地为我们服务. 1.什么是protobuf ...
- Python 常用的操作文件代码
1:统计list中相同的个数,并按大小排序. original_list = ['a', 'b', 'b', 'a', 'd', 'd', 'b', 'z', 'c', 'b', 'r', 's', ...