类android.os.StrictMode.ThreadPolicy源码实例Demo

下面列出了怎么用android.os.StrictMode.ThreadPolicy的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: android_9.0.0_r45   文件: SliceProvider.java
private Slice onBindSliceStrict(Uri sliceUri, List<SliceSpec> supportedSpecs) {
    ThreadPolicy oldPolicy = StrictMode.getThreadPolicy();
    try {
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                .detectAll()
                .penaltyDeath()
                .build());
        return onBindSlice(sliceUri, new ArraySet<>(supportedSpecs));
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
源代码2 项目: 365browser   文件: PackageManagerDelegate.java
/**
 * Retrieves the single activity that matches the given intent, or null if none found.
 * @param intent The intent to query.
 * @return The matching activity.
 */
public ResolveInfo resolveActivity(Intent intent) {
    ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        return ContextUtils.getApplicationContext().getPackageManager().resolveActivity(
                intent, 0);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
源代码3 项目: 365browser   文件: PackageManagerDelegate.java
/**
 * Retrieves the list of activities that can respond to the given intent.
 * @param intent The intent to query.
 * @return The list of activities that can respond to the intent.
 */
public List<ResolveInfo> getActivitiesThatCanRespondToIntent(Intent intent) {
    ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        return ContextUtils.getApplicationContext().getPackageManager().queryIntentActivities(
                intent, 0);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
源代码4 项目: 365browser   文件: PackageManagerDelegate.java
/**
 * Retrieves the list of activities that can respond to the given intent. And returns the
 * activites' meta data in ResolveInfo.
 *
 * @param intent The intent to query.
 * @return The list of activities that can respond to the intent.
 */
public List<ResolveInfo> getActivitiesThatCanRespondToIntentWithMetaData(Intent intent) {
    ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        return ContextUtils.getApplicationContext().getPackageManager().queryIntentActivities(
                intent, PackageManager.GET_META_DATA);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
源代码5 项目: 365browser   文件: PackageManagerDelegate.java
/**
 * Retrieves the list of services that can respond to the given intent.
 * @param intent The intent to query.
 * @return The list of services that can respond to the intent.
 */
public List<ResolveInfo> getServicesThatCanRespondToIntent(Intent intent) {
    ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        return ContextUtils.getApplicationContext().getPackageManager().queryIntentServices(
                intent, 0);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
源代码6 项目: agera   文件: NotesApplication.java
@Override
public void onCreate() {
  super.onCreate();
  setThreadPolicy(new ThreadPolicy.Builder().detectAll().penaltyLog().build());
  setVmPolicy(new VmPolicy.Builder().detectAll().penaltyLog().build());
}
 
 类所在包
 同包方法