Я пытаюсь использовать MillenialMedia в приложении Phonegap, но я просто не могу заставить ее работать. Я получаю следующие ошибки в LogCat:Проблема с Phonegap и MillennialMedia
08-12 12: 52: 36.755: I/MillennialMediaSDK (333): Инициализация MMLayout.
08-12 12: 52: 37.385: W/MillennialMediaSDK (333): MMLayout добавление вида (MMWebView изначально (1) MRaidState (загрузка).) В 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): Проверка идентификатора для родителя: 1 по сравнению с 1
08-12 12: 52: 38.355: I/MillennialMediaSDK (333): Не удалось вернуть объявление в течение многолетнего объявления. Возвращается нулевая длина содержимого.
08-12 12: 52: 38.965: E/MillennialMediaSDK (333): Не удалось получить рукопожатие. Не доверенный сертификат сервера
Вот мой код:
/*
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;
}
}
Любая помощь будет принята с благодарностью. Спасибо заранее!