整合千年媒体SDK 5.0的Andr​​oid应用程序 [英] Integrate Millennial Media SDK 5.0 in Android Application

查看:148
本文介绍了整合千年媒体SDK 5.0的Andr​​oid应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于格式的问题,我试图格式化,但它并没有显示出来的code几行字,我不知道为什么。它今天发生的第二次。请如果有人可以对其进行格式化,这将是巨大的。

Quesiton - :

安卓2.3.3

我只是想千年媒体SDK集成到一个演示程序。没有华而不实的东西。只需简单的应用程序,以获得实现它的想法。

下面是我做了:::

  1. 从网站上下载android_5_0_0_sdk。
  2. 在创建了一个项目,并且增加了MMSDK.jar文件库
  3. 在Rgight点击项目,进入属性 - > Java构建path-> libraries->添加jars->选择的路径库和MMSDK.jar

4.Added的XML code到我的活动

 < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:毫米=htt​​p://millennialmedia.com/android/schema//这
    的xmlns:工具=htt​​p://schemas.android.com/tool​​s
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:paddingBottom会=@扪/ activity_vertical_margin
    机器人:以下属性来=@扪/ activity_horizo​​ntal_margin
    机器人:paddingRight =@扪/ activity_horizo​​ntal_margin
    机器人:paddingTop =@扪/ activity_vertical_margin
    工具:上下文=MainActivity。>

    <的TextView
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:文本=@字符串/参考hello world/>

    // 和这个
    < com.millennialmedia.android.MMAdView
        机器人:ID =@ + ID / AD浏览报
        机器人:layout_width =468dp
        机器人:layout_height =60dp
        机器人:layout_alignParentTop =真
        机器人:layout_centerHorizo​​ntal =真
        MM:APID =123149
        MM:高=60
        毫米:宽=468/>


< / RelativeLayout的>
 

  1. 这是我的Andr​​oidManifest.xml

     < XML版本=1.0编码=UTF-8&GT?;
    <舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=com.example.millennialdemo
    安卓版code =1
    机器人:VERSIONNAME =1.0>
    
    <用途-SDK
        安卓的minSdkVersion =8
        机器人:targetSdkVersion =17/>
    
    <使用-权限的Andr​​oid:名称=android.permission.READ_PHONE_STATE/>
    <使用-权限的Andr​​oid:名称=android.permission.INTERNET对/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_NETWORK_STATE/>
    <使用-权限的Andr​​oid:名称=android.permission.WRITE_EXTERNAL_STORAG​​E/>
    
    <应用
    机器人:allowBackup =真
    机器人:图标=@可绘制/ ic_launcher
    机器人:标签=@字符串/ APP_NAME
    机器人:主题=@风格/ AppTheme>
    <活动
        机器人:名称=com.example.millennialdemo.MainActivity
        机器人:标签=@字符串/ APP_NAME>
        <意向滤光器>
            <作用机器人:名称=android.intent.action.MAIN/>
    
            <类机器人:名称=android.intent.category.LAUNCHER/>
        &所述; /意图滤光器>
    < /活性GT;
    
    <  - !开始MillennialMedia.com code的 - >
    <活动
        机器人:名称=com.millennialmedia.android.MMActivity
        机器人:configChanges =keyboardHidden |方向|键盘>
    < /活性GT;
    <活动
        机器人:名称=com.millennialmedia.android.VideoPlayer
        机器人:configChanges =keyboardHidden |方向|键盘>
    < /活性GT;
    
    <! - 的MillennialMedia.com code端 - >
     

  1. 下面是我的MainActivity: -

     进口com.millennialmedia.android.MMAdView;
    进口com.millennialmedia.android.MMInterstitial;
    进口com.millennialmedia.android.MMAd;
    进口com.millennialmedia.android.MMBroadcastReceiver;
    进口com.millennialmedia.android.MMRequest;
    进口com.millennialmedia.android.MMSDK;
    进口com.millennialmedia.android.RequestListener.RequestListenerImpl;
    公共类MainActivity延伸活动{
    
    @覆盖
    保护无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
    
        MMSDK.initialize(本);
    
        的setContentView(R.layout.activity_main);
    
        MMAdView AD浏览报=新MMAdView(本);
    
        //替换YOUR_APID与千年媒体提供给您的APID
        adView.setApid(123149);
    
        在MMRequest对象//设置你的元数据
        MMRequest请求=新MMRequest();
    
        //添加元数据在这里。
    
        //该MMRequest对象添加到您的MMAdView。
        adView.setMMRequest(要求);
    
        //设置ID为preserve广告上的配置更改。
        adView.setId(MMSDK.getDefaultAdId());
            adView.getAd(); //改变由千年马克建议
    
    
    }
    
    @覆盖
    公共布尔onCreateOptionsMenu(功能菜单){
        //充气菜单;这增加了项目操作栏,如果它是present。
        。getMenuInflater()膨胀(R.menu.main,菜单);
        返回true;
    }
    
    }
     

我想我所做的一切被告知在文档中,但我没有得到任何的广告和我得到的是下面的日志中我logcat中...

  05-20 20:54:58.932:E / Web控制台(386):的ReferenceError:找不到变量:MMJS在不确定的:1
05-20 20:54:58.932:E / Web控制台(386):的ReferenceError:找不到变量:MMJS在不确定的:1
05-20 20:54:58.972:W / MillennialMediaSDK(386):AD浏览报onLayout changedfalse INT留下24 INT前24 INT权456 INT底部99
05-20 20:55:00.3​​82:D / dalvikvm(386):GC_CONCURRENT释放1228K,57%免费2903K / 6727K,外部2002K / 2137K,暂停为6ms + 6ms的
05-20 20:55:01.172:E / MillennialMediaSDK(386):无法获取握手。没有对方的证书
05-20 20:55:01.172:E / MillennialMediaSDK(386):无法获取握手。没有对方的证书
05-20 20:55:01.212:D / dalvikvm(386):GC_CONCURRENT释放826K,58%免费2843K / 6727K,外部2002K / 2137K,暂停为6ms + 5ms的
 

我不明白发生了什么错误。如果有人能帮助我,这是多少AP preciated。

更改此之后

  MMAdView AD浏览报=新MMAdView(本);
 

  MMAdView AD浏览报=(MMAdView)findViewById(R.id.adView);
 

我仍然有同样的问题..这里是logcat的。

  05-20 21:57:26.911:I / MillennialMediaSDK(467):初始化MMLayout。
05-20 21:57:27.631:W / MillennialMediaSDK(467):MMLayout添加视图(MMWebView最初是从(1)MRaidState(装载)),以AdType [(B)InternalId(1)LinkedId(0)isFinishing(假) ]
05-20 21:57:27.842:W / MillennialMediaSDK(467):AD浏览报onLayout changedtrue INT留下24 INT前24 INT权456 INT底部114
05-20 21:57:27.861:W / MillennialMediaSDK(467):ID检查的家长:1对1
05-20 21:57:27.911:W / MillennialMediaSDK(467):AD浏览报onLayout changedfalse INT留下24 INT前24 INT权456 INT底部114
05-20 21:57:28.041:E / Web控制台(467):的ReferenceError:找不到变量:MMJS在不确定的:1
05-20 21:57:28.051:E / Web控制台(467):的ReferenceError:找不到变量:MMJS在不确定的:1
05-20 21:57:28.551:W / MillennialMediaSDK(467):AD浏览报onLayout changedfalse INT留下24 INT前24 INT权456 INT底部114
05-20 21:57:29.541:D / dalvikvm(467):GC_CONCURRENT释放1226K,57%免费2905K / 6727K,外部2002K / 2137K,暂停为5ms + 9ms的
05-20 21:57:30.292:E / MillennialMediaSDK(467):无法获取握手。没有对方的证书
05-20 21:57:30.301:E / MillennialMediaSDK(467):无法获取握手。没有对方的证书
05-20 21:57:30.331:D / dalvikvm(467):GC_CONCURRENT释放813K,58%免费2843K / 6727K,外部2002K / 2137K,暂停4毫秒+ 4ms的
 

改变code所建议的千年马克后,我得到了下面的错误,基本上是相同的。

 八月五日至21日:54:38.948:I / MillennialMediaSDK(341):初始化MMLayout。
8月5日至21日:54:39.616:W / MillennialMediaSDK(341):MMLayout添加视图(MMWebView最初是从(1)MRaidState(装载)),以AdType [(B)InternalId(1)LinkedId(0)isFinishing(假) ]
8月5日至21日:54:40.027:W / MillennialMediaSDK(341):AD浏览报onLayout changedtrue INT留下24 INT前24 INT权456 INT底部99
8月5日至21日:54:40.055:W / MillennialMediaSDK(341):ID检查的家长:1对1
8月5日至21日:54:40.115:W / MillennialMediaSDK(341):AD浏览报onLayout changedfalse INT留下24 INT前24 INT权456 INT底部99
8月5日至21日:54:40.295:E / Web控制台(341):的ReferenceError:找不到变量:MMJS在不确定的:1
8月5日至21日:54:40.295:E / Web控制台(341):的ReferenceError:找不到变量:MMJS在不确定的:1
8月5日至21日:54:40.295:W / MillennialMediaSDK(341):AD浏览报onLayout changedfalse INT留下24 INT前24 INT权456 INT底部99
8月5日至21日:54:58.139:E / MillennialMediaSDK(341):广告请求的HTTP错误。 androidsdk.ads.mp.mydas.mobi
8月5日至21日:54:59.527:E / MillennialMediaSDK(341):无法获取握手。 ads.mp.mydas.mobi
8月5日至21日:54:59.527:E / MillennialMediaSDK(341):无法获取握手。 ads.mp.mydas.mobi
 

我已经通过千年马克在其他情况下给出的答案去了。这是我做了什么。

单击鼠标右键在项目 - >属性 - > Java构建path->去订货和出口标签,检查MMSDK jar文件的复选框。现在,我不明白的握手的错误,但参考的错误仍然出现,并没有广告被显示出来。

下面是logcat的跟踪

 九月5日至21日:03:33.565:E / Web控制台(341):的ReferenceError:找不到变量:MMJS在不确定的:1
9月5号至21号:03:46.296:W / MillennialMediaSDK(341):ID检查的家长:1对1
9月5号至21号:03:46.346:E / Web控制台(341):的ReferenceError:找不到变量:MMJS在不确定的:1
 

修改MainActivity

 包com.example.millennialdemo;

进口android.os.Bundle;
进口android.app.Activity;
进口android.util.DisplayMetrics;
进口android.util.TypedValue;
进口android.view.Menu;
进口android.widget.RelativeLayout;

进口com.millennialmedia.android.MMAdView;
进口com.millennialmedia.android.MMInterstitial;
进口com.millennialmedia.android.MMAd;
进口com.millennialmedia.android.MMBroadcastReceiver;
进口com.millennialmedia.android.MMRequest;
进口com.millennialmedia.android.MMSDK;
进口com.millennialmedia.android.RequestListener.RequestListenerImpl;


公共类MainActivity延伸活动{

    @覆盖
    保护无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);

        MMSDK.initialize(本);

        的setContentView(R.layout.activity_main);

        MMAdView AD浏览报=(MMAdView)findViewById(R.id.adView);

        //替换YOUR_APID与千年媒体提供给您的APID
        adView.setApid(123149);

        在MMRequest对象//设置你的元数据
        MMRequest请求=新MMRequest();

        //添加元数据在这里。

        //该MMRequest对象添加到您的MMAdView。
        adView.setMMRequest(要求);

        //设置ID为preserve广告上的配置更改。
        adView.setId(MMSDK.getDefaultAdId());
        adView.getAd();


    }

    @覆盖
    公共布尔onCreateOptionsMenu(功能菜单){
        //充气菜单;这增加了项目操作栏,如果它是present。
        。getMenuInflater()膨胀(R.menu.main,菜单);
        返回true;
    }

}
 

解决方案

我觉得塔伦是对他的第一个步骤。变化:

MMAdView AD浏览报=新MMAdView(本);

MMAdView AD浏览报=(MMAdView)findViewById(R.id.adView);

和补充:

adView.getAd();

...在你活动的onCreate(...)方法的结尾(后 adView.setId(MMSDK.getDefaultAdId());

Regarding formatting the question, I tried to format it, but it doesn't show up few lines of code, I don't know why. It's happening for the second time today. Please if someone can format it, It would be great.

Quesiton -:

Android 2.3.3

I am just trying to integrate millennial media sdk into a demo app. No fancy stuff. Just simple app, to get an idea of implementing it.

Here is what I have done :::

  1. Downloaded android_5_0_0_sdk from the site.
  2. Created a project and added the MMSDK.jar file to libs
  3. Rgight click on the project, go to properties->java build path->libraries->add jars-> chose the path to the libs and MMSDK.jar

4.Added the XML code to my activity

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:mm="http://millennialmedia.com/android/schema" // this
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

    // and this
    <com.millennialmedia.android.MMAdView
        android:id="@+id/adView"
        android:layout_width="468dp"
        android:layout_height="60dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        mm:apid="123149"
        mm:height="60"
        mm:width="468" />


</RelativeLayout>

  1. This is my AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.millennialdemo"
    android:versionCode="1"
    android:versionName="1.0" >
    
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
    
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    
    <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.millennialdemo.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
    
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    
    <!-- Start of MillennialMedia.com code -->
    <activity
        android:name="com.millennialmedia.android.MMActivity"
        android:configChanges="keyboardHidden|orientation|keyboard" >
    </activity>
    <activity
        android:name="com.millennialmedia.android.VideoPlayer"
        android:configChanges="keyboardHidden|orientation|keyboard" >
    </activity>
    
    <!-- End of MillennialMedia.com code -->
    

  1. Here is my MainActivity:-

    import com.millennialmedia.android.MMAdView;
    import com.millennialmedia.android.MMInterstitial;
    import com.millennialmedia.android.MMAd;
    import com.millennialmedia.android.MMBroadcastReceiver;
    import com.millennialmedia.android.MMRequest;
    import com.millennialmedia.android.MMSDK;
    import com.millennialmedia.android.RequestListener.RequestListenerImpl;
    public class MainActivity extends Activity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        MMSDK.initialize(this);
    
        setContentView(R.layout.activity_main);
    
        MMAdView adView = new MMAdView(this);
    
        //Replace YOUR_APID with the APID provided to you by Millennial Media
        adView.setApid("123149");
    
        //Set your metadata in the MMRequest object
        MMRequest request = new MMRequest();
    
        //Add metadata here.
    
        //Add the MMRequest object to your MMAdView.
        adView.setMMRequest(request);
    
        //Sets the id to preserve your ad on configuration changes.
        adView.setId(MMSDK.getDefaultAdId());
            adView.getAd();//change suggested by Millennial Mark
    
    
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
    }
    

I think I have done whatever is told in the document but i don't get any ad and all i get is the following log in my logcat...

05-20 20:54:58.932: E/Web Console(386): ReferenceError: Can't find variable: MMJS at undefined:1
05-20 20:54:58.932: E/Web Console(386): ReferenceError: Can't find variable: MMJS at undefined:1
05-20 20:54:58.972: W/MillennialMediaSDK(386): AdView onLayout changedfalse int left 24 int top 24 int right 456 int bottom 99
05-20 20:55:00.382: D/dalvikvm(386): GC_CONCURRENT freed 1228K, 57% free 2903K/6727K, external 2002K/2137K, paused 6ms+6ms
05-20 20:55:01.172: E/MillennialMediaSDK(386): Could not get a handshake. No peer certificate
05-20 20:55:01.172: E/MillennialMediaSDK(386): Could not get a handshake. No peer certificate
05-20 20:55:01.212: D/dalvikvm(386): GC_CONCURRENT freed 826K, 58% free 2843K/6727K, external 2002K/2137K, paused 6ms+5ms

I don't understand what's going wrong. If someone can help me, it's much appreciated.

After changing this

 MMAdView adView = new MMAdView(this);

to

MMAdView adView = (MMAdView) findViewById(R.id.adView);

I still have the same problem.. here is the logcat..

05-20 21:57:26.911: I/MillennialMediaSDK(467): Initializing MMLayout.
05-20 21:57:27.631: W/MillennialMediaSDK(467): MMLayout adding view (MMWebView originally from(1) MRaidState(loading).) to AdType[(b) InternalId(1) LinkedId(0) isFinishing(false)]
05-20 21:57:27.842: W/MillennialMediaSDK(467): AdView onLayout changedtrue int left 24 int top 24 int right 456 int bottom 114
05-20 21:57:27.861: W/MillennialMediaSDK(467): Id check for parent: 1 versus 1
05-20 21:57:27.911: W/MillennialMediaSDK(467): AdView onLayout changedfalse int left 24 int top 24 int right 456 int bottom 114
05-20 21:57:28.041: E/Web Console(467): ReferenceError: Can't find variable: MMJS at undefined:1
05-20 21:57:28.051: E/Web Console(467): ReferenceError: Can't find variable: MMJS at undefined:1
05-20 21:57:28.551: W/MillennialMediaSDK(467): AdView onLayout changedfalse int left 24 int top 24 int right 456 int bottom 114
05-20 21:57:29.541: D/dalvikvm(467): GC_CONCURRENT freed 1226K, 57% free 2905K/6727K, external 2002K/2137K, paused 5ms+9ms
05-20 21:57:30.292: E/MillennialMediaSDK(467): Could not get a handshake. No peer certificate
05-20 21:57:30.301: E/MillennialMediaSDK(467): Could not get a handshake. No peer certificate
05-20 21:57:30.331: D/dalvikvm(467): GC_CONCURRENT freed 813K, 58% free 2843K/6727K, external 2002K/2137K, paused 4ms+4ms

After changing the code as suggested by Millennial Mark, I get the following errors, basically the same..

05-21 08:54:38.948: I/MillennialMediaSDK(341): Initializing MMLayout.
05-21 08:54:39.616: W/MillennialMediaSDK(341): MMLayout adding view (MMWebView originally from(1) MRaidState(loading).) to AdType[(b) InternalId(1) LinkedId(0) isFinishing(false)]
05-21 08:54:40.027: W/MillennialMediaSDK(341): AdView onLayout changedtrue int left 24 int top 24 int right 456 int bottom 99
05-21 08:54:40.055: W/MillennialMediaSDK(341): Id check for parent: 1 versus 1
05-21 08:54:40.115: W/MillennialMediaSDK(341): AdView onLayout changedfalse int left 24 int top 24 int right 456 int bottom 99
05-21 08:54:40.295: E/Web Console(341): ReferenceError: Can't find variable: MMJS at undefined:1
05-21 08:54:40.295: E/Web Console(341): ReferenceError: Can't find variable: MMJS at undefined:1
05-21 08:54:40.295: W/MillennialMediaSDK(341): AdView onLayout changedfalse int left 24 int top 24 int right 456 int bottom 99
05-21 08:54:58.139: E/MillennialMediaSDK(341): Ad request HTTP error. androidsdk.ads.mp.mydas.mobi
05-21 08:54:59.527: E/MillennialMediaSDK(341): Could not get a handshake. ads.mp.mydas.mobi
05-21 08:54:59.527: E/MillennialMediaSDK(341): Could not get a handshake. ads.mp.mydas.mobi

I have went through the answers given by Millennial Mark in other scenarios. Here is what I have done.

Rightclick on project->properties->java build path->go to order and export tab and check the checkbox of the MMSDK jar file. Now, I don't get the "handshake" error, but the "reference" error still comes up and NO AD is being displayed as well.

Here is the logcat trace

05-21 09:03:33.565: E/Web Console(341): ReferenceError: Can't find variable: MMJS at undefined:1
05-21 09:03:46.296: W/MillennialMediaSDK(341): Id check for parent: 1 versus 1
05-21 09:03:46.346: E/Web Console(341): ReferenceError: Can't find variable: MMJS at undefined:1

Modified MainActivity

package com.example.millennialdemo;

import android.os.Bundle;
import android.app.Activity;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.Menu;
import android.widget.RelativeLayout;

import com.millennialmedia.android.MMAdView;
import com.millennialmedia.android.MMInterstitial;
import com.millennialmedia.android.MMAd;
import com.millennialmedia.android.MMBroadcastReceiver;
import com.millennialmedia.android.MMRequest;
import com.millennialmedia.android.MMSDK;
import com.millennialmedia.android.RequestListener.RequestListenerImpl;


public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        MMSDK.initialize(this);

        setContentView(R.layout.activity_main);

        MMAdView adView = (MMAdView) findViewById(R.id.adView);

        //Replace YOUR_APID with the APID provided to you by Millennial Media
        adView.setApid("123149");

        //Set your metadata in the MMRequest object
        MMRequest request = new MMRequest();

        //Add metadata here.

        //Add the MMRequest object to your MMAdView.
        adView.setMMRequest(request);

        //Sets the id to preserve your ad on configuration changes.
        adView.setId(MMSDK.getDefaultAdId());
        adView.getAd();


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

解决方案

I think Tarun was right in his first step. Change:

MMAdView adView = new MMAdView(this);

to

MMAdView adView = (MMAdView)findViewById(R.id.adView);

and add:

adView.getAd();

...at the end of your Activity's onCreate(...) method ( after adView.setId(MMSDK.getDefaultAdId()); ).

这篇关于整合千年媒体SDK 5.0的Andr​​oid应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆