问题描述
我很好奇如何在mopub点击广告时加载的WebView。默认情况下,广告打开浏览器。目前在这个非常小的文件,我一直没能找到任何的例子。
我实例,我发现在mopub API,因为它看起来像它应该做我想做的,但无济于事AD浏览报班。我真不知道如何从浏览器切换广告点击的WebView。
此外,getClickThroughUrl()返回null。 Mopub是存储URL,但因为该页面在浏览器中打开。那么,如何正确地检索该网址是什么?
下面是我的code:
mAdView.setAdUnitId(MOPUB_SALES_LIST_ID);
mAdView.loadAd();
mAdView.setOnAdLoadedListener(新OnAdLoadedListener(){
公共无效OnAdLoaded(MoPubView MPV){
adPopupLayout.setVisibility(View.VISIBLE);
}
});
mAdView.setOnAdClickedListener(新OnAdClickedListener(){
@覆盖
公共无效OnAdClicked(MoPubView M){
AD浏览报AD浏览报=新的AD浏览报(getApplicationContext(),mAdView);
adview.loadUrl(m.getClickthroughUrl());
}
});
这是不是很容易。你将不得不做出改变mopub SDK。
在 AD浏览报班,您需要更改 showBrowserForUrl()
来加载web视图,而不是浏览器。
I am curious how to load a webview when clicking on a mopub ad. By default the ad is opening a browser. There is very little documentation on this and I haven't been able to find any examples.
I instantiate the AdView class that I found in the mopub api as it seems like it should do what I want but to no avail. And I'm still not sure how to switch the ad click from browser to webview.
Also, getClickThroughUrl() returns null. Mopub is storing the url though because the page opens in a browser. So how do I properly retrieve the URL?
Here's my code:
mAdView.setAdUnitId(MOPUB_SALES_LIST_ID);
mAdView.loadAd();
mAdView.setOnAdLoadedListener(new OnAdLoadedListener() {
public void OnAdLoaded(MoPubView mpv) {
adPopupLayout.setVisibility(View.VISIBLE);
}
});
mAdView.setOnAdClickedListener(new OnAdClickedListener() {
@Override
public void OnAdClicked(MoPubView m) {
AdView adview = new AdView(getApplicationContext(), mAdView);
adview.loadUrl(m.getClickthroughUrl());
}
});
This is not very easy. You will have to make changes in the mopub SDK.
In the AdView class, you need to change the showBrowserForUrl()
to load a webview instead of browser.
这篇关于安卓:需要Mopub广告打开web视图中单击时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!