在从官网下载jar包,目前有三个jar包,一个是广告条的,另一个是积分墙的,及推送广告。还有就是导入unity的class.jar。
其他都就写代码啦,首先在eclipse下建立一个android工程,把下载的两个jar包导入工程。我们只需要写他的主activity,AndroidManifest.xml和proguard-Projector.txt文件。
MainActivity.java:
注:注意把Activity改成UnityPlayerActivity哦!
[html] view plain copy print ?
1. package com.dlnu.goddess;
2.
3. import com.unity3d.player.UnityPlayerActivity;
4.
5. import net.youmi.android.AdManager;
6. import net.youmi.android.AdView;
7. import net.youmi.android.appoffers.YoumiOffersManager;
8. import net.youmi.android.appoffers.YoumiPointsManager;
9. import net.youmi.push.android.YoumiPush;
10. import android.os.Bundle;
11. import android.content.Context;
12. import android.view.ViewGroup.LayoutParams;
13. import android.widget.LinearLayout;
14.
15. public class MainActivity extends UnityPlayerActivity {
16.
17. context =null;
18. protected void onCreate(Bundle savedInstanceState) {
19. super.onCreate(savedInstanceState);
20. context = this;
21. //推送广告
22. YoumiPush.startYoumiPush(this, "f6e5dc3a6da84ca0", "98fb0492fd253f61", true);
23.
24. //banner广告
25. AdManager.init(this,"9a96b4725e1947e6", "dbf605c63c57e21c", 30, false);
26. layout=new LinearLayout(this);
27. addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
28. adView = new AdView(this);
29. params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
30. layout.addView(adView, params);
31.
32. //积分墙
33. YoumiOffersManager.init(this, "9a96b4725e1947e6", "dbf605c63c57e21c");
34. }
35. //打开积分墙
36. void open1(){
37. YoumiOffersManager.showOffers( MainActivity.this,YoumiOffersManager.TYPE_REWARD_OFFERS);
38. }
39. //打开推荐列表
40. void opne2(){
41.
42. YoumiOffersManager.showOffers(MainActivity.this,YoumiOffersManager.TYPE_REWARDLESS_APPLIST);
43.
44. }
45. //打开单个推荐
46. void open3(){
47.
48. YoumiOffersManager.showOffers(MainActivity.this,YoumiOffersManager.TYPE_REWARDLESS_FEATUREDAPP);
49. }
50. //获取积分
51. int getpoint(){
52.
53. return YoumiPointsManager.queryPoints(this);
54. }
55.
56. }
AndroidManifest.xml:
注:注意主Aactivity哦,我这里是android:name="com.dlnu.goddess.MainActivity",就是我们上面的那个Activity,其实就是你第一个看到的页面,个人理解哦,呵呵~~~
[html] view plain copy print ?
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.
7. <uses-sdk
8. android:minSdkVersion="8"
9. android:targetSdkVersion="17" />
10. <uses-permission android:name="android.permission.INTERNET"/>
11. <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
12. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
13. <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
14. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
15. <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
16. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
17. <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
18. <uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"/>
19. <application
20. android:allowBackup="true"
21. android:icon="@drawable/ic_launcher"
22. android:label="@string/app_name"
23. android:theme="@style/AppTheme" >
24. <activity
25. android:name="com.dlnu.goddess.MainActivity"
26. android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation">
27. <intent-filter>
28. <action android:name="android.intent.action.MAIN" />
29.
30. <category android:name="android.intent.category.LAUNCHER" />
31. </intent-filter>
32. </activity>
33. <service android:name="net.youmi.push.android.YoumiService"></service>
34. <activity android:name="net.youmi.push.android.YoumiActivity"></activity>
35. <receiver android:name="net.youmi.push.android.YoumiReceiver">
36. <intent-filter>
37. <action android:name="android.intent.action.BOOT_COMPLETED" />
38. </intent-filter>
39. <intent-filter>
40. <action android:name="android.intent.action.PACKAGE_ADDED"/>
41. <action android:name="android.intent.action.PACKAGE_INSTALL"/>
42. <data android:scheme="package"/>
43. </intent-filter>
44. </receiver>
45. <activity android:name="net.youmi.android.appoffers.YoumiOffersActivity"
46. android:configChanges="keyboard|keyboardHidden|orientation"/>
47. <activity
48. android:configChanges="keyboard|keyboardHidden|orientation"
49. android:name="net.youmi.android.AdActivity" />
50. <receiver android:name="net.youmi.android.YoumiReceiver">
51. <intent-filter>
52. <action android:name="android.intent.action.PACKAGE_ADDED"/>
53. <action android:name="android.intent.action.PACKAGE_INSTALL"/>
54. <data android:scheme="package"/>
55. </intent-filter>
56. </receiver>
57. <meta-data android:name="YOUMI_CHANNEL" android:value="0"></meta-data>
58.
59. </application>
60.
61. </manifest>
proguard-Projector.txt:
[html] view plain copy print ?
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.
13. # Add any project specific keep options here:
14.
15. # If your project uses WebView with JS, uncomment the following
16. # and specify the fully qualified class name to the JavaScript interface
17. # class:
18. #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19. # public *;
20. #}
21. -keep class net.youmi.push.android.** {
22. *;
23. }
24. -keep class net.youmi.android.appoffers.** {
25. *;
26. }
27. -keep class net.youmi.android.** {
28. *;
29. }
接下来的部分就得看雨松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下的脚本:
[html] view plain copy print ?
1. using UnityEngine;
2. using System.Collections;
3.
4. public class AdTest : MonoBehaviour {
5.
6. AndroidJavaClass jc;
7. AndroidJavaObject jo;
8. void Start()
9. {
10. jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
11. jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
12. }
13. void Update ()
14. {
15. if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home) )
16. {
17. Application.Quit();
18. }
19. }
20.
21. void OnGUI()
22. {
23. if(GUILayout.Button("OPEN1",GUILayout.Height(100)))
24. {
25. jo.Call("open1");
26. }
27. if(GUILayout.Button("OPEN2",GUILayout.Height(100)))
28. {
29. jo.Call("open2");
30. }
31. if(GUILayout.Button("OPEN3",GUILayout.Height(100)))
32. {
33. jo.Call("open3");
34. }
35. }
36.
37.
38. }
注:一定要记得把报名改成Android里面的一样哦!
转载地址:
国内的广告,我觉得万普和有米还不错,我也只试了这两个,其他的都是看评价的,呵呵~~~首先我们去有米官网注册一个账号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哦!
[html] view plain copy print ?
AndroidManifest.xml:
1. package com.dlnu.goddess;
2.
3. import com.unity3d.player.UnityPlayerActivity;
4.
5. import net.youmi.android.AdManager;
6. import net.youmi.android.AdView;
7. import net.youmi.android.appoffers.YoumiOffersManager;
8. import net.youmi.android.appoffers.YoumiPointsManager;
9. import net.youmi.push.android.YoumiPush;
10. import android.os.Bundle;
11. import android.content.Context;
12. import android.view.ViewGroup.LayoutParams;
13. import android.widget.LinearLayout;
14.
15. public class MainActivity extends UnityPlayerActivity {
16.
17. context =null;
18. protected void onCreate(Bundle savedInstanceState) {
19. super.onCreate(savedInstanceState);
20. context = this;
21. //推送广告
22. YoumiPush.startYoumiPush(this, "f6e5dc3a6da84ca0", "98fb0492fd253f61", true);
23.
24. //banner广告
25. AdManager.init(this,"9a96b4725e1947e6", "dbf605c63c57e21c", 30, false);
26. layout=new LinearLayout(this);
27. addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
28. adView = new AdView(this);
29. params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
30. layout.addView(adView, params);
31.
32. //积分墙
33. YoumiOffersManager.init(this, "9a96b4725e1947e6", "dbf605c63c57e21c");
34. }
35. //打开积分墙
36. void open1(){
37. YoumiOffersManager.showOffers( MainActivity.this,YoumiOffersManager.TYPE_REWARD_OFFERS);
38. }
39. //打开推荐列表
40. void opne2(){
41.
42. YoumiOffersManager.showOffers(MainActivity.this,YoumiOffersManager.TYPE_REWARDLESS_APPLIST);
43.
44. }
45. //打开单个推荐
46. void open3(){
47.
48. YoumiOffersManager.showOffers(MainActivity.this,YoumiOffersManager.TYPE_REWARDLESS_FEATUREDAPP);
49. }
50. //获取积分
51. int getpoint(){
52.
53. return YoumiPointsManager.queryPoints(this);
54. }
55.
56. }
注:注意主Aactivity哦,我这里是android:name="com.dlnu.goddess.MainActivity",就是我们上面的那个Activity,其实就是你第一个看到的页面,个人理解哦,呵呵~~~
[html] view plain copy print ?
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.
7. <uses-sdk
8. android:minSdkVersion="8"
9. android:targetSdkVersion="17" />
10. <uses-permission android:name="android.permission.INTERNET"/>
11. <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
12. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
13. <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
14. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
15. <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
16. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
17. <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
18. <uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"/>
19. <application
20. android:allowBackup="true"
21. android:icon="@drawable/ic_launcher"
22. android:label="@string/app_name"
23. android:theme="@style/AppTheme" >
24. <activity
25. android:name="com.dlnu.goddess.MainActivity"
26. android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation">
27. <intent-filter>
28. <action android:name="android.intent.action.MAIN" />
29.
30. <category android:name="android.intent.category.LAUNCHER" />
31. </intent-filter>
32. </activity>
33. <service android:name="net.youmi.push.android.YoumiService"></service>
34. <activity android:name="net.youmi.push.android.YoumiActivity"></activity>
35. <receiver android:name="net.youmi.push.android.YoumiReceiver">
36. <intent-filter>
37. <action android:name="android.intent.action.BOOT_COMPLETED" />
38. </intent-filter>
39. <intent-filter>
40. <action android:name="android.intent.action.PACKAGE_ADDED"/>
41. <action android:name="android.intent.action.PACKAGE_INSTALL"/>
42. <data android:scheme="package"/>
43. </intent-filter>
44. </receiver>
45. <activity android:name="net.youmi.android.appoffers.YoumiOffersActivity"
46. android:configChanges="keyboard|keyboardHidden|orientation"/>
47. <activity
48. android:configChanges="keyboard|keyboardHidden|orientation"
49. android:name="net.youmi.android.AdActivity" />
50. <receiver android:name="net.youmi.android.YoumiReceiver">
51. <intent-filter>
52. <action android:name="android.intent.action.PACKAGE_ADDED"/>
53. <action android:name="android.intent.action.PACKAGE_INSTALL"/>
54. <data android:scheme="package"/>
55. </intent-filter>
56. </receiver>
57. <meta-data android:name="YOUMI_CHANNEL" android:value="0"></meta-data>
58.
59. </application>
60.
61. </manifest>
proguard-Projector.txt:
[html] view plain copy print ?
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.
13. # Add any project specific keep options here:
14.
15. # If your project uses WebView with JS, uncomment the following
16. # and specify the fully qualified class name to the JavaScript interface
17. # class:
18. #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19. # public *;
20. #}
21. -keep class net.youmi.push.android.** {
22. *;
23. }
24. -keep class net.youmi.android.appoffers.** {
25. *;
26. }
27. -keep class net.youmi.android.** {
28. *;
29. }
接下来的部分就得看雨松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下的脚本:
[html] view plain copy print ?
1. using UnityEngine;
2. using System.Collections;
3.
4. public class AdTest : MonoBehaviour {
5.
6. AndroidJavaClass jc;
7. AndroidJavaObject jo;
8. void Start()
9. {
10. jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
11. jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
12. }
13. void Update ()
14. {
15. if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home) )
16. {
17. Application.Quit();
18. }
19. }
20.
21. void OnGUI()
22. {
23. if(GUILayout.Button("OPEN1",GUILayout.Height(100)))
24. {
25. jo.Call("open1");
26. }
27. if(GUILayout.Button("OPEN2",GUILayout.Height(100)))
28. {
29. jo.Call("open2");
30. }
31. if(GUILayout.Button("OPEN3",GUILayout.Height(100)))
32. {
33. jo.Call("open3");
34. }
35. }
36.
37.
38. }
注:一定要记得把报名改成Android里面的一样哦!