gpt4 book ai didi

java - 多媒体整合问题

转载 作者:行者123 更新时间:2023-12-01 13:16:19 26 4
gpt4 key购买 nike

我已经通过电子邮件与他们的技术支持来回发送了一个多星期,但他们似乎无法弄清楚发生了什么......

我是一名新开发人员,所以我制作了一个非常简单的应用程序来引导我自己完成基础知识,包括集成广告公司(我选择了 mmedia)

问题是:

通过他们的网站,我可以看到正在发送和接收广告请求,并且该公司已确认这一点,但是当您打开应用程序本身时,您会看到一个空间,其中横幅应该显示其调用的广告,但什么也没有发生了

非常感谢任何帮助

Logcat 错误“未处理的事件循环异常”

03-12 19:31:23.361: D/dalvikvm(266): Trying to load lib /data/data/com.loudest.airhornextreme/lib/libnmsp_speex.so 0x45f3dc30
03-12 19:31:23.373: D/dalvikvm(266): Added shared lib /data/data/com.loudest.airhornextreme/lib/libnmsp_speex.so 0x45f3dc30
03-12 19:31:23.391: D/dalvikvm(266): No JNI_OnLoad found in /data/data/com.loudest.airhornextreme/lib/libnmsp_speex.so 0x45f3dc30, skipping init
03-12 19:31:24.352: I/MillennialMediaSDK(266): Initializing MMLayout.
03-12 19:31:25.043: D/dalvikvm(266): GC_FOR_MALLOC freed 5029 objects / 300200 bytes in 158ms
03-12 19:31:25.822: W/MillennialMediaSDK(266): MMLayout adding view (MMWebView originally from(1) MRaidState(loading).com.millennialmedia.android.MMWebView@45fa9950) to AdType[(b) InternalId(1) LinkedId(0) isFinishing(false)]
03-12 19:31:25.852: I/MillennialMediaSDK(266): Initializing MMLayout.
03-12 19:31:26.042: D/dalvikvm(266): GC_FOR_MALLOC freed 5307 objects / 266960 bytes in 181ms
03-12 19:31:26.201: I/MillennialMediaSDK(266): A request is already in progress.
03-12 19:31:26.412: W/MillennialMediaSDK(266): MMLayout adding view (MMWebView originally from(2) MRaidState(loading).com.millennialmedia.android.MMWebView@45f36248) to AdType[(b) InternalId(2) LinkedId(0) isFinishing(false)]
03-12 19:31:28.511: D/dalvikvm(266): GC_FOR_MALLOC freed 4020 objects / 397408 bytes in 727ms
03-12 19:31:28.521: W/MillennialMediaSDK(266): @@@ SENDING IT!!!@@@@@ adSize ! {"height":0,"width":0,"x":0,"y":50}
03-12 19:31:28.571: W/MillennialMediaSDK(266): Id check for parent: 2 versus 2
03-12 19:31:29.062: E/Web Console(266): ReferenceError: Can't find variable: MMJS at undefined:1
03-12 19:31:29.062: E/Web Console(266): ReferenceError: Can't find variable: MMJS at undefined:1
03-12 19:31:29.672: D/dalvikvm(266): GC_FOR_MALLOC freed 4494 objects / 277928 bytes in 162ms
03-12 19:31:29.942: D/dalvikvm(266): GC_FOR_MALLOC freed 1276 objects / 75352 bytes in 149ms
03-12 19:31:29.972: W/System.err(266): org.json.JSONException: End of input at character 0 of
03-12 19:31:29.982: W/System.err(266): at org.json.JSONTokener.syntaxError(JSONTokener.java:446)
03-12 19:31:30.052: W/System.err(266): at org.json.JSONTokener.nextValue(JSONTokener.java:93)
03-12 19:31:30.052: W/System.err(266): at org.json.JSONObject.<init>(JSONObject.java:154)
03-12 19:31:30.052: W/System.err(266): at org.json.JSONObject.<init>(JSONObject.java:171)
03-12 19:31:30.052: W/System.err(266): at com.millennialmedia.android.HandShake.parseJson(HandShake.java:615)
03-12 19:31:30.052: W/System.err(266): at com.millennialmedia.android.HandShake.access$400(HandShake.java:39)
03-12 19:31:30.052: W/System.err(266): at com.millennialmedia.android.HandShake$1.run(HandShake.java:337)
03-12 19:31:30.062: W/System.err(266): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
03-12 19:31:30.071: W/System.err(266): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
03-12 19:31:30.071: W/System.err(266): at java.lang.Thread.run(Thread.java:1096)
03-12 19:31:30.391: W/MillennialMediaSDK(266): MMJS - same URL
03-12 19:31:30.391: W/MillennialMediaSDK(266): Not downloading MMJS - (http://cdn.millennialmedia.com/mmjs/v1.4/mm.js)
03-12 19:31:31.932: E/Web Console(266): TypeError: Result of expression 'window.interface' [undefined] is not an object. at http://ads.mp.mydas.mobi/:1
03-12 19:31:31.992: W/webcore(266): Can't get the viewWidth after the first layout
03-12 19:31:32.212: D/dalvikvm(266): GC_FOR_MALLOC freed 4874 objects / 440896 bytes in 83ms
03-12 19:31:32.231: D/NativeCrypto(266): Freeing OpenSSL session
03-12 19:31:32.281: I/Web Console(266): setAdProperties: {"permissions":{"android.permission.ACCESS_FINE_LOCATION":true},"device":{"platform":"Android","connection":"umts","mmisdk":"5.1.0-13.08.12.a","height":854,"density":1.5,"mmdid":"mmh_CF95DC53F383F9A836FD749F3EF439CD_41E29575C7361B2924F701502CA6D932B45B9E51","width":480,"device":"sdk","language":"en","cookies":[{"path":"/","name":"MAC-ID"}],"country":"US","version":"2.2","sdkVersion":"5.1.0-13.08.12.a"},"ad":{"width":"0","height":"0"},"screen":{"width":"320","height":"569"},"supports":{"inlineVideo":"true","sms":"false","storePicture":"false","calendar":"false","tel":"false"},"do":"portrait","maxSize":{"width":"320","height":"569"}} at file:///data/data/com.loudest.airhornextreme/files/.mmsyscache/mraid.js:221
03-12 19:31:32.361: I/Web Console(266): MRAID state change from "loading" to "default" at file:///data/data/com.loudest.airhornextreme/files/.mmsyscache/mraid.js:221
03-12 19:31:32.381: I/Web Console(266): event callback: stateChange at file:///data/data/com.loudest.airhornextreme/files/.mmsyscache/mraid.js:221
03-12 19:31:32.391: I/Web Console(266): MRAID ready. at file:///data/data/com.loudest.airhornextreme/files/.mmsyscache/mraid.js:221
03-12 19:31:32.391: I/Web Console(266): event callback: ready at file:///data/data/com.loudest.airhornextreme/files/.mmsyscache/mraid.js:221
03-12 19:31:47.011: D/dalvikvm(320): Trying to load lib /data/data/com.loudest.airhornextreme/lib/libnmsp_speex.so 0x45f3dbd8
03-12 19:31:47.021: D/dalvikvm(320): Added shared lib /data/data/com.loudest.airhornextreme/lib/libnmsp_speex.so 0x45f3dbd8
03-12 19:31:47.021: D/dalvikvm(320): No JNI_OnLoad found in /data/data/com.loudest.airhornextreme/lib/libnmsp_speex.so 0x45f3dbd8, skipping init
03-12 19:31:47.332: I/MillennialMediaSDK(320): Initializing MMLayout.
03-12 19:31:47.542: D/dalvikvm(320): GC_FOR_MALLOC freed 4275 objects / 268528 bytes in 84ms
03-12 19:31:48.022: W/MillennialMediaSDK(320): MMLayout adding view (MMWebView originally from(1) MRaidState(loading).com.millennialmedia.android.MMWebView@45f8d4e0) to AdType[(b) InternalId(1) LinkedId(0) isFinishing(false)]
03-12 19:31:48.091: I/MillennialMediaSDK(320): Initializing MMLayout.
03-12 19:31:48.172: I/MillennialMediaSDK(320): A request is already in progress.
03-12 19:31:48.332: D/dalvikvm(320): GC_FOR_MALLOC freed 5133 objects / 259400 bytes in 117ms
03-12 19:31:48.841: W/MillennialMediaSDK(320): MMLayout adding view (MMWebView originally from(2) MRaidState(loading).com.millennialmedia.android.MMWebView@45f36130) to AdType[(b) InternalId(2) LinkedId(0) isFinishing(false)]
03-12 19:31:50.022: W/MillennialMediaSDK(320): @@@ SENDING IT!!!@@@@@ adSize ! {"height":0,"width":0,"x":0,"y":480}
03-12 19:31:50.052: W/MillennialMediaSDK(320): Id check for parent: 2 versus 2
03-12 19:31:50.302: D/dalvikvm(320): GC_FOR_MALLOC freed 5527 objects / 499848 bytes in 73ms
03-12 19:31:50.352: E/Web Console(320): ReferenceError: Can't find variable: MMJS at undefined:1
03-12 19:31:50.352: E/Web Console(320): ReferenceError: Can't find variable: MMJS at undefined:1
03-12 19:31:50.691: D/dalvikvm(320): GC_FOR_MALLOC freed 472 objects / 28000 bytes in 329ms
03-12 19:31:50.962: D/dalvikvm(320): GC_FOR_MALLOC freed 1379 objects / 74616 bytes in 88ms
03-12 19:31:50.962: I/dalvikvm-heap(320): Grow heap (frag case) to 3.336MB for 87396-byte allocation
03-12 19:31:51.063: D/dalvikvm(320): GC_FOR_MALLOC freed 234 objects / 16808 bytes in 103ms
03-12 19:31:51.142: D/dalvikvm(320): GC_FOR_MALLOC freed 989 objects / 45056 bytes in 72ms
03-12 19:31:51.352: W/MillennialMediaSDK(320): MMJS - same URL
03-12 19:31:51.352: W/MillennialMediaSDK(320): Not downloading MMJS - (http://cdn.millennialmedia.com/mmjs/v1.4/mm.js)
03-12 19:31:51.531: D/dalvikvm(320): GC_FOR_MALLOC freed 3914 objects / 248624 bytes in 70ms
03-12 19:31:52.062: E/Web Console(320): TypeError: Result of expression 'window.interface' [undefined] is not an object. at http://ads.mp.mydas.mobi/:1
03-12 19:31:52.082: W/webcore(320): Can't get the viewWidth after the first layout
03-12 19:31:52.222: I/Web Console(320): setAdProperties: {"permissions":{"android.permission.ACCESS_FINE_LOCATION":true},"device":{"platform":"Android","connection":"umts","mmisdk":"5.1.0-13.08.12.a","height":854,"density":1.5,"mmdid":"mmh_CF95DC53F383F9A836FD749F3EF439CD_41E29575C7361B2924F701502CA6D932B45B9E51","width":480,"device":"sdk","language":"en","cookies":[{"path":"/","name":"MAC-ID"}],"country":"US","version":"2.2","sdkVersion":"5.1.0-13.08.12.a"},"ad":{"width":"0","height":"0"},"screen":{"width":"320","height":"569"},"supports":{"inlineVideo":"true","sms":"false","storePicture":"false","calendar":"false","tel":"false"},"do":"portrait","maxSize":{"width":"320","height":"569"}} at file:///data/data/com.loudest.airhornextreme/files/.mmsyscache/mraid.js:221
03-12 19:31:52.242: I/Web Console(320): MRAID state change from "loading" to "default" at file:///data/data/com.loudest.airhornextreme/files/.mmsyscache/mraid.js:221
03-12 19:31:52.242: I/Web Console(320): event callback: stateChange at file:///data/data/com.loudest.airhornextreme/files/.mmsyscache/mraid.js:221
03-12 19:31:52.252: I/Web Console(320): MRAID ready. at file:///data/data/com.loudest.airhornextreme/files/.mmsyscache/mraid.js:221
03-12 19:31:52.252: I/Web Console(320): event callback: ready at file:///data/data/com.loudest.airhornextreme/files/.mmsyscache/mraid.js:221
03-12 19:33:10.521: D/dalvikvm(320): GC_FOR_MALLOC freed 15996 objects / 732152 bytes in 81ms
03-12 19:35:08.252: D/dalvikvm(320): GC_FOR_MALLOC freed 21998 objects / 717432 bytes in 77ms
03-12 19:37:06.082: D/dalvikvm(320): GC_FOR_MALLOC freed 21763

70 毫秒内对象/524272 字节

对于我的代码,

list :

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.loudest.airhornextreme"
android:versionCode="102"
android:versionName="1.2" >

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<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" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="Air Horn Extreme"
android:theme="@style/AppTheme" >

<activity
android:name=".Splash"
android:label="@string/title_activity_airhornextreme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.loudest.airhornextreme.Soundboard"
android:label="@string/title_activity_airhornextreme" >
<intent-filter>
<action android:name="com.loudest.airhornextreme.STARTINGPOINT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.millennialmedia.android.MMActivity"
android:configChanges="keyboardHidden|orientation|keyboard"
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
</activity>
<service
android:name="com.loudest.airhornextreme.LocationObject"
android:enabled="true"
android:exported="true" >
</service>
</application>

</manifest>

**Layout**

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mm="http://millennialmedia.com/android/schema"
xmlns:app="http://schemas.android.com/apk/res/com.loudest.airhornextreme"
android:id="@+id/tablelayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >



<Button
android:id="@+id/sound1"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:text="CLEAN HORN" >
</Button>

<Button
android:id="@+id/sound3"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:text="ECHO HORN" />

<Button
android:id="@+id/sound2"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:text="HIGH HORN" >
</Button>

<Button
android:id="@+id/sound4"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:text="LOUDEST HORN" >
</Button>

<Button
android:id="@+id/sound5"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:text="LOW HORN" >
</Button>

<Button
android:id="@+id/sound6"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:text="REVERB HORN" >
</Button>




<com.millennialmedia.android.MMAdView
android:id="@+id/adView"
android:layout_width="320dp"
android:layout_height="50dp"
mm:apid="153971"
mm:height="match_parent"
mm:width="match_parent" />


</TableLayout>


**MAIN JAVA**

package com.loudest.airhornextreme;

import com.loudest.airhornextreme.R;

import com.loudest.airhornextreme.SoundManager;
import com.millennialmedia.android.MMAdView;
import com.millennialmedia.android.MMRequest;
import com.millennialmedia.android.MMSDK;
import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import android.widget.RelativeLayout;


public class Soundboard extends Activity {



private SoundManager mSoundManager;

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;
}

//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;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);



{

MMSDK.initialize(this);
}

setContentView(R.layout.activity_soundboardtest);

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

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

//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();

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;
}

//screenwake

getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);


super.onCreate(savedInstanceState);
setContentView(R.layout.activity_soundboardtest);

//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);


adView.getAd();

mSoundManager = new SoundManager();
mSoundManager.initSounds(getBaseContext());
mSoundManager.addSound(1, R.raw.sound1);
mSoundManager.addSound(2, R.raw.sound2);
mSoundManager.addSound(3, R.raw.sound3);
mSoundManager.addSound(4, R.raw.sound4);
mSoundManager.addSound(5, R.raw.sound5);
mSoundManager.addSound(6, R.raw.sound6);


Button SoundButton1 = (Button)findViewById(R.id.sound1);
SoundButton1.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
mSoundManager.playSound(1);

}
});
Button SoundButton2 = (Button)findViewById(R.id.sound2);
SoundButton2.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
mSoundManager.playSound(2);

}
});
Button SoundButton3 = (Button)findViewById(R.id.sound3);
SoundButton3.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
mSoundManager.playSound(3);

}
});
Button SoundButton4 = (Button)findViewById(R.id.sound4);
SoundButton4.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
mSoundManager.playSound(4);

}
});
Button SoundButton5 = (Button)findViewById(R.id.sound5);
SoundButton5.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
mSoundManager.playSound(5);

}
});
Button SoundButton6 = (Button)findViewById(R.id.sound6);
SoundButton6.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
mSoundManager.playSound(6);

}
});



}
}

最佳答案

我认为这里的问题是你的代码中出现了两次:

        super.onCreate(savedInstanceState);
setContentView(R.layout.activity_soundboardtest);

它应该只出现在 Activity 的 onCreate(...) 方法的最开始处。泄露它的东西在你的 logcat 中:

        03-12 19:31:26.201: I/MillennialMediaSDK(266): A request is already in progress.

我已将您的代码粘贴到 Eclipse 项目中,删除了上述两行的第二个实例,并使所有内容正确显示。发生的情况是这样的:主要 Activity 是使用 MMAdView 创建的,然后删除 MMAdView 的旧实例,创建一个新实例(通常由于广告 SDK 的异步特性而失败),并添加声音按钮到新的布局。

如果我们缺少任何内容,请更新您已提交给我们的票证!

关于java - 多媒体整合问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22438483/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com