当前位置: 首页>>代码示例>>Java>>正文


Java ThreadPolicy.Builder方法代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:blstream,项目名称:StudyBox_Android,代码行数:24,代码来源:DebugHelper.java

示例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());
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:13,代码来源:SplashScreenActivity.java

示例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);
}
 
开发者ID:remelpugh,项目名称:android-shared,代码行数:44,代码来源:StrictModeHelper.java

示例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;
}
 
开发者ID:remelpugh,项目名称:android-shared,代码行数:14,代码来源:StrictModeHelper.java

示例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());
}
 
开发者ID:grote,项目名称:Transportr,代码行数:12,代码来源:MapActivity.java


注:本文中的android.os.StrictMode.ThreadPolicy.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。