Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java android中未加载填隙添加_Java_Android_Android Activity_Admob_Manifest - Fatal编程技术网

Java android中未加载填隙添加

Java android中未加载填隙添加,java,android,android-activity,admob,manifest,Java,Android,Android Activity,Admob,Manifest,调试后,我发现我的onload()返回值为false,只显示一个空白的白色屏幕。 没有加载任何添加!即使我等待无限的时间 添加单元id是从中选取的 (用于样本添加) 这是我的主要活动课 package com.example.jatinarora.threestickhockey; import android.app.ActionBar; import android.content.Context; import android.content.Shared

调试后,我发现我的
onload()
返回值为false,只显示一个空白的白色屏幕。 没有加载任何添加!即使我等待无限的时间 添加单元id是从中选取的

(用于样本添加) 这是我的主要活动课

    package com.example.jatinarora.threestickhockey;
    import android.app.ActionBar;
    import android.content.Context;
    import android.content.SharedPreferences;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.graphics.Canvas;
    import android.graphics.Paint;
    import android.media.MediaPlayer;
    import android.os.SystemClock;
    import android.support.v4.view.MotionEventCompat;
    import android.support.v4.view.VelocityTrackerCompat;
    import android.support.v7.app.ActionBarActivity;
    import android.os.Bundle;
    import android.util.DisplayMetrics;
    import android.util.Log;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.MotionEvent;
    import android.view.VelocityTracker;
    import android.view.View;
    import android.view.ViewGroup;
    import android.view.Window;
    import android.view.WindowManager;
    import android.widget.Toast;
    import com.google.android.gms.ads.AdListener;  
    import com.google.android.gms.ads.AdRequest;
    import com.google.android.gms.ads.AdView;
    import com.google.android.gms.ads.InterstitialAd;

    public class MainActivity extends ActionBarActivity {

public InterstitialAd interstitial;
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
    WindowManager.LayoutParams.FLAG_FULLSCREEN);
    interstitial = new InterstitialAd(this);
    interstitial.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
    requestNewInterstitial();
    float count123 = 1 ;
    // i tried setting the loop to infinity to wait for the advertisment to load!
    while(count123 >=0) {
        if (interstitial!= null && interstitial.isLoaded()) {
            interstitial.show();
            count123 = -1;
        }
        }
        }

private void requestNewInterstitial() {
    AdRequest adRequest = new AdRequest.Builder().build();
    interstitial.loadAd(adRequest);
}



@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    //getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}
@Override
protected void onResume() {
    super.onResume();
    mView.running = true;
}
protected void onPause()
{
    mView.resume = 1;
    mView.running = false;
    super.onPause();
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}}
在我的
activity\u main.xml
中,我没有添加AdView,因为在我访问过的所有教程和链接中,我都没有看到任何Interstitual,它被用作横幅

这是我的活动_main.xml

    <RelativeLayout
   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"
android:paddingLeft="0dp"
android:label="@string/app_name"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp" tools:context=".MainActivity">
<com.example.jatinarora.threestickhockey.mView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />
   </RelativeLayout>

这是我的文件

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.example.jatinarora.threestickhockey" >
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar">
        <activity
        android:name=".MainActivity"
        android:screenOrientation="portrait"
        android:label="@string/app_name" >

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version"/>
    <activity android:name="com.google.android.gms.ads.AdActivity"
               android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:theme="@android:style/Theme.Translucent" />
  </application>
</manifest>


任何建议,错误,为什么添加没有显示或任何替代解决方案将是非常有帮助的

[问题的原因]

我不能给出这个问题的确切原因,但是,在主线程上运行循环会引入延迟,这就是为什么add没有加载的原因,因为它超时太快,没有加载的空间,因为在该线程上有很多占用进程的工作,这也可能是导致3-4秒出现白色屏幕的原因。。但除此之外,通常不会显示的附加项可能是您的internet连接或


因此,先生,忘记循环,检查这个,它将向您展示如何在加载完成时显示add-它有
onadloated()
,当
interstitual.isLoaded()
为真时触发它。。剩下的留给internet和google,当它出现时,add会显示出来,你可以添加断点来了解它是如何运行的

为什么不使用布尔run=true;在你的while循环中,这只是BTW,也是空白的白色屏幕,你的应用程序屏幕还是它在你的应用程序之上?如果你的应用程序显示为白色屏幕,那么它是你的应用程序,而不是admobSee,如果我只在没有admob的情况下运行我的应用程序,它会在白色屏幕上停留3-4秒,然后工作正常!:D即使我使用有限的while循环,我的应用程序也能工作。。而且中间的add没有出现。。因此,为了等待添加加载,我让循环等待添加显示!