开发者

error message for wi -fi turned off

I create application using map.

It works, but when there's no internet or wifi the application crashes.

Instead of crashing I want to show error message in device.

It is not shown in logcat.

Here's my code:

LocationManager myManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
if(myManager != null){
    String param=(String)myManager.getProviders(true).get(0);
    Location loc = myManager.getLastKnownLocation(param);

    if(loc != null){
         ............
    } else {
         Log.e("AndroidMaps-1 ","Error: Location  is null");
         builder.setMessage("err").setPositiveButton("Yes",dialogClickListener).show();
    }   
} else {
    Log.e("AndroidMaps-2 ","Error: Location Manager is null");
    builder.setMessage("Are you sure").setPositiveButton("Yes",dialogClickListener).show();
}

when wi-fi is turned off I do 开发者_开发问答not get any error message from logcat or dialog box.


Before doing anything else, you could check for Internet connectivity. If no Internet connection is available, you could notify the user.

Although, in my applications, it doesn't crash when the Map tries to lead tiles without any Internet connection.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜