当前位置: 编程技术>移动开发
本页文章导读:
▪Reachablity检测网络状态 包孕代码 Reachablity检测网络状态 包含代码
检测网络状态的代码,使用block的形式:
Reachability * reach = [Reachability reachabilityWithHostname:@"www.google.com"];
reach.reachableBlock = ^(Reachability * reachability)
{
.........
▪ Unable to add window is not valid; is your activity running Unable to add window is not valid; is your activity running?
郁闷的Bug,终于解决了,分享一下! 错误: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@435.........
▪ 字符编码优秀稿件收集 字符编码优秀文章收集
http://www.ibm.com/developerworks/cn/java/j-lo-chinesecoding/
......
[1]Reachablity检测网络状态 包孕代码
来源: 互联网 发布时间: 2014-02-18
Reachablity检测网络状态 包含代码
检测网络状态的代码,使用block的形式:
Reachability * reach = [Reachability reachabilityWithHostname:@"www.google.com"]; reach.reachableBlock = ^(Reachability * reachability) { dispatch_async(dispatch_get_main_queue(), ^{ blockLabel.text = @"Block Says Reachable"; }); }; reach.unreachableBlock = ^(Reachability * reachability) { dispatch_async(dispatch_get_main_queue(), ^{ blockLabel.text = @"Block Says Unreachable"; }); }; [reach startNotifier];
使用通知的形式:
- (void)viewDidLoad { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil]; } -(void)reachabilityChanged:(NSNotification*)note { Reachability * reach = [note object]; if([reach isReachable]) { notificationLabel.text = @"Notification Says Reachable"; } else { notificationLabel.text = @"Notification Says Unreachable"; } }
[2] Unable to add window is not valid; is your activity running
来源: 互联网 发布时间: 2014-02-18
Unable to add window is not valid; is your activity running?
郁闷的Bug,终于解决了,分享一下!
错误:
android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@435def20 is not valid; is your activity running? at android.view.ViewRoot.setView......
发生环境:
在一个tabActivity里面嵌套一个tabAcitivity, 如果在子tabActivity里面显示AlertDialog的话,就会引发此错误。
解决方法:
AlertDialog.Builder(xxx.this) => AlertDialog.Builder(this.getParent())
文章引用自:http://macleo.iteye.com/blog/1486684
[3] 字符编码优秀稿件收集
来源: 互联网 发布时间: 2014-02-18
字符编码优秀文章收集
http://www.ibm.com/developerworks/cn/java/j-lo-chinesecoding/
最新技术文章: