android.os.NetworkOnMainThreadException,Failed to find provider info for com.android.inputmethod.lat
来源:互联网 发布:lstm python实现 编辑:程序博客网 时间:2024/06/05 09:11
在android 2.3上设计的下载程序,在android 4.0上运行时报android.os.NetworkOnMainThreadException异常,原来在4.0中,访问网络不能在主程序中进行,有两个方法可以解决,一个是在主程序中增加:
// 详见StrictMode文档
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork() // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.penaltyDeath()
.build());
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork() // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.penaltyDeath()
.build());
另一种是启动线程执行任务:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);setContentView(R.layout.main);
// 启动线程执行任务
new Thread(thread).start();
}
/**
* 下载线程
*/
Runnable thread = new Runnable(){
@Override
public void run() {
// TODO Auto-generated method stub
相关代码...
}
};
0 0
- android.os.NetworkOnMainThreadException,Failed to find provider info for com.android.inputmethod.lat
- Failed to find provider info for com.android.calendar问题排除
- Android - Failed to find provider info for com.google.settings in MapView Example
- android: failed to find provider info for downloads
- failed to find provider info for com.……
- FAILED TO FIND PROVIDER INFO FOR COM.……
- Failed to find provider info for com.google.settings
- Failed to find provider info for com.sina.weibo.sdkProvider
- 获取快捷方式在Launcher数据库中的信息 Failed to find provider info for com.android.launcher2.settings
- Failed to find provider info for com.android.download.provider 在修改package名称及 权限的时候出现了崩的情况
- Failed to find provider info for com.tencent.mm.sdk.plugin.provider
- Android 快捷方式的创建与查询 快捷方式问题大全 获取快捷方式在Launcher数据库中的信息 Failed to find provider info for com.android.la
- 友盟微博failed to find provider info for com.sina.weibo.sdkprovider
- 微博分享不成功 Failed to find provider info for com.sina.weibo.sdkProvider
- Failed to find provider info for com.zhoujian.contentPrivider.bookprivider(authorities)
- 新浪微博Failed to find provider info for com.sina.weibo.sdkProvider
- Test running failed: Unable to find instrumentation info for: ComponentInfo
- Failed to find: com.android.support:appcompat-v7:20
- UVa 1585 Score(水)
- 集合框架(泛型方法)
- 数据挖掘算法学习(四)PCA算法
- 非递归枚举排列组合(C++)
- 集合框架(静态方法泛型)
- android.os.NetworkOnMainThreadException,Failed to find provider info for com.android.inputmethod.lat
- 集合框架(泛型接口)
- N元语法模型的数据稀疏问题解决方法之一:Good-Turing平滑
- 集合框架(泛型限定)
- HDU1545(01-K Code)
- C程序设计语言(K&R)第一章学习笔记
- hdu 1010 Tempter of the Bone(DFS)
- 集合框架(泛型限定2)
- OJ最长公共字串