public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.activity_main); /** * 這個模式去關掉device */ StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads() .detectDiskWrites() .detectNetwork() // or .detectAll() for all detectable problems .penaltyLog() .build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects() .detectLeakedSqlLiteObjects() .penaltyLog() .penaltyDeath() .build()); /** * */ RelativeLayout mainLayout = (RelativeLayout)getLayoutInflater().inflate(R.layout.activity_main, null); TextView resultView = (TextView) mainLayout.findViewById (R.id.TestHttpView); String result = ""; result = getStringFromURL("http://www.google.com.tw"); if(result != null || result.length() > 0) { resultView.setText(result); } setContentView(mainLayout);
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
/**
* 這個模式去關掉device
*/
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork() // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedSqlLiteObjects()
.penaltyLog()
.penaltyDeath()
.build());
/**
*
*/
RelativeLayout mainLayout = (RelativeLayout)getLayoutInflater().inflate(R.layout.activity_main, null);
TextView resultView = (TextView) mainLayout.findViewById (R.id.TestHttpView);
String result = "";
result = getStringFromURL("http://www.google.com.tw");
if(result != null || result.length() > 0) {
resultView.setText(result);
}
setContentView(mainLayout);
}