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


Java StrictMode.ThreadPolicy方法代码示例

本文整理汇总了Java中android.os.StrictMode.ThreadPolicy方法的典型用法代码示例。如果您正苦于以下问题:Java StrictMode.ThreadPolicy方法的具体用法?Java StrictMode.ThreadPolicy怎么用?Java StrictMode.ThreadPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.StrictMode的用法示例。


在下文中一共展示了StrictMode.ThreadPolicy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.os.StrictMode; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //check is tablet or not
if(isTablet(getApplicationContext())){
setContentView(R.layout.activity_home);
 }else{
setContentView(R.layout.activity_home1);
}

    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }


        //get and set screen resolution
        QuranConfig.getResolutionURLLink(this);

        //init application views
        init();


}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:26,代码来源:HomeActivity.java

示例2: onCreate

import android.os.StrictMode; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i(getClass().getSimpleName(), "Start MainActivity");
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    Config.instance.init(this);
    DeviceManager.instance.setContext(this);
    WifiManager.instance.init(this);
    BLEManager.instance.init(this);
    try {
        mServer = new WebService(this);
        startService(new Intent(this, CloudPublisherService.class));
    }catch (Exception e){
        Log.e(getClass().getSimpleName(), e.toString());
    }
}
 
开发者ID:dmtan90,项目名称:Sense-Hub-Android-Things,代码行数:18,代码来源:MainActivity.java

示例3: getDownloadsDirectory

import android.os.StrictMode; //导入方法依赖的package包/类
/**
 * @return the public downloads directory.
 */
@SuppressWarnings("unused")
@CalledByNative
private static String getDownloadsDirectory(Context appContext) {
    // Temporarily allowing disk access while fixing. TODO: http://crbug.com/508615
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    String downloadsPath;
    try {
        long time = SystemClock.elapsedRealtime();
        downloadsPath = Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_DOWNLOADS).getPath();
        RecordHistogram.recordTimesHistogram("Android.StrictMode.DownloadsDir",
                SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
    return downloadsPath;
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:21,代码来源:PathUtils.java

示例4: onCreate

import android.os.StrictMode; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
    
	super.onCreate(savedInstanceState);


     StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
     StrictMode.setThreadPolicy(policy);

	setContentView(R.layout.socket_connection_build);
	ed_host = (EditText) findViewById(R.id.ed_host);
	ed_port = (EditText) findViewById(R.id.ed_port);
	btn_connect = (Button) findViewById(R.id.btn_connect);
	
	/* Fetch earlier defined host ip and port numbers and write them as default 
	 * (to avoid retyping this, typically standard, info) */
	SharedPreferences mSharedPreferences = getSharedPreferences("list",MODE_PRIVATE);
	String oldHost = mSharedPreferences.getString("host", null); 
	if (oldHost != null)
		ed_host.setText(oldHost);
	int oldPortCommunicator = mSharedPreferences.getInt("port",0);
	if (oldPortCommunicator != 0)
		ed_port.setText(Integer.toString(oldPortCommunicator));
	


}
 
开发者ID:felixnorden,项目名称:moppepojkar,代码行数:27,代码来源:Settings.java

示例5: getUriForItem

import android.os.StrictMode; //导入方法依赖的package包/类
/**
 * Returns a URI that points at the file.
 * @param file File to get a URI for.
 * @return URI that points at that file, either as a content:// URI or a file:// URI.
 */
public static Uri getUriForItem(File file) {
    Uri uri = null;

    // #getContentUriFromFile causes a disk read when it calls into FileProvider#getUriForFile.
    // Obtaining a content URI is on the critical path for creating a share intent after the
    // user taps on the share button, so even if we were to run this method on a background
    // thread we would have to wait. As it depends on user-selected items, we cannot
    // know/preload which URIs we need until the user presses share.
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        // Try to obtain a content:// URI, which is preferred to a file:// URI so that
        // receiving apps don't attempt to determine the file's mime type (which often fails).
        uri = ContentUriUtils.getContentUriFromFile(ContextUtils.getApplicationContext(), file);
    } catch (IllegalArgumentException e) {
        Log.e(TAG, "Could not create content uri: " + e);
    }
    StrictMode.setThreadPolicy(oldPolicy);

    if (uri == null) uri = Uri.fromFile(file);

    return uri;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:28,代码来源:DownloadUtils.java

示例6: startChromeBrowserProcessesSync

import android.os.StrictMode; //导入方法依赖的package包/类
private void startChromeBrowserProcessesSync() throws ProcessInitException {
    try {
        TraceEvent.begin("ChromeBrowserInitializer.startChromeBrowserProcessesSync");
        ThreadUtils.assertOnUiThread();
        mApplication.initCommandLine();
        LibraryLoader libraryLoader = LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER);
        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
        libraryLoader.ensureInitialized();
        StrictMode.setThreadPolicy(oldPolicy);
        libraryLoader.asyncPrefetchLibrariesToMemory();
        BrowserStartupController.get(mApplication, LibraryProcessType.PROCESS_BROWSER)
                .startBrowserProcessesSync(false);
        GoogleServicesManager.get(mApplication);
    } finally {
        TraceEvent.end("ChromeBrowserInitializer.startChromeBrowserProcessesSync");
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:18,代码来源:ChromeBrowserInitializer.java

示例7: startActivityIfNeeded

import android.os.StrictMode; //导入方法依赖的package包/类
@Override
public boolean startActivityIfNeeded(Intent intent, boolean proxy) {
    boolean activityWasLaunched;
    // Only touches disk on Kitkat. See http://crbug.com/617725 for more context.
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
    StrictMode.allowThreadDiskReads();
    try {
        forcePdfViewerAsIntentHandlerIfNeeded(mApplicationContext, intent);
        if (proxy) {
            dispatchAuthenticatedIntent(intent);
            activityWasLaunched = true;
        } else {
            Context context = getAvailableContext();
            if (context instanceof Activity) {
                activityWasLaunched = ((Activity) context).startActivityIfNeeded(intent, -1);
            } else {
                activityWasLaunched = false;
            }
        }
        if (activityWasLaunched) recordExternalNavigationDispatched(intent);
        return activityWasLaunched;
    } catch (RuntimeException e) {
        IntentUtils.logTransactionTooLargeOrRethrow(e, intent);
        return false;
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:29,代码来源:ExternalNavigationDelegateImpl.java

示例8: initializeLocale

import android.os.StrictMode; //导入方法依赖的package包/类
/**
 * Is only required by locale aware activities, AND  Application. In most cases you should be
 * using LocaleAwareAppCompatActivity or friends.
 * @param context
 */
public static void initializeLocale(Context context) {
    final LocaleManager localeManager = LocaleManager.getInstance();
    final StrictMode.ThreadPolicy savedPolicy = StrictMode.allowThreadDiskReads();
    StrictMode.allowThreadDiskWrites();
    try {
        localeManager.getAndApplyPersistedLocale(context);
    } finally {
        StrictMode.setThreadPolicy(savedPolicy);
    }
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:16,代码来源:Locales.java

示例9: cayenneService

import android.os.StrictMode; //导入方法依赖的package包/类
/**
 * Dagger DI provider method for {@link CayenneService}
 *
 * @param context
 *          android context used by {@link DefaultCayenneService} service internally
 * @return Cayenne service implementation
 */
@Provides
@Singleton
public CayenneService cayenneService(Context context) {
    // TODO: Cayenne temp ID functionality uses Localhost address,
    // TODO: i.e. network activity in terms of Android.
    // TODO: Without explicit permission here Cayenne will permanently fail to create new objects.
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

    // This installs "assets:" url schema handler, this may be not optimal solution.
    UrlToAssetUtils.registerHandler(context.getAssets());

    return new DefaultCayenneService(context);
}
 
开发者ID:stariy95,项目名称:cayenne-android-demo,代码行数:22,代码来源:AppModule.java

示例10: onCreate

import android.os.StrictMode; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    prefs = getSharedPreferences("com.threebetasonematt.a420game", MODE_PRIVATE);


    //get reference for username box
    mEnterUsername = (EditText)findViewById(R.id.edittext_enter_username);

    //handle play button
    mPlayButton = (Button)findViewById(R.id.button_splash_play);
    mPlayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String username = mEnterUsername.getText().toString();
            if(username.equals("") || username.equals(null)){
                //display error if the username is bad
                Toast.makeText(InitialActivity.this, R.string.blank_username_error, Toast.LENGTH_SHORT).show();
            }
            else{
                //open next activity
                Intent intent = new Intent(InitialActivity.this, StartGameActivity.class);
                intent.putExtra(constants.KEY_USERNAME, username);
                SocketHandler.username = username;
                startActivity(intent);
            }
        }
    });




}
 
开发者ID:mattdelsordo,项目名称:420Game,代码行数:38,代码来源:InitialActivity.java

示例11: Register

import android.os.StrictMode; //导入方法依赖的package包/类
public Register(Activity cont, PreferencesShared pref) throws IOException {
    this.context = cont;
    preferencesShared = pref;
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    con = (HttpURLConnection) (new URL(this.context.getString(R.string.api_url)+this.context.getString(R.string.register_url))).openConnection();
    con.setRequestMethod("POST");
    con.setRequestProperty("Content-Type","application/json");
    con.setDoInput(true);
    con.setDoOutput(true);
    con.setUseCaches(true);
    con.connect();
}
 
开发者ID:TudorRosca,项目名称:enklave,代码行数:14,代码来源:Register.java

示例12: createVrShell

import android.os.StrictMode; //导入方法依赖的package包/类
private boolean createVrShell() {
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    StrictMode.allowThreadDiskWrites();
    try {
        Constructor<?> vrShellConstructor = mVrShellClass.getConstructor(Activity.class);
        mVrShell = (VrShell) vrShellConstructor.newInstance(mActivity);
    } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
            | InvocationTargetException | NoSuchMethodException e) {
        Log.e(TAG, "Unable to instantiate VrShell", e);
        return false;
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
    return true;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:16,代码来源:VrShellDelegate.java

示例13: onCreate

import android.os.StrictMode; //导入方法依赖的package包/类
/**
 * Figure out how to route the Intent.  Because this is on the critical path to startup, please
 * avoid making the pathway any more complicated than it already is.  Make sure that anything
 * you add _absolutely has_ to be here.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    // Third-party code adds disk access to Activity.onCreate. http://crbug.com/619824
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    TraceEvent.begin("ChromeLauncherActivity");
    TraceEvent.begin("ChromeLauncherActivity.onCreate");
    try {
        super.onCreate(savedInstanceState);
        doOnCreate(savedInstanceState);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
        TraceEvent.end("ChromeLauncherActivity.onCreate");
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:ChromeLauncherActivity.java

示例14: restoreTab

import android.os.StrictMode; //导入方法依赖的package包/类
private void restoreTab(TabRestoreDetails tabToRestore, boolean setAsActive) {
    // As we do this in startup, and restoring the active tab's state is critical, we permit
    // this read in the event that the prefetch task is not available. Either:
    // 1. The user just upgraded, has not yet set the new active tab id pref yet. Or
    // 2. restoreTab is used to preempt async queue and restore immediately on the UI thread.
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        long time = SystemClock.uptimeMillis();
        TabState state;
        int restoredTabId = mPreferences.getInt(PREF_ACTIVE_TAB_ID, Tab.INVALID_TAB_ID);
        if (restoredTabId == tabToRestore.id && mPrefetchActiveTabTask != null) {
            long timeWaitingForPrefetch = SystemClock.uptimeMillis();
            state = mPrefetchActiveTabTask.get();
            logExecutionTime("RestoreTabPrefetchTime", timeWaitingForPrefetch);
        } else {
            // Necessary to do on the UI thread as a last resort.
            state = TabState.restoreTabState(getStateDirectory(), tabToRestore.id);
        }
        logExecutionTime("RestoreTabTime", time);
        restoreTab(tabToRestore, state, setAsActive);
    } catch (Exception e) {
        // Catch generic exception to prevent a corrupted state from crashing the app
        // at startup.
        Log.d(TAG, "loadTabs exception: " + e.toString(), e);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:29,代码来源:TabPersistentStore.java

示例15: getThreadPolicy

import android.os.StrictMode; //导入方法依赖的package包/类
@Nullable
StrictMode.ThreadPolicy getThreadPolicy();
 
开发者ID:kirich1409,项目名称:StrictModeCompat,代码行数:3,代码来源:StrictModeCompat.java


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