<div id="article_content" class="article_content">
<p>引子:在我们的应用为用户提供定位服务时,通常想为用户提供精确点的定位服务,这是需要用户配合的。我们必须先检测用户手机的GPS当前是否打开,若没打开则弹出对话框提示。用户若不配合我们也没办法,只能采用基站定位方式。如果我们的应用必须用户打开GPS才可使用,这时流氓一点的做法,就是强制帮用户打开GPS。</p>
<p>阐明概念: </p>
<p> 定位服务GPS:全球卫星定位系统,使用24个人造卫星所形成的网络来三角定位接受器的位置,并提供经纬度坐标。虽然GPS提供绝佳的位置的精确度,但定位的位置需要在可看见人造卫星或轨道所经过的地方。</p>
<p> 定位服务AGPS:辅助全球卫星定位系统(英语:Assisted Global Positioning System,简称:AGPS)是一种GPS的运行方式。它可以利用手机基地站的资讯,配合传统GPS卫星,让定位的速度更快。用中文来说应该是网络辅助GPS定位系统。通俗的说AGPS是在以往通过卫星接受定位信号的同时结合移动运营的GSM或者CDMA网络机站的定位信息,就是一方面由具有AGPS的手机获取来自卫星的定位信息,而同时也要靠该手机透过中国移动的GPRS网络下载辅助的定位信息,两者相结合来完成定位。与传统GPS(GlobalPositioningSystem全球定位系统)首次定位要2、3分钟相比AGPS的首次定位时间最快仅需几秒钟,同时AGPS也彻底解决了普通GPS设备在室内无法获取定位信息的缺陷。</p>
<p>一、检测用户手机的GPS当前是否打开,,代码如下:</p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="#" class="ViewSource" title="view plain" οnclick="dp.sh.Toolbar.Command('ViewSource',this);return false;">view plain</a><span data-mod="popu_168"> <a href="#" class="CopyToClipboard" title="copy" οnclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;">copy</a><div style="position: absolute; left: 721px; top: 859px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_1" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_1" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&width=18&height=18" wmode="transparent"></div></span><span data-mod="popu_169"> <a href="#" class="PrintSource" title="print" οnclick="dp.sh.Toolbar.Command('PrintSource',this);return false;">print</a></span><a href="#" class="About" title="?" οnclick="dp.sh.Toolbar.Command('About',this);return false;">?</a></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="comment">/**</span> </span></li><li class=""><span><span class="comment"> * 判断GPS是否开启,GPS或者AGPS开启一个就认为是开启的</span> </span></li><li class="alt"><span><span class="comment"> * @param context</span> </span></li><li class=""><span><span class="comment"> * @return true 表示开启</span> </span></li><li class="alt"><span><span class="comment"> */</span><span> </span></span></li><li class=""><span> <span class="keyword">public</span><span> </span><span class="keyword">static</span><span> </span><span class="keyword">final</span><span> </span><span class="keyword">boolean</span><span> isOPen(</span><span class="keyword">final</span><span> Context context) { </span></span></li><li class="alt"><span> LocationManager locationManager </span></li><li class=""><span> = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); </span></li><li class="alt"><span> <span class="comment">// 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快)</span><span> </span></span></li><li class=""><span> <span class="keyword">boolean</span><span> gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); </span></span></li><li class="alt"><span> <span class="comment">// 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位)</span><span> </span></span></li><li class=""><span> <span class="keyword">boolean</span><span> network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); </span></span></li><li class="alt"><span> <span class="keyword">if</span><span> (gps || network) { </span></span></li><li class=""><span> <span class="keyword">return</span><span> </span><span class="keyword">true</span><span>; </span></span></li><li class="alt"><span> } </span></li><li class=""><span> </span></li><li class="alt"><span> <span class="keyword">return</span><span> </span><span class="keyword">false</span><span>; </span></span></li><li class=""><span> } </span></li></ol><div class="save_code tracking-ad" data-mod="popu_249" style="display: none;"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre class="java" name="code" style="display: none;">/**
* 判断GPS是否开启,GPS或者AGPS开启一个就认为是开启的
* @param context
* @return true 表示开启
*/
public static final boolean isOPen(final Context context) {
LocationManager locationManager
= (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
// 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快)
boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
// 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位)
boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (gps || network) {
return true;
}
return false;
}</pre>
<p>二、强制帮用户打开GPS,代码如下:</p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="#" class="ViewSource" title="view plain" οnclick="dp.sh.Toolbar.Command('ViewSource',this);return false;">view plain</a><span data-mod="popu_168"> <a href="#" class="CopyToClipboard" title="copy" οnclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;">copy</a><div style="position: absolute; left: 721px; top: 1278px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_2" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_2" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=2&width=18&height=18" wmode="transparent"></div></span><span data-mod="popu_169"> <a href="#" class="PrintSource" title="print" οnclick="dp.sh.Toolbar.Command('PrintSource',this);return false;">print</a></span><a href="#" class="About" title="?" οnclick="dp.sh.Toolbar.Command('About',this);return false;">?</a></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="comment">/**</span> </span></li><li class=""><span><span class="comment"> * 强制帮用户打开GPS</span> </span></li><li class="alt"><span><span class="comment"> * @param context</span> </span></li><li class=""><span><span class="comment"> */</span><span> </span></span></li><li class="alt"><span> <span class="keyword">public</span><span> </span><span class="keyword">static</span><span> </span><span class="keyword">final</span><span> </span><span class="keyword">void</span><span> openGPS(Context context) { </span></span></li><li class=""><span> Intent GPSIntent = <span class="keyword">new</span><span> Intent(); </span></span></li><li class="alt"><span> GPSIntent.setClassName(<span class="string">"com.android.settings"</span><span>, </span></span></li><li class=""><span> <span class="string">"com.android.settings.widget.SettingsAppWidgetProvider"</span><span>); </span></span></li><li class="alt"><span> GPSIntent.addCategory(<span class="string">"android.intent.category.ALTERNATIVE"</span><span>); </span></span></li><li class=""><span> GPSIntent.setData(Uri.parse(<span class="string">"custom:3"</span><span>)); </span></span></li><li class="alt"><span> <span class="keyword">try</span><span> { </span></span></li><li class=""><span> PendingIntent.getBroadcast(context, <span class="number">0</span><span>, GPSIntent, </span><span class="number">0</span><span>).send(); </span></span></li><li class="alt"><span> } <span class="keyword">catch</span><span> (CanceledException e) { </span></span></li><li class=""><span> e.printStackTrace(); </span></li><li class="alt"><span> } </span></li><li class=""><span> } </span></li></ol><div class="save_code tracking-ad" data-mod="popu_249" style="display: none;"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre class="java" name="code" style="display: none;">/**
* 强制帮用户打开GPS
* @param context
*/
public static final void openGPS(Context context) {
Intent GPSIntent = new Intent();
GPSIntent.setClassName("com.android.settings",
"com.android.settings.widget.SettingsAppWidgetProvider");
GPSIntent.addCategory("android.intent.category.ALTERNATIVE");
GPSIntent.setData(Uri.parse("custom:3"));
try {
PendingIntent.getBroadcast(context, 0, GPSIntent, 0).send();
} catch (CanceledException e) {
e.printStackTrace();
}
}</pre>
<p>三、在AndroidManifest.xml文件里需要添加的权限:</p>
<div class="dp-highlighter bg_html"><div class="bar"><div class="tools"><b>[html]</b> <a href="#" class="ViewSource" title="view plain" οnclick="dp.sh.Toolbar.Command('ViewSource',this);return false;">view plain</a><span data-mod="popu_168"> <a href="#" class="CopyToClipboard" title="copy" οnclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;">copy</a><div style="position: absolute; left: 723px; top: 1661px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_3" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_3" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=3&width=18&height=18" wmode="transparent"></div></span><span data-mod="popu_169"> <a href="#" class="PrintSource" title="print" οnclick="dp.sh.Toolbar.Command('PrintSource',this);return false;">print</a></span><a href="#" class="About" title="?" οnclick="dp.sh.Toolbar.Command('About',this);return false;">?</a></div></div><ol start="1" class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">uses-permission</span><span> </span><span class="attribute">android:name</span><span>=</span><span class="attribute-value">"android.permission.ACCESS_COARSE_LOCATION"</span><span> </span><span class="tag">/></span><span> </span></span></li><li class=""><span><span class="tag"><</span><span class="tag-name">uses-permission</span><span> </span><span class="attribute">android:name</span><span>=</span><span class="attribute-value">"android.permission.ACCESS_FINE_LOCATION"</span><span> </span><span class="tag">/></span><span> </span></span></li><li class="alt"><span><span class="tag"><</span><span class="tag-name">uses-permission</span><span> </span><span class="attribute">android:name</span><span>=</span><span class="attribute-value">"android.permission.ACCESS_WIFI_STATE"</span><span> </span><span class="tag">/></span><span> </span></span></li><li class=""><span><span class="tag"><</span><span class="tag-name">uses-permission</span><span> </span><span class="attribute">android:name</span><span>=</span><span class="attribute-value">"android.permission.ACCESS_NETWORK_STATE"</span><span> </span><span class="tag">/></span><span> </span></span></li><li class="alt"><span><span class="tag"><</span><span class="tag-name">uses-permission</span><span> </span><span class="attribute">android:name</span><span>=</span><span class="attribute-value">"android.permission.CHANGE_WIFI_STATE"</span><span> </span><span class="tag">/></span><span> </span></span></li><li class=""><span><span class="tag"><</span><span class="tag-name">uses-permission</span><span> </span><span class="attribute">android:name</span><span>=</span><span class="attribute-value">"android.permission.INTERNET"</span><span> </span><span class="tag">/></span><span> </span></span></li></ol><div class="save_code tracking-ad" data-mod="popu_249" style="display: none;"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre class="html" name="code" style="display: none;"> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" /></pre>
</div>
<p>引子:在我们的应用为用户提供定位服务时,通常想为用户提供精确点的定位服务,这是需要用户配合的。我们必须先检测用户手机的GPS当前是否打开,若没打开则弹出对话框提示。用户若不配合我们也没办法,只能采用基站定位方式。如果我们的应用必须用户打开GPS才可使用,这时流氓一点的做法,就是强制帮用户打开GPS。</p>
<p>阐明概念: </p>
<p> 定位服务GPS:全球卫星定位系统,使用24个人造卫星所形成的网络来三角定位接受器的位置,并提供经纬度坐标。虽然GPS提供绝佳的位置的精确度,但定位的位置需要在可看见人造卫星或轨道所经过的地方。</p>
<p> 定位服务AGPS:辅助全球卫星定位系统(英语:Assisted Global Positioning System,简称:AGPS)是一种GPS的运行方式。它可以利用手机基地站的资讯,配合传统GPS卫星,让定位的速度更快。用中文来说应该是网络辅助GPS定位系统。通俗的说AGPS是在以往通过卫星接受定位信号的同时结合移动运营的GSM或者CDMA网络机站的定位信息,就是一方面由具有AGPS的手机获取来自卫星的定位信息,而同时也要靠该手机透过中国移动的GPRS网络下载辅助的定位信息,两者相结合来完成定位。与传统GPS(GlobalPositioningSystem全球定位系统)首次定位要2、3分钟相比AGPS的首次定位时间最快仅需几秒钟,同时AGPS也彻底解决了普通GPS设备在室内无法获取定位信息的缺陷。</p>
<p>一、检测用户手机的GPS当前是否打开,,代码如下:</p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="#" class="ViewSource" title="view plain" οnclick="dp.sh.Toolbar.Command('ViewSource',this);return false;">view plain</a><span data-mod="popu_168"> <a href="#" class="CopyToClipboard" title="copy" οnclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;">copy</a><div style="position: absolute; left: 721px; top: 859px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_1" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_1" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&width=18&height=18" wmode="transparent"></div></span><span data-mod="popu_169"> <a href="#" class="PrintSource" title="print" οnclick="dp.sh.Toolbar.Command('PrintSource',this);return false;">print</a></span><a href="#" class="About" title="?" οnclick="dp.sh.Toolbar.Command('About',this);return false;">?</a></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="comment">/**</span> </span></li><li class=""><span><span class="comment"> * 判断GPS是否开启,GPS或者AGPS开启一个就认为是开启的</span> </span></li><li class="alt"><span><span class="comment"> * @param context</span> </span></li><li class=""><span><span class="comment"> * @return true 表示开启</span> </span></li><li class="alt"><span><span class="comment"> */</span><span> </span></span></li><li class=""><span> <span class="keyword">public</span><span> </span><span class="keyword">static</span><span> </span><span class="keyword">final</span><span> </span><span class="keyword">boolean</span><span> isOPen(</span><span class="keyword">final</span><span> Context context) { </span></span></li><li class="alt"><span> LocationManager locationManager </span></li><li class=""><span> = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); </span></li><li class="alt"><span> <span class="comment">// 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快)</span><span> </span></span></li><li class=""><span> <span class="keyword">boolean</span><span> gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); </span></span></li><li class="alt"><span> <span class="comment">// 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位)</span><span> </span></span></li><li class=""><span> <span class="keyword">boolean</span><span> network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); </span></span></li><li class="alt"><span> <span class="keyword">if</span><span> (gps || network) { </span></span></li><li class=""><span> <span class="keyword">return</span><span> </span><span class="keyword">true</span><span>; </span></span></li><li class="alt"><span> } </span></li><li class=""><span> </span></li><li class="alt"><span> <span class="keyword">return</span><span> </span><span class="keyword">false</span><span>; </span></span></li><li class=""><span> } </span></li></ol><div class="save_code tracking-ad" data-mod="popu_249" style="display: none;"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre class="java" name="code" style="display: none;">/**
* 判断GPS是否开启,GPS或者AGPS开启一个就认为是开启的
* @param context
* @return true 表示开启
*/
public static final boolean isOPen(final Context context) {
LocationManager locationManager
= (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
// 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快)
boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
// 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位)
boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (gps || network) {
return true;
}
return false;
}</pre>
<p>二、强制帮用户打开GPS,代码如下:</p>
<div class="dp-highlighter bg_java"><div class="bar"><div class="tools"><b>[java]</b> <a href="#" class="ViewSource" title="view plain" οnclick="dp.sh.Toolbar.Command('ViewSource',this);return false;">view plain</a><span data-mod="popu_168"> <a href="#" class="CopyToClipboard" title="copy" οnclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;">copy</a><div style="position: absolute; left: 721px; top: 1278px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_2" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_2" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=2&width=18&height=18" wmode="transparent"></div></span><span data-mod="popu_169"> <a href="#" class="PrintSource" title="print" οnclick="dp.sh.Toolbar.Command('PrintSource',this);return false;">print</a></span><a href="#" class="About" title="?" οnclick="dp.sh.Toolbar.Command('About',this);return false;">?</a></div></div><ol start="1" class="dp-j"><li class="alt"><span><span class="comment">/**</span> </span></li><li class=""><span><span class="comment"> * 强制帮用户打开GPS</span> </span></li><li class="alt"><span><span class="comment"> * @param context</span> </span></li><li class=""><span><span class="comment"> */</span><span> </span></span></li><li class="alt"><span> <span class="keyword">public</span><span> </span><span class="keyword">static</span><span> </span><span class="keyword">final</span><span> </span><span class="keyword">void</span><span> openGPS(Context context) { </span></span></li><li class=""><span> Intent GPSIntent = <span class="keyword">new</span><span> Intent(); </span></span></li><li class="alt"><span> GPSIntent.setClassName(<span class="string">"com.android.settings"</span><span>, </span></span></li><li class=""><span> <span class="string">"com.android.settings.widget.SettingsAppWidgetProvider"</span><span>); </span></span></li><li class="alt"><span> GPSIntent.addCategory(<span class="string">"android.intent.category.ALTERNATIVE"</span><span>); </span></span></li><li class=""><span> GPSIntent.setData(Uri.parse(<span class="string">"custom:3"</span><span>)); </span></span></li><li class="alt"><span> <span class="keyword">try</span><span> { </span></span></li><li class=""><span> PendingIntent.getBroadcast(context, <span class="number">0</span><span>, GPSIntent, </span><span class="number">0</span><span>).send(); </span></span></li><li class="alt"><span> } <span class="keyword">catch</span><span> (CanceledException e) { </span></span></li><li class=""><span> e.printStackTrace(); </span></li><li class="alt"><span> } </span></li><li class=""><span> } </span></li></ol><div class="save_code tracking-ad" data-mod="popu_249" style="display: none;"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre class="java" name="code" style="display: none;">/**
* 强制帮用户打开GPS
* @param context
*/
public static final void openGPS(Context context) {
Intent GPSIntent = new Intent();
GPSIntent.setClassName("com.android.settings",
"com.android.settings.widget.SettingsAppWidgetProvider");
GPSIntent.addCategory("android.intent.category.ALTERNATIVE");
GPSIntent.setData(Uri.parse("custom:3"));
try {
PendingIntent.getBroadcast(context, 0, GPSIntent, 0).send();
} catch (CanceledException e) {
e.printStackTrace();
}
}</pre>
<p>三、在AndroidManifest.xml文件里需要添加的权限:</p>
<div class="dp-highlighter bg_html"><div class="bar"><div class="tools"><b>[html]</b> <a href="#" class="ViewSource" title="view plain" οnclick="dp.sh.Toolbar.Command('ViewSource',this);return false;">view plain</a><span data-mod="popu_168"> <a href="#" class="CopyToClipboard" title="copy" οnclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;">copy</a><div style="position: absolute; left: 723px; top: 1661px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_3" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_3" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=3&width=18&height=18" wmode="transparent"></div></span><span data-mod="popu_169"> <a href="#" class="PrintSource" title="print" οnclick="dp.sh.Toolbar.Command('PrintSource',this);return false;">print</a></span><a href="#" class="About" title="?" οnclick="dp.sh.Toolbar.Command('About',this);return false;">?</a></div></div><ol start="1" class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">uses-permission</span><span> </span><span class="attribute">android:name</span><span>=</span><span class="attribute-value">"android.permission.ACCESS_COARSE_LOCATION"</span><span> </span><span class="tag">/></span><span> </span></span></li><li class=""><span><span class="tag"><</span><span class="tag-name">uses-permission</span><span> </span><span class="attribute">android:name</span><span>=</span><span class="attribute-value">"android.permission.ACCESS_FINE_LOCATION"</span><span> </span><span class="tag">/></span><span> </span></span></li><li class="alt"><span><span class="tag"><</span><span class="tag-name">uses-permission</span><span> </span><span class="attribute">android:name</span><span>=</span><span class="attribute-value">"android.permission.ACCESS_WIFI_STATE"</span><span> </span><span class="tag">/></span><span> </span></span></li><li class=""><span><span class="tag"><</span><span class="tag-name">uses-permission</span><span> </span><span class="attribute">android:name</span><span>=</span><span class="attribute-value">"android.permission.ACCESS_NETWORK_STATE"</span><span> </span><span class="tag">/></span><span> </span></span></li><li class="alt"><span><span class="tag"><</span><span class="tag-name">uses-permission</span><span> </span><span class="attribute">android:name</span><span>=</span><span class="attribute-value">"android.permission.CHANGE_WIFI_STATE"</span><span> </span><span class="tag">/></span><span> </span></span></li><li class=""><span><span class="tag"><</span><span class="tag-name">uses-permission</span><span> </span><span class="attribute">android:name</span><span>=</span><span class="attribute-value">"android.permission.INTERNET"</span><span> </span><span class="tag">/></span><span> </span></span></li></ol><div class="save_code tracking-ad" data-mod="popu_249" style="display: none;"><a href="javascript:;" target="_blank"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div><pre class="html" name="code" style="display: none;"> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" /></pre>
</div>