【发布时间】:2012-02-22 08:42:56
【问题描述】:
我不想获得我当前的位置,但在大多数手机中它都失败了。 接下来是mycode:
public Location getLocation(Context context)
{
LocationManager locMan = (LocationManager) context
.getSystemService(Context.LOCATION_SERVICE);
Location location = locMan
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location == null)
{
location = locMan
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
}
return location;
}
【问题讨论】:
-
它失败这非常很有帮助。
-
需要更多信息。您是否在清单中添加了所需的权限?
-
你有什么错误吗.. 如果有,请粘贴堆栈跟踪
-
我已将所有需要的权限添加到清单中。此功能有时有效,但有时会失败。