Commit 86747623 authored by 王雪伟's avatar 王雪伟

加入初始化环境切换

parent e83c498b
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -32,7 +32,7 @@ public class MainActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ZXHCADManager.getInstance().InitAd(this, "1000127");
ZXHCADManager.getInstance().InitAd(this, "1000127",false);
String url = "http://sspv2test.zhangxinhuichuan.com/ssp/v1/ads?pid=2100154&type=api&ad_type=3&ad_w=480&ad_h=720&app_package=com.popcap.pvz2cthd&app_id=1000127&app_name=com.popcap.pvz2cthd&app_versionid=1005&device_geo_lat=&device_geo_lon=&device_imei=X6GNU17524105082&device_adid=d0cf1c3d5280f16b&device_mac=F0:C8:50:A1:4E:8E&device_width=1920&device_height=1132&device_imsi=460000501365163&device_carrier=&device_network=1&device_os=Android&device_os_version=24&device_density=2.0&device_ppi=2.0&device_ip=183.211.87.156&device_ua=Dalvik%2F2.1.0+%28Linux%3B+U%3B+Android+9%3B+Redmi+Note+8+Pro+MIUI%2FV10.4.9.0.PGGCNXM%29&device_type=0&is_mobile=1&device_model=FLA-AL10&device_brand=HUAWEI";
String BaseUrl = "http://sspv2test.zhangxinhuichuan.com/ssp/v1/ads";
new OaidUtils().GetOaid(MainActivity.this, new IOaidListener() {
......
......@@ -9,6 +9,8 @@ import android.text.TextUtils;
import android.util.Log;
import android.webkit.WebView;
import java.net.URLEncoder;
public class AppliContext {
......@@ -38,7 +40,7 @@ public class AppliContext {
ZXHCConstant.screen_size = PhoneUtils.getInstance().getScreenSize(context) + "";
ZXHCConstant.device_ip = PhoneUtils.getInstance().getIPAddress(false) + "";
ZXHCConstant.device_ua = new WebView(context).getSettings().getUserAgentString();
ZXHCConstant.device_ua =toURLEncoded(new WebView(context).getSettings().getUserAgentString());
ZXHCConstant.device_type = "0";
ZXHCConstant.is_mobile = "1";
ZXHCConstant.device_model = PhoneUtils.getInstance().getModel();
......@@ -68,4 +70,20 @@ public class AppliContext {
}
}
public static String toURLEncoded(String paramString) {
if (paramString == null || paramString.equals("")) {
return "";
}
try
{
String str = new String(paramString.getBytes(), "UTF-8");
str = URLEncoder.encode(str, "UTF-8");
return str;
}
catch (Exception localException)
{
}
return "";
}
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
......@@ -67,11 +68,12 @@ public class HttpClientUtils {
connection.setConnectTimeout(50000);
connection.setReadTimeout(50000);
// User-Agent IE9的标识
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;");
//connection.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;");
connection.setRequestProperty("Accept-Language", "zh-CN");
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setRequestProperty("Charset", "UTF-8");
/*
/*Zx
* 当我们要获取我们请求的http地址访问的数据时就是使用connection.getInputStream().read()方式时我们就需要setDoInput(true),
* 根据api文档我们可知doInput默认就是为true。我们可以不用手动设置了,如果不需要读取输入流的话那就setDoInput(false)。
* 当我们要采用非get请求给一个http网络地址传参 就是使用connection.getOutputStream().write() 方法时我们就需要setDoOutput(true), 默认是false
......@@ -82,6 +84,8 @@ public class HttpClientUtils {
//connection.setDoOutput(true);//Android 4.0 GET时候 用这句会变成POST 报错java.io.FileNotFoundException
connection.setUseCaches(false);
connection.connect();//
Log.d("wxw","connection.getURL(); "+connection.getURL());
int contentLength = connection.getContentLength();
if (connection.getResponseCode() == 200) {
inputStream = connection.getInputStream();//会隐式调用connect()
......@@ -341,5 +345,4 @@ public class HttpClientUtils {
return str;
}
}
......@@ -756,7 +756,11 @@ public class PhoneUtils {
} catch (Exception e) {
e.printStackTrace();
}
return result.get(0).getLocality();
if(result!=null&&result.size()>0){
return result.get(0).getLocality();
}else {
return "";
}
}
} else {
//ToastUtils.showToast(this, "GPS未定位到位置");
......
......@@ -22,15 +22,14 @@ public class ZXHCADManager {
}
return sInstance;
}
public boolean InitAd(Activity context, String appId){
Log.d("wxw","appid"+appId);
public boolean InitAd(Activity context, String appId,boolean isDebug){
ZXHCConstant.ZXHC_APPID = appId;
AppliContext.init(context);
ZXHCConstant.IS_DEBUG = true;
ZXHCConstant.IS_DEBUG = isDebug;
if (ZXHCConstant.IS_DEBUG){
ZXHCConstant.BASE_URL = "http://sspv2test.zhangxinhuichuan.com/ssp/v1/ads";
}else {
ZXHCConstant.BASE_URL = "";
ZXHCConstant.BASE_URL = "http://sspv2.zhangxinhuichuan.com/ssp/v1/ads";
}
return true;
......
......@@ -72,7 +72,6 @@ public class ZXHCSplashAD {
adBean.setClickReport(false);
adBean.setClickDpLinkSucReport(false);
adBean.setClickDpLinkfailReport(false);
Log.d("wxw", "ad.getSrcUrls().size()" + adBean.getSrcUrls().size());
if (adBean.getSrcUrls().size() > 0) {
HttpClientUtils.LoadImg(adBean.getSrcUrls().get(0), new HttpClientUtils.OnRequestImgCallBack() {
@Override
......@@ -96,6 +95,8 @@ public class ZXHCSplashAD {
Log.d("wxw", "bitmaperrorMsg" + errorMsg);
}
});
}else {
listener.OnError("广告数据为0");
}
}
......@@ -145,7 +146,6 @@ public class ZXHCSplashAD {
private ViewGroup splashView;
public void showAd(ViewGroup vp) {
splashView = vp;
Log.d("wxw", "showAd");
context.runOnUiThread(new Runnable() {
@SuppressLint("ClickableViewAccessibility")
@Override
......@@ -160,7 +160,7 @@ public class ZXHCSplashAD {
@Override
public void onClick(View v) {
if (delayTime <= 0) {
listener.OnAdClosed();
//listener.OnAdClosed();
ZXHCAdViewManager.getInstance().removeAdView(context, vp);
mHandler.removeMessages(SPLASH_CODE);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment