2014-04-30 41 views
0

我已將admob廣告添加到我的應用中。之後,我的應用程序的大小正在增加。我已經在Settings-App-MyApp中檢查過它(存儲數據,而不是緩存)。我很擔心,它會增加,直到手機沒有空閒內存或者這個大小有限制(有多大)?來自AdMob的意外數據存儲。

編輯:

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> 

數據存儲正在上升,這也要看是什麼活動。如果活動包含AdMob廣告並啓用了互聯網連接,則數據存儲量將會增加。沒有AdMob廣告的徽標活動不會。 PS。我正在使用Nexus 7 2013

回答

0

Admob將消耗少量空間,因爲它使用構建數據庫的WebView。它也會緩存廣告資源。但它不會太多(如果超過1MB,我會感到驚訝)。

+0

謝謝您的信息:) – mzfx

+0

我現在正在測試,數據存儲上升了1,46 MB:\並不斷提高 – mzfx

+0

這聽起來並不像Admob使用的存儲量。您在應用中存儲或緩存了哪些其他數據?你在應用程序的其他地方使用WebView嗎? – William

0

當使用admob時,它會在Android/yourfile/app_webview下保存一些文件(餅乾,索引等)。如果您不想增加數據使用量,則可以在退出應用程序之前刪除該文件。