发行与PhoneGap的和MillennialMedia [英] Issue with Phonegap and MillennialMedia

查看:123
本文介绍了发行与PhoneGap的和MillennialMedia的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用MillenialMedia我PhoneGap的应用程序,但我就是不能使它工作。
我上LogCat中以下错误:

I'm trying to use MillenialMedia on my Phonegap app, but i just can't make it work. I get the following errors on the LogCat:

12月8日至12日:52:36.755:I / MillennialMediaSDK(333):初始化MMLayout结果
十二月8日至12日:52:37.385:W / MillennialMediaSDK(333):MMLayout(从(1)MRaidState(装载)MMWebView原)至ADTYPE [(B)InternalId(1)LinkedId(0)isFinishing添加视图(假) ]结果
十二月8日至12日:52:37.645:W / MillennialMediaSDK(333):AdView的onLayout changedtrue INT左边的0 INT顶部687 INT权480 INT底部762结果
十二月8日至12日:52:37.685:W / MillennialMediaSDK(333):ID检查父:1对1结果
十二月8日至12日:52:38.355:I / MillennialMediaSDK(333):Millennial广告回报失败。零内容长度返回。结果
十二月8日至12日:52:38.965:E / MillennialMediaSDK(333):无法获取握手。不被信任的服务器证书

08-12 12:52:36.755: I/MillennialMediaSDK(333): Initializing MMLayout.
08-12 12:52:37.385: W/MillennialMediaSDK(333): MMLayout adding view (MMWebView originally from(1) MRaidState(loading).) to AdType[(b) InternalId(1) LinkedId(0) isFinishing(false)]
08-12 12:52:37.645: W/MillennialMediaSDK(333): AdView onLayout changedtrue int left 0 int top 687 int right 480 int bottom 762
08-12 12:52:37.685: W/MillennialMediaSDK(333): Id check for parent: 1 versus 1
08-12 12:52:38.355: I/MillennialMediaSDK(333): Millennial ad return failed. Zero content length returned.
08-12 12:52:38.965: E/MillennialMediaSDK(333): Could not get a handshake. Not trusted server certificate

下面是我的code:

/*
       Licensed to the Apache Software Foundation (ASF) under one
       or more contributor license agreements.  See the NOTICE file
       distributed with this work for additional information
       regarding copyright ownership.  The ASF licenses this file
       to you under the Apache License, Version 2.0 (the
       "License"); you may not use this file except in compliance
       with the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

       Unless required by applicable law or agreed to in writing,
       software distributed under the License is distributed on an
       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
       KIND, either express or implied.  See the License for the
       specific language governing permissions and limitations
       under the License.
 */

package com.logicstudio.paradise.Replay;

import android.os.Bundle;
import org.apache.cordova.*;
import android.os.Handler;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class Replay extends DroidGap
{
    //Constants for tablet sized ads (728x90)
    private static final int IAB_LEADERBOARD_WIDTH = 728;
    private static final int IAB_LEADERBOARD_HEIGHT = 90;

    private static final int MED_BANNER_WIDTH = 480;
    private static final int MED_BANNER_HEIGHT = 60;

    //Constants for phone sized ads (320x50)
    private static final int BANNER_AD_WIDTH = 320;
    private static final int BANNER_AD_HEIGHT = 50;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        super.setIntegerProperty("splashscreen", R.drawable.splash);
        super.loadUrl(Config.getStartUrl());

        int placementWidth = BANNER_AD_WIDTH;
        int placementHeight = BANNER_AD_HEIGHT;

        //Finds an ad that best fits a users device.
        if(canFit(IAB_LEADERBOARD_WIDTH)) {
            placementWidth = IAB_LEADERBOARD_WIDTH;
            placementHeight = IAB_LEADERBOARD_HEIGHT;
        }
        else if(canFit(MED_BANNER_WIDTH)) {
            placementWidth = MED_BANNER_WIDTH;
            placementHeight = MED_BANNER_HEIGHT;
        }


        com.millennialmedia.android.MMSDK.initialize(this);

        com.millennialmedia.android.MMAdView adView = new com.millennialmedia.android.MMAdView(this);

        LinearLayout layout = super.root;

        adView.setApid("131468");

        //Set your metadata in the MMRequest object
        com.millennialmedia.android.MMRequest request = new com.millennialmedia.android.MMRequest();

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

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

        //Set the ad size. Replace the width and height values if needed.
        adView.setWidth(placementWidth);
        adView.setHeight(placementHeight);

        //Calculate the size of the adView based on the ad size. Replace the width and height values if needed.
        int layoutWidth = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, placementWidth, getResources().getDisplayMetrics());
        int layoutHeight = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, placementHeight, getResources().getDisplayMetrics());

        //Create the layout parameters using the calculated adView width and height.
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(layoutWidth, layoutHeight);

        //This positions the banner.
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);

        adView.setLayoutParams(layoutParams);

        //Add the adView to the layout. The layout is assumed to be a RelativeLayout.
        layout.addView(adView);

        adView.getAd();
    }

    protected boolean canFit(int adWidth) {
        int adWidthPx = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, adWidth, getResources().getDisplayMetrics());
        DisplayMetrics metrics = this.getResources().getDisplayMetrics();
        return metrics.widthPixels >= adWidthPx;
    }
}

任何帮助将大大AP preciated。
在此先感谢!

Any help will be greatly appreciated. Thanks in advance!

推荐答案

PhoneGap的工作方式是投掷HTML / CSS / JS到一个特殊的WebView(CordovaWebView),这是在整个屏幕上运行。在code控制此默认行为,他们的生活类DroidApp里面。

PhoneGap works by throwing HTML/CSS/JS into a special WebView (CordovaWebView), which is running on the entire screen. The code that controls this default behavior lives inside their DroidApp class.

要获得千禧年广告工作(或任何标准的Andr​​oid控件,对于这个问题),你必须创建一个扩展android.app.Activity(而不是DroidApp)一类和活动中嵌入您的CordovaWebView。这CordovaWebView将处理所有应用的PhoneGap的相关资产的同时,你的活动及其相应的布局可以处理你的Andr​​oid特有的类(比如千禧年的MMAdView)。

To get Millennial ads to work (or any standard Android controls, for that matter), you have to create a class that extends android.app.Activity (rather than DroidApp) and embed your CordovaWebView within that activity. That CordovaWebView will handle all of your app's Phonegap-related assets while your activity and its corresponding layout can handle your Android-specific classes (like Millennial's MMAdView).

要获取的PhoneGap是如何工作在Android上有更深的了解,我强烈建议在这里阅读他们的文档:的 http://cordova.apache.org/docs/en/2.7.0/guide_cordova-webview_android.md.html

To get a deeper understanding of how PhoneGap works on Android, I strongly recommend reading their docs here: http://cordova.apache.org/docs/en/2.7.0/guide_cordova-webview_android.md.html

要获得更多关于如何具体得到千年的SDK在该环境中工作,跟这里的乡亲们的支持: https://tool​​s.mmedia.com/user/supportDevPortal

To get more on how to specifically get Millennial's SDK working in that environment, talk to the support folks here: https://tools.mmedia.com/user/supportDevPortal

这篇关于发行与PhoneGap的和MillennialMedia的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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