馬上加入Android 台灣中文網,立即免費下載應用遊戲。
您需要 登錄 才可以下載或查看,沒有帳號?註冊
x
玩player上別人的app點擊完廣告後按下手機back鍵,遊戲還好好的在等你回來繼續...我的app卻是按完廣告返回遊戲時已經沒有回應...是不是少寫了什麼....
//-----Activity
package asue.game;
import android.os.Bundle;
import android.app.Activity;
import android.view.Window;
import android.view.WindowManager;
import android.content.pm.ActivityInfo;
import android.util.DisplayMetrics;
public class MainActivity extends Activity {
public static float vWidth;
public static float vHeight;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); //螢幕切換 ctrl+f12
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
DisplayMetrics dm = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(dm); //取得裝置的資訊
vWidth = dm.widthPixels;//寬
vHeight = dm.heightPixels; //高
}
/** Called before the activity is destroyed. */
@Override
public void onDestroy() {
super.onDestroy();
}
}
//-------------main
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent">
<asue.game.Panel
android:id="@+id/mainPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/adView"
android:layout_gravity="top"
android:layout_alignParentTop="true"
/>
<com.google.ads.AdView
android:id="@id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="a1234567890"
ads:loadAdOnCreate="true"
android:layout_alignParentBottom="true"
/>
</RelativeLayout> |
|