本文整理汇总了Java中android.os.StrictMode.ThreadPolicy.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadPolicy.Builder方法的具体用法?Java ThreadPolicy.Builder怎么用?Java ThreadPolicy.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.StrictMode.ThreadPolicy
的用法示例。
在下文中一共展示了ThreadPolicy.Builder方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeStrictMode
import android.os.StrictMode.ThreadPolicy; //导入方法依赖的package包/类
private static void initializeStrictMode() {
if (!strictModeInitialized) {
if (SDK_INT >= GINGERBREAD) {
ThreadPolicy.Builder threadPolicy = new ThreadPolicy.Builder();
VmPolicy.Builder vmPolicy = new VmPolicy.Builder();
threadPolicy.detectAll()
.penaltyLog();
vmPolicy.detectAll()
.penaltyLog();
if (STRICT_MODE_KILL_ON_ERROR) {
threadPolicy.penaltyDeath();
vmPolicy.penaltyDeath();
}
StrictMode.setThreadPolicy(threadPolicy.build());
StrictMode.setVmPolicy(vmPolicy.build());
strictModeInitialized = true;
}
}
}
示例2: enableStrictMode
import android.os.StrictMode.ThreadPolicy; //导入方法依赖的package包/类
private void enableStrictMode() {
if (TESTING) {
ThreadPolicy.Builder threadPolicy = new ThreadPolicy.Builder();
threadPolicy.detectAll();
threadPolicy.penaltyLog();
StrictMode.setThreadPolicy(threadPolicy.build());
VmPolicy.Builder vmPolicy = new VmPolicy.Builder();
vmPolicy.detectAll();
vmPolicy.penaltyLog();
StrictMode.setVmPolicy(vmPolicy.build());
}
}
示例3: permit
import android.os.StrictMode.ThreadPolicy; //导入方法依赖的package包/类
/**
* @param policy
* @param runnable
* @return
*/
@TargetApi(VERSION_CODES.HONEYCOMB)
public void permit(final Policy.Thread policy, final Runnable runnable) {
final ThreadPolicy oldPolicy = StrictMode.getThreadPolicy();
final ThreadPolicy.Builder builder = new ThreadPolicy.Builder(oldPolicy);
switch (policy) {
case PermitAll: {
builder.permitAll();
break;
}
case PermitCustomSlowCalls: {
if (AndroidUtils.isAtLeastHoneycomb()) {
builder.permitCustomSlowCalls();
}
break;
}
case PermitDiskReads: {
builder.permitDiskReads();
break;
}
case PermitDiskWrites: {
builder.permitDiskWrites();
break;
}
case PermitNetwork: {
builder.permitNetwork();
break;
}
}
StrictMode.setThreadPolicy(builder.build());
if (runnable != null) {
runnable.run();
}
StrictMode.setThreadPolicy(oldPolicy);
}
示例4: reset
import android.os.StrictMode.ThreadPolicy; //导入方法依赖的package包/类
/**
* @return The current instance of {@link StrictModeHelper}.
*/
public StrictModeHelper reset() {
if (!AppHelper.with(context).isDebuggable()) {
return this;
}
threadBuilder = new ThreadPolicy.Builder();
vmBuilder = new VmPolicy.Builder();
return this;
}
示例5: enableStrictMode
import android.os.StrictMode.ThreadPolicy; //导入方法依赖的package包/类
private void enableStrictMode() {
ThreadPolicy.Builder threadPolicy = new ThreadPolicy.Builder();
threadPolicy.detectAll();
threadPolicy.penaltyLog();
StrictMode.setThreadPolicy(threadPolicy.build());
VmPolicy.Builder vmPolicy = new VmPolicy.Builder();
vmPolicy.detectAll();
vmPolicy.penaltyLog();
StrictMode.setVmPolicy(vmPolicy.build());
}