我正在使用Facebook Audience Network并根据这篇文章
我没有缓存广告,但广告在屏幕上停留而没有刷新.我正在加载所有广告,他们会一直在屏幕上,直到用户关闭应用.
private void initializeAds() {
//ENABLE TESTING MODE
if (BuildConfig.DEBUG) {
AdSettings.addTestDevice("alksdfj");//For testing ads
}
//NATIVE AD
nativeAd = new NativeAd(this, "alksdjf");
nativeAd.setAdListener(new AdListener() {
@Override
public void onError(Ad ad, AdError adError) {
}
@Override
public void onAdLoaded(Ad ad) {
// Render the Native Ad Template
View adView = NativeAdView.render(MainActivity.this, nativeAd, NativeAdView.Type.HEIGHT_120);
LinearLayout nativeAdContainer = (LinearLayout) findViewById(R.id.native_ad_container);
// Add the Native Ad View to your ad container
nativeAdContainer.addView(adView);
}
@Override
public void onAdClicked(Ad ad) {
} …Run Code Online (Sandbox Code Playgroud) I am trying to add Firebase crashlytics to an existing project (not developed by me). I keep getting the error
ERROR: Could not find com.google.gms.google-services:4.2.0:.
Required by:
project :
Search in build.gradle files
Run Code Online (Sandbox Code Playgroud)
I have gone through all (or most ) of the solution that asks to add maven { url 'https://maven.google.com' } and none of them work. I am getting the above error for all the solution.
Please not other projects that i have developed are working …
我需要获取android锁屏活动的包名.我用google搜索除了/sf/answers/1181674511/之外什么都没找到,这似乎不起作用.
有没有办法获得锁屏包名称
我正在尝试在我的应用中放置广告.根据Admob 文档,我必须初始化移动广告SDK
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
Run Code Online (Sandbox Code Playgroud)
这会导致代码中高ram使用率的飙升.
但是,如果我删除此行,则ram使用率下降&且这行代码似乎对应用内部的服务器广告没有任何影响.
此外,当从admob ram使用请求广告再次飙升并在应用启动时导致3-4个GC事件.我相信这是内存泄漏.
这是我在
onCreate方法中请求广告的方式
AdRequest request = null;
if (BuildConfig.DEBUG) {
//Facebook Audience Network
List<String> testDeviceId = new ArrayList<>();
testDeviceId.add("TESTID");//Redmi Note 3
testDeviceId.add("TESTID");//Moto G 1st Gen
AdSettings.addTestDevices(testDeviceId);
//Google Ad-mob
request = new AdRequest.Builder()
.addTestDevice("TESTID")//Redmi Note 3
.addTestDevice("TESTID")//Mot G 1st Gen
.build();
} else {
request = new AdRequest.Builder()
.build();
}
AdView mAdView = findViewById(R.id.adView);
mAdView.loadAd(request);
Run Code Online (Sandbox Code Playgroud)
加载此横幅广告时,会启动多个GC事件.如果我不加载广告,则GC事件永远不会被踢入.
这种行为与admob一样正常吗?我该如何解决这个问题?
我有一个画布,我试图通过JavaScript获得高度,但它返回半高,然后返回实际高度
这是我正在使用的简单代码
var canvas = document.getElementById("clock");
var context = canvas.getContext("2d");
document.getElementById("status").innerHTML = canvas.height;
console.log(canvas.height);Run Code Online (Sandbox Code Playgroud)
canvas#clock{
width:300px;
height:300px;
border:#D50003 1px solid;
background:#1E1E1E;
}Run Code Online (Sandbox Code Playgroud)
<canvas id="clock"></canvas>
<div id="status"></div>Run Code Online (Sandbox Code Playgroud)
我正在使用OkHttp库来进行多部分数据,一切都很好我没有任何错误但是当我编译程序时它会给我错误
错误:(172,40)错误:无法访问未找到okio.ByteString的ByteString类文件
这里发生错误 RequestBody.create(MEDIA_TYPE_JPG, new File(data.getFileParam())))
这是实现多部分请求的整个方法代码
public static String makeRequest(RequestConstructor data, String a, String b) {
final MediaType MEDIA_TYPE_JPG = MediaType.parse("image/jpg");
try {
OkHttpClient client = new OkHttpClient();
Log.d("test",data.getFileParam());
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("bunting", data.getParam("bunting"))
.addFormDataPart("dangler", data.getParam("dangler"))
.addFormDataPart("poster", data.getParam("poster"))
.addFormDataPart("tearPad", data.getParam("tearPad"))
.addFormDataPart("leafLet", data.getParam("leafLet"))
.addFormDataPart("outlet_category", "")
.addFormDataPart("dealerName", data.getParam("dealerName"))
.addFormDataPart("brouchers", data.getParam("brouchers"))
.addFormDataPart("wobblers", data.getParam("wobblers"))
.addFormDataPart("tentCard", data.getParam("tentCard"))
.addFormDataPart("others", data.getParam("others"))
.addFormDataPart("photo", "1.jpg",
RequestBody.create(MEDIA_TYPE_JPG, new File(data.getFileParam())))
.build();
Request request = new Request.Builder()
.url(data.getUrl())
.post(requestBody)
.build();
Response response = client.newCall(request).execute();
if (!response.isSuccessful()) throw new …Run Code Online (Sandbox Code Playgroud) 我有点想做一台老虎机.要创建老虎机影响我从包装器中删除第一个div并将其添加回底部.当我使用值时,onClick事件工作正常,1000ms但当我使用像100msinterval这样的东西时,我需要快速点击多次以便注册点击事件.为什么会这样?
另外在触摸屏上(在我的手机上查看)我没有遇到这个问题.
setInterval(function() {
swap_box();
}, 100);
function swap_box() {
let first_box = document.getElementsByClassName("box")[0];
first_box.remove();
document.getElementsByClassName("div-wrapper")[0].appendChild(first_box);
first_box.addEventListener("click", function() {
console.log(this.innerText);
});
}Run Code Online (Sandbox Code Playgroud)
.box {
width: 100px;
height: 50px;
border: 1px solid black;
}Run Code Online (Sandbox Code Playgroud)
<div class="div-wrapper">
<div class="box">0</div>
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">7</div>
</div>Run Code Online (Sandbox Code Playgroud)
android ×5
html ×2
javascript ×2
admob ×1
facebook ×1
firebase ×1
google-admob ×1
height ×1
java ×1
lockscreen ×1
memory-leaks ×1
okhttp3 ×1
package-name ×1