{"id":1908,"date":"2022-11-25T18:00:42","date_gmt":"2022-11-25T10:00:42","guid":{"rendered":"https:\/\/app.applebyme.cn\/cloud\/appshangjia\/1908.html"},"modified":"2022-11-25T18:00:42","modified_gmt":"2022-11-25T10:00:42","slug":"%e5%b0%8f%e7%b1%b3%e5%bc%80%e5%8f%91%e5%b9%b3%e5%8f%b0-%e5%85%b3%e4%ba%8e%e6%97%a0gps%e7%a1%ac%e4%bb%b6%e6%9c%ba%e5%9e%8b%e7%9a%84%e4%bd%8d%e7%bd%ae%e6%9c%8d%e5%8a%a1%e9%80%82%e9%85%8d%e8%af%b4","status":"publish","type":"post","link":"https:\/\/app.applebyme.cn\/cloud\/appshangjia\/1908.html","title":{"rendered":"\u5c0f\u7c73\u5f00\u53d1\u5e73\u53f0 \u5173\u4e8e\u65e0GPS\u786c\u4ef6\u673a\u578b\u7684\u4f4d\u7f6e\u670d\u52a1\u9002\u914d\u8bf4\u660e"},"content":{"rendered":"<p><span class=\"wpcom_tag_link\">\u5c0f\u7c73<\/span>\u5f00\u53d1\u5e73\u53f0 \u5173\u4e8e<span class=\"wpcom_tag_link\">\u65e0GPS\u786c\u4ef6<\/span>\u673a\u578b\u7684\u4f4d\u7f6e\u670d\u52a1\u9002\u914d\u8bf4\u660e<\/p>\n<h2 id=\"_0\">1.\u80cc\u666f<\/h2>\n<p>\u7531\u4e8e\u90e8\u5206WiFi\u7248\u672c\u7684\u5c0f\u7c73\u5e73\u677f\uff08\u4f8b\u5982\uff1a\u5c0f\u7c73\u5e73\u677f5 WiFi\u7248\u7b49\uff09\u65e0<span class=\"wpcom_tag_link\">GPS\u786c\u4ef6<\/span>\uff0c\u5373\u4f7f\u7528\u6237\u5f00\u542f\u4f4d\u7f6e\u670d\u52a1\uff0c\u5e94\u7528\u4e5f\u65e0\u6cd5\u83b7\u53d6\u5230<span class=\"wpcom_tag_link\">GPS<\/span> Provider\uff0c\u90e8\u5206\u4f9d\u8d56\u4e8eGPS\u4f4d\u7f6e\u670d\u52a1\u7684\u5e94\u7528\u53ef\u80fd\u4f1a\u63d0\u793a\u201c\u672a\u5f00\u542f\u4f4d\u7f6e\u670d\u52a1\u6216\u51fa\u73b0\u5176\u4ed6\u95ee\u9898\u201d\uff0c\u7528\u6237\u4f53\u9a8c\u8f83\u5dee\u3002<\/p>\n<h2 id=\"_1\">2.\u9002\u914d\u8bf4\u660e<\/h2>\n<p>\u9488\u5bf9\u65e0GPS\u786c\u4ef6\u7684\u673a\u578b\uff0c\u5e94\u7528\u53ef\u4ee5\u901a\u8fc7\u68c0\u6d4b<span class=\"wpcom_tag_link\">Location Proveders<\/span>\u4e2d\u662f\u5426\u5305\u542b&#8221;gps&#8221;\u6765\u5224\u65ad\u662f\u5426\u6709GPS\u786c\u4ef6\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u53ef\u4ee5\u901a\u8fc7\u68c0\u6d4b<span class=\"wpcom_tag_link\">Network Provider<\/span>\u72b6\u6001\u6765\u5224\u65ad\u7528\u6237\u662f\u5426\u6253\u5f00\u4f4d\u7f6e\u670d\u52a1\u3002<\/p>\n<p>\u53c2\u8003Demo\u5982\u4e0b\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>LocationManager lm = (Locat<a href=\"https:\/\/app.applebyme.cn\/shengcheng-125.html\">\u684c\u9762app\u6253\u5305\u751f\u6210<\/a>ionManager)getSystemService(Context.LOCATION_SERVICE);\n<em>\/\/ \u65e0GPS\u8bbe\u5907\u901a\u8fc7\u5224\u65adNetwork Provider\u6765\u5224\u65ad\u4f4d\u7f6e\u670d\u52a1\u662f\u5426\u6253\u5f00<\/em>\n<em>\/\/ \u5176\u4ed6\u8bbe\u5907\u4ecd\u7136\u901a\u8fc7GPS Provider\u6765\u5224\u65ad\u4f4d\u7f6e\u670d\u52a1\u662f\u5426\u6253\u5f00<\/em>\n<strong>if<\/strong> (!isGPSExist(lm) &amp;&amp; isNetworkLocationAble(lm) || isGpsAble(lm)) {\n    <em>\/\/ \u7528\u6237\u5df2\u5f00\u542f\u4f4d\u7f6e\u670d\u52a1<\/em>\n    <em>\/\/ \u5e94\u7528\u81ea\u8eab\u5b9a\u4f4d\u903b\u8f91<\/em>\n} <strong>else<\/strong> {\n    <em>\/\/ \u63d0\u9192\u7528\u6237\u672a\u5f00\u542f\u4f4d\u7f6e\u670d\u52a1\uff0c\u5f15\u5bfc\u7528\u6237\u81f3\u4f4d\u7f6e\u670d\u52a1\u8bbe\u7f6e\u9875\u9762<\/em>\n    openLocationService();\n}\n\n<em>\/\/ \u5e94\u7528\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u5224\u65ad\u662f\u5426\u6709GPS\u786c\u4ef6<\/em>\n<strong>public<\/strong> <strong>static<\/strong> <strong>boolean<\/strong> <strong>isGPSExist<\/strong>(LocationManager lm) {\n    <strong>return<\/strong> lm.getAllProviders().contains(\"gps\");\n}\n\n<strong>private<\/strong> <strong>boolean<\/strong> <strong>isGpsAble<\/strong>(LocationManager lm){\n    <strong>return<\/strong> lm.isProviderEnabled(LocationManager.GPS_PROVIDER);\n}\n\n<strong>private<\/strong> <strong>boolean<\/strong> <strong>isNetworkLocationAble<\/strong>(LocationManager lm){\n     <strong>return<\/strong> lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);\n}\n\n<strong>private<\/strong> <strong>void<\/strong> <strong>openLocationService<\/strong>()(){\n    Intent intent = <strong>new<\/strong> Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);\n    startActivity(intent);\n}<\/code><\/pre>\n<h2 id=\"_2\">3.\u4f18\u5316\u5efa\u8bae<\/h2>\n<p>\u5982\u679c\u5e94\u7528\u5bf9GP<a href=\"https:\/\/app.applebyme.cn\/shengcheng-103.html\">\u751f\u6210web app<\/a>S\u6709\u5f3a\u4f9d\u8d56\uff0c\u5efa\u8bae\u5e94\u7528\u4f18\u5316\u65b0\u589e\u76f8\u5173\u53cb\u597d\u63d0\u793a\u3002<\/p>\n<p>\u7f16\u8f91\uff1ayimen\uff0c\u5982\u82e5\u8f6c\u8f7d\uff0c\u8bf7\u6ce8\u660e\u51fa\u5904\uff1ahttps:\/\/www.yimenapp.com\/kb-yimen\/12696\/<\/p>\n<p>\u90e8\u5206\u5185\u5bb9\u6765\u81ea\u7f51\u7edc\u6295\u7a3f\uff0c\u5982\u6709\u4fb5\u6743\u8054\u7cfb\u7acb\u5220<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c0f\u7c73\u5f00\u53d1\u5e73\u53f0 \u5173\u4e8e\u65e0GPS\u786c\u4ef6\u673a\u578b\u7684\u4f4d\u7f6e\u670d\u52a1\u9002\u914d\u8bf4\u660e1.\u80cc\u666f\u7531\u4e8e\u90e8\u5206WiFi\u7248\u672c\u7684\u5c0f\u7c73\u5e73\u677f\uff08\u4f8b\u5982\uff1a\u5c0f\u7c73\u5e73\u677f5 WiFi\u7248\u7b49\uff09\u65e0GPS\u786c\u4ef6\uff0c\u5373\u4f7f\u7528\u6237\u5f00\u542f\u4f4d\u7f6e\u670d\u52a1\uff0c\u5e94\u7528\u4e5f\u65e0\u6cd5\u83b7\u53d6\u5230GPS Provider\uff0c\u90e8\u5206\u4f9d\u8d56\u4e8eGPS\u4f4d\u7f6e\u670d\u52a1\u7684\u5e94\u7528\u53ef\u80fd\u4f1a\u63d0\u793a\u201c\u672a\u5f00\u542f\u4f4d\u7f6e\u670d\u52a1\u6216\u51fa\u73b0\u5176\u4ed6\u95ee\u9898\u201d\uff0c\u7528\u6237\u4f53\u9a8c\u8f83\u5dee\u30022.\u9002\u914d\u8bf4<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[836,548,1322],"class_list":["post-1908","post","type-post","status-publish","format-standard","hentry","category-appshangjia","tag-836","tag-548","tag-1322"],"_links":{"self":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/1908","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/comments?post=1908"}],"version-history":[{"count":0,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/1908\/revisions"}],"wp:attachment":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/media?parent=1908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/categories?post=1908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/tags?post=1908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}