开发者

Windows Phone 7 - Testing for Data Connection

My app failed certification today and the reason was:

"The application can be caused to silently terminate when the device has no data connection available."

I 开发者_开发问答didn't even think about that when I developed the app. How do I test for no data connection? Is there a method that I can call or do I just wrap a try catch around my web service call and try to "catch-it" that way?

Thanks!


Try-catch seems to be the best way, as the data connection could go down between the time you check for it and the time you try to use it. Even if it's the next line of code.


I would also suggest you need to handle exceptions (try..catch..finally) that can occur under all operating conditions.

With regard to detecting the state of the network connection you can use GetIsNetworkAvailable() and NetworkInterfaceType.

Be aware of developments in this post if using the latter.

Reading NetworkInterfaceType can take over 20 seconds

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜