{"id":1259,"date":"2023-03-18T09:49:37","date_gmt":"2023-03-18T01:49:37","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1259"},"modified":"2023-04-29T09:27:34","modified_gmt":"2023-04-29T01:27:34","slug":"android-access-google-play-service","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/18\/android-access-google-play-service\/","title":{"rendered":"Android\u63a5\u5165Google Play Service"},"content":{"rendered":"<h2>\u5fc5\u987b\u6761\u4ef6<\/h2>\n<p>\u5982\u6d4b\u8bd5Google\u767b\u5f55\u7684\u6761\u4ef6: <\/p>\n<p><!-- more --><\/p>\n<ul>\n<li>\u624b\u673a\u5177\u5907\u7ffb\u5899\u80fd\u529b<\/li>\n<li>\u624b\u673a\u4e3aGoogle\u624b\u673a\u6216\u8005\u5b89\u88c5Google Play service\uff08\u5404\u5927\u5e94\u7528\u5e02\u573a\u641c\u7d22\u8c37\u6b4c\u5b89\u88c5\u5668\uff09<\/li>\n<li>\u5e94\u7528\u7b7e\u540d\u914d\u7f6e\u6b63\u786e<\/li>\n<li>google-services.json\u4e3a\u6700\u65b0\u5e76\u653e\u7f6e\u5728module\u76ee\u5f55\u4e0b<\/li>\n<\/ul>\n<h2>\u5f15\u5165Google Play Service<\/h2>\n<p>\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/developers.google.com\/android\/guides\/setup\">https:\/\/developers.google.com\/android\/guides\/setup<\/a><\/p>\n<h2>\u914d\u7f6eAndroidManifest<\/h2>\n<pre><code class=\"language-xml\">&lt;meta-data android:name=&quot;com.google.android.gms.version&quot;\n    android:value=&quot;@integer\/google_play_services_version&quot; \/&gt;<\/code><\/pre>\n<pre><code class=\"language-xml\">&lt;resources&gt;\n    &lt;!-- Android-Sdk\\extras\\google\\m2repository\\com\\google\\android\\gms\\play-services --&gt;\n    &lt;integer name=&quot;google_play_services_version&quot;&gt;12451000&lt;\/integer&gt;\n&lt;\/resources&gt;<\/code><\/pre>\n<h2>\u5224\u65adGoogle Play Service\u662f\u5426\u53ef\u7528<\/h2>\n<pre><code class=\"language-java\">public static boolean isGooglePlayServicesAvailable(Activity activity) {\n    GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();\n    Integer resultCode = googleApiAvailability.isGooglePlayServicesAvailable(activity);\n    if (resultCode != ConnectionResult.SUCCESS) {\n        Dialog dialog = googleApiAvailability.getErrorDialog(activity, resultCode, 0);\n        if (dialog != null) {\n            dialog.show();\n        }\n        return false;\n    }\n    return true;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5fc5\u987b\u6761\u4ef6 \u5982\u6d4b\u8bd5Google\u767b\u5f55\u7684\u6761\u4ef6: \u624b\u673a\u5177\u5907\u7ffb\u5899\u80fd\u529b \u624b\u673a\u4e3aGoogle\u624b\u673a\u6216\u8005\u5b89\u88c5Google Pla [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[239],"class_list":["post-1259","post","type-post","status-publish","format-standard","hentry","category-android-basic","tag-google"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1259"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1259\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}