cocos2d-x android開發中 常用的一些筆記
//設置窗體全屏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//設置窗體始終點亮
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//設置窗體背景模糊
getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
System.exit(0); //常規java、c#的標準退出法,返回值為0代表正常退出
android.os.Process.killProcess(android.os.Process.myPid()) ; //獲取PID
//檢測當前網絡是否為wifi
public static ConnectivityManager conMan;
conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
public static boolean CheckNetworkIsWifi()
{
boolean isWifi = false;
Log.e("TAG", "CheckNetworkIsWifi");
//mobile 3G Data Network
try
{
State mobile = conMan.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
Log.e("TAG 3G", mobile.toString());
//wifi
State wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
Log.e("TAG WIFI", wifi.toString());
if(mobile == State.CONNECTED || mobile == State.CONNECTING)
{
Log.e("TAG 3G", "is network 3g!!!");
isWifi = false;
}
else if(wifi == State.CONNECTED || wifi == State.CONNECTING)
{
Log.e("TAG WIFI", "is network wifi");
isWifi = true;
}
}
catch (Exception e)
{
Log.e("TAG", "is network error!!!");
isWifi = true;
}
return isWifi;
}
}
沒有留言:
張貼留言