{"id":21955,"date":"2024-01-24T15:08:28","date_gmt":"2024-01-24T07:08:28","guid":{"rendered":"https:\/\/www.zhidianwl.com\/zhidian\/?p=21955"},"modified":"2024-01-24T15:08:28","modified_gmt":"2024-01-24T07:08:28","slug":"android%e5%bc%80%e5%8f%91%e5%ae%9e%e7%8e%b0apk%e5%88%86%e4%ba%ab%e5%8a%9e%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.com\/zhidian\/2024\/21955\/","title":{"rendered":"android\u5f00\u53d1\u5b9e\u73b0apk\u5206\u4eab\u529e\u6cd5"},"content":{"rendered":"

<\/figure>\n<\/p>\n

Android\u5f00\u53d1\u4e2d\u5b9e\u73b0APK\u5206\u4eab\u7684\u539f\u7406\u5f88\u7b80\u5355\uff0c\u4e3b\u8981\u6d89\u53ca\u5230\u4e24\u4e2a\u6b65\u9aa4\uff1a\u751f\u6210APK\u6587\u4ef6\u548c\u5206\u4eabAPK\u6587\u4ef6\u3002\u4e0b\u9762\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e24\u4e2a\u6b65\u9aa4\u3002<\/p>\n

1. \u751f\u6210APK\u6587\u4ef6<\/p>\n

\u5728Android\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528Android Studio\u4f5c\u4e3a\u5f00\u53d1\u5de5\u5177\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u751f\u6210APK\u6587\u4ef6\u3002\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684\u9879\u76ee\u4ee3\u7801\u5df2\u7ecf\u5b8c\u6210\uff0c\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u3002\u7136\u540e\uff0c\u6309\u4ee5\u4e0b\u6b65\u9aa4\u751f\u6210APK\u6587\u4ef6\uff1a<\/p>\n

1. \u6253\u5f00Android Studio\uff0c\u6253\u5f00\u4f60\u7684\u9879\u76ee\u3002<\/p>\n

2. \u70b9\u51fb\u83dc\u5355\u680f\u4e2d\u7684”Build”\uff0c\u9009\u62e9”Build Bundle(s) \/ APK(s)”\uff0c\u7136\u540e\u9009\u62e9”Build APK(s)”\u9009\u9879\u3002<\/p>\n

3. Android Studio\u4f1a\u5f00\u59cb\u6784\u5efa\u4f60\u7684\u9879\u76ee\uff0c\u5e76\u751f\u6210APK\u6587\u4ef6\u3002\u6784\u5efa\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u5728”app\/build\/outputs\/apk\/”\u76ee\u5f55\u4e0b\u627e\u5230\u751f\u6210\u7684APK\u6587\u4ef6\u3002<\/p>\n

2. \u5206\u4eabAPK\u6587\u4ef6<\/p>\n

\u751f\u6210\u4e86APK\u6587\u4ef6\u4e4b\u540e\uff0c\u6211\u4eec\u9700\u8981\u5b9e\u73b0\u5206\u4eab\u529f\u80fd\uff0c\u8ba9\u7528\u6237\u53ef\u4ee5\u5c06APK\u6587\u4ef6\u5206\u4eab\u7ed9\u5176\u4ed6\u4eba\u3002\u5b9e\u73b0APK\u5206\u4eab\u4e3b\u8981\u6709\u4e24\u79cd\u65b9\u5f0f\uff1a\u901a\u8fc7\u7b2c\u4e09\u65b9\u5e94\u7528\u5206\u4eab\u548c\u901a\u8fc7\u5e94\u7528\u5185\u5206\u4eab\u3002<\/p>\n

\uff081\uff09\u901a\u8fc7\u7b2c\u4e09\u65b9\u5e94\u7528\u5206\u4eab<\/p>\n

\u8fd9\u79cd\u65b9\u5f0f\u6bd4\u8f83\u7b80\u5355\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u7cfb\u7edf\u5206\u4eab\u529f\u80fd\uff0c\u8ba9\u7528\u6237\u9009\u62e9\u4e00\u4e2a\u7b2c\u4e09\u65b9\u5e94\u7528\u8fdb\u884c\u5206\u4eab\u3002\u5177\u4f53\u5b9e\u73b0\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n

1. \u5728\u4f60\u7684\u5e94\u7528\u4e2d\uff0c\u6dfb\u52a0\u4e00\u4e2a\u5206\u4eab\u6309\u94ae\u6216\u5176\u4ed6\u89e6\u53d1\u5206\u4eab\u64cd\u4f5c\u7684\u63a7\u4ef6\u3002<\/p>\n

2. \u5728\u6309\u94ae\u7684\u70b9\u51fb\u4e8b\u4ef6\u4e2d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u6267\u884c\u5206\u4eab\u64cd\u4f5c\uff1a<\/p>\n

“`<\/p>\n

Intent shareIntent = new Intent(Intent.ACTION_SEND);<\/p>\n

shareIntent.setType(“application\/vnd.android.package-archive”);<\/p>\n

File apkFile = new File(“\u8def\u5f84\/\u4f60\u7684APK\u6587\u4ef6.apk”);<\/p>\n

Uri apkUriapp\u6e90\u7801\u751f\u6210apk<\/a> = FileProvider.getUriForFile(context, “\u4f60\u7684FileProvider\u7684authorities”, apkFile);<\/p>\n

shareIntent.putExtra(Intent.EXTRA_STREAM, apkUri);<\/p>\n

startActivity(Intent.createChooser(shareIntent, “Share APK”));<\/p>\n

“`<\/p>\n

\u8bf7\u6ce8\u610f\uff0c\u4e0a\u8ff0\u4ee3\u7801\u4e2d\u7684”\u8def\u5f84\/\u4f60\u7684APK\u6587\u4ef6.apk”\u9700\u8981\u66ff\u6362\u4e3a\u4f60\u751f\u6210\u7684APK\u6587\u4ef6\u7684\u5b9e\u9645\u8def\u5f84\u3002”\u4f60\u7684FileProvider\u7684authorities”\u9700\u8981\u66ff\u6362\u4e3a\u4f60\u5728AndroidManifest.xml\u4e2d\u914d\u7f6e\u7684FileProvider\u7684authorities\u3002<\/p>\n

\uff082\uff09\u901a\u8fc7\u5e94\u7528\u5185\u5206\u4eab<\/p>\n

\u5982\u679c\u4f60\u5e0c\u671b\u5728\u5e94\u7528\u5185\u90e8\u5b9e\u73b0APK\u5206\u4eab\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u5171\u4eab\u7684\u6587\u4ef6\u5939\uff0c\u5c06APK\u6587\u4ef6\u62f7\u8d1d\u5230\u8be5\u6587\u4ef6\u5939\u4e0b\uff0c\u7136\u540e\u4f7f\u7528FileProvider\u83b7\u53d6\u6587\u4ef6\u7684Uri\u8fdb\u884c\u5206\u4eab\u3002\u5177\u4f53\u5b9e\u73b0\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n

1. \u521b\u5efa\u4e00\u4e2a\u5171\u4eab\u7684\u6587\u4ef6\u5939\uff0c\u7528\u4e8e\u5b58\u653eAPK\u6587\u4ef6\u3002\u53ef\u4ee5\u5728\u5e94\u7528\u7684\u6839\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a”share”\u6587\u4ef6\u5939\u3002<\/p>\n

2. \u5c06\u751f\u6210\u7684APK\u6587\u4ef6\u62f7\u8d1d\u5230”share”\u6587\u4ef6\u5939\u4e0b\u3002<\/p>\n

3. \u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fdb\u884c\u5206\u4eab\u64cd\u4f5c\uff1a<\/p>\n

“`<\/p>\n

File apkFile = new File(“\u5171\u4eab\u6587\u4ef6\u5939\u7684\u8def\u5f84\/\u4f60\u7684APK\u6587\u4ef6.apk”);<\/p>\n

Uri apkUri = FileProvider.getUriForFile(context, “\u4f60\u7684FileProvider\u7684authorities”, apkFile);<\/p>\n

Intent shareIntent = new Intent(Intent.ACTION_SEND);<\/p>\n

shareIntent.setType(“application\/vnd.android.package-archive”);<\/p>\n

shareIntent.putExtra(Intent.EXTRA_STREAM, apkUri);<\/p>\n

startActivity(Intent.createChooser(shareIntent, “Share APK”));<\/p>\n

“`<\/p>\n

\u540c\u6837\uff0c\u4e0a\u8ff0\u4ee3\u7801\u4e2d\u7684”\u5171\u4eab\u6587\u4ef6\u5939\u7684\u8def\u5f84\/\u4f60\u7684APK\u6587\u4ef6.apk”\u9700\u8981\u5728\u7ebf\u5236\u4f5capk\u8f6f\u4ef6\u7f51\u5740<\/a>\u66ff\u6362\u4e3a\u4f60\u751f\u6210\u7684APK\u6587\u4ef6\u5728\u5171\u4eab\u6587\u4ef6\u5939\u4e0b\u7684\u5b9e\u9645\u8def\u5f84\u3002<\/p>\n

\u4ee5\u4e0a\u5c31\u662f\u5b9e\u73b0Android APK\u5206\u4eab\u7684\u539f\u7406\u548c\u8be6\u7ec6\u4ecb\u7ecd\u3002\u901a\u8fc7\u751f\u6210APK\u6587\u4ef6\u548c\u5206\u4eabAPK\u6587\u4ef6\uff0c\u6211\u4eec\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06\u5e94\u7528\u5206\u4eab\u7ed9\u5176\u4ed6\u4eba\uff0c\u8ba9\u66f4\u591a\u4eba\u4f7f\u7528\u548c\u4f53\u9a8c\u6211\u4eec\u7684\u5e94\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Android\u5f00\u53d1\u4e2d\u5b9e\u73b0APK\u5206\u4eab\u7684\u539f\u7406\u5f88\u7b80\u5355\uff0c\u4e3b\u8981\u6d89\u53ca\u5230\u4e24\u4e2a\u6b65\u9aa4\uff1a\u751f\u6210APK\u6587\u4ef6\u548c\u5206\u4eabAPK\u6587\u4ef6\u3002\u4e0b\u9762\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e24\u4e2a\u6b65\u9aa4\u30021. \u751f\u6210APK\u6587\u4ef6\u5728Android\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528Android S<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[22245,171,314,26218,1822],"class_list":["post-21955","post","type-post","status-publish","format-standard","hentry","category-zuoapp","tag-appapk","tag-171","tag-314","tag-apk","tag-1822"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/21955","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/comments?post=21955"}],"version-history":[{"count":1,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/21955\/revisions"}],"predecessor-version":[{"id":22245,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/21955\/revisions\/22245"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/media?parent=21955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/categories?post=21955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/tags?post=21955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}