Java 来自AdMob的意外数据存储。
我已将admob广告添加到我的应用程序中。之后,我的应用程序的大小在增加。我已经在设置应用程序MyApp(存储数据,而不是缓存)中进行了检查。我很担心,它会一直增加直到手机没有可用内存还是这个尺寸有限制(多大) 编辑:Java 来自AdMob的意外数据存储。,java,android,memory,admob,storage,Java,Android,Memory,Admob,Storage,我已将admob广告添加到我的应用程序中。之后,我的应用程序的大小在增加。我已经在设置应用程序MyApp(存储数据,而不是缓存)中进行了检查。我很担心,它会一直增加直到手机没有可用内存还是这个尺寸有限制(多大) 编辑: import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.AdView; import android.support.v7.app.ActionBarActi
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.GridLayout;
import android.support.v4.app.Fragment;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.GridLayout.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.os.Build;
public class Failed extends Activity {
LinearLayout myL;
Button mB;
int checker=0;
int modeChecker=0;
int level=0;
AdView adView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.failed);
myL = (LinearLayout) findViewById(R.id.layoutFail);
adView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
Display display = getWindowManager().getDefaultDisplay();
int screenheight = display.getHeight();
if(screenheight>400){
myL.setPadding(0, 50, 0, 0);
}
if(screenheight>800){
myL.setPadding(0, 100, 0, 0);
}
if(screenheight>1000){
myL.setPadding(0, 250, 0, 0);
}
checker = getIntent().getExtras().getInt("type");
modeChecker = getIntent().getExtras().getInt("modeCheck");
level = getIntent().getExtras().getInt("level");
}
@Override
public void onBackPressed() {
}
public void tryAgain(View v){
if(level==1){
Intent intent = new Intent(Failed.this,FruitTwoTwo.class);
intent.putExtra("check", checker);
intent.putExtra("modeCheck", modeChecker);
startActivity(intent);
}
if(level==2){
Intent intent = new Intent(Failed.this,MainActivity.class);
intent.putExtra("check", checker);
intent.putExtra("modeCheck", modeChecker);
startActivity(intent);
}
if(level==3){
Intent intent = new Intent(Failed.this,FourFour.class);
intent.putExtra("check", checker);
intent.putExtra("modeCheck", modeChecker);
startActivity(intent);
}
if(level==4){
Intent intent = new Intent(Failed.this,FourFive.class);
intent.putExtra("check", checker);
intent.putExtra("modeCheck", modeChecker);
startActivity(intent);
}
if(level==5){
Intent intent = new Intent(Failed.this,MainActivityPlus.class);
intent.putExtra("check", checker);
intent.putExtra("modeCheck", modeChecker);
startActivity(intent);
}
if(level==6){
Intent intent = new Intent(Failed.this,SixSix.class);
intent.putExtra("check", checker);
intent.putExtra("modeCheck", modeChecker);
startActivity(intent);
}
if(level==7){
Intent intent = new Intent(Failed.this,SevenSix.class);
intent.putExtra("check", checker);
intent.putExtra("modeCheck", modeChecker);
startActivity(intent);
}
if(level==8){
Intent intent = new Intent(Failed.this,SevenE.class);
intent.putExtra("check", checker);
intent.putExtra("modeCheck", modeChecker);
startActivity(intent);
}
if(level==9){
Intent intent = new Intent(Failed.this,EightE.class);
intent.putExtra("check", checker);
intent.putExtra("modeCheck", modeChecker);
startActivity(intent);
}
finish();
adView.destroy();
}
public void goBack(View v){
Intent intent = new Intent(Failed.this,MenuActivity.class);
intent.putExtra("type", checker);
startActivity(intent);
adView.destroy();
finish();
}
@Override
public void onResume() {
super.onResume();
if (adView != null) {
adView.resume();
}
}
@Override
public void onPause() {
if (adView != null) {
adView.pause();
}
super.onPause();
}
/** Called before the activity is destroyed. */
@Override
public void onDestroy() {
// Destroy the AdView.
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
}
和xml文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.testlogo.MyDialog"
android:background="@drawable/greenbackt"
android:orientation="vertical"
android:id="@+id/layoutFail"
>
<ImageView
android:id="@+id/failLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/failed"
android:layout_gravity="center"
android:paddingTop="20dp" />
<Button
android:id="@+id/fail"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:layout_marginTop="27dp"
android:onClick="tryAgain"
android:layout_gravity="center"
android:text="@string/tryagain"
android:background="@drawable/button" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/line" />
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:text="@string/back"
android:onClick="goBack"
android:background="@drawable/button" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="here is my adUnitId"
ads:adSize="BANNER"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</LinearLayout>
数据存储正在上升,这并不取决于活动中的内容。如果activity有AdMob广告且internet连接处于打开状态,则数据存储量将增加。没有AdMob ad的标识活动将不可用。
另外,我正在使用Nexus 7 2013Admob将消耗少量空间,因为它使用构建数据库的WebView。它还将缓存广告资源。但不会太多(如果超过1MB,我会感到惊讶)。使用admob时,它会在Android/yourfile/app_webview下保存一些文件(cookies、索引等)。如果您不想增加数据使用量,可以在退出应用程序之前删除该文件。我现在正在测试,数据存储量增加了1,46 mb:\并且不断增加,这听起来不像Admob使用的存储量。您在应用程序中存储或缓存哪些其他数据?您是否在应用程序的其他位置使用网络视图?否,仅admob。我也使用SharedReferences,但100%这不是问题所在。当互联网打开,广告刷新时,数据存储量正在增加。我的一些活动在活动结束时不会破坏广告。我应该在adview上使用.destroy()吗?是的-看它没有帮助=[数据存储空间上升到3.88mb并持续上升。我真的不知道为什么会发生这种情况…也许可以删除这个数据库?就像我正在删除SharedReferences文件=新文件(“/Data/Data/com.example.testlogo/shared_prefs/LevelOne.xml”);File.delete();