{"id":27445,"date":"2024-07-31T15:08:08","date_gmt":"2024-07-31T07:08:08","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=27445"},"modified":"2024-07-31T15:08:08","modified_gmt":"2024-07-31T07:08:08","slug":"apk-%e4%ba%8c%e7%bb%b4%e7%a0%81%e7%94%9f%e6%88%90%e8%a6%81%e6%80%8e%e4%b9%88%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/27445\/","title":{"rendered":"apk \u4e8c\u7ef4\u7801\u751f\u6210\u8981\u600e\u4e48\u5b9e\u73b0?"},"content":{"rendered":"

APK\u4e8c\u7ef4\u7801\u751f\u6210\u662f\u4e00\u79cd\u5728Android\u5e73\u53f0\u4e0a\u5b9e\u73b0\u7684\u529f\u80fd\uff0c\u901a\u8fc7\u751f\u6210\u4e8c\u7ef4\u7801\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8bc6\u522b\u548c\u5206\u4eabAPP\u4fe1\u606f\u3002\u672c\u6587\u5c06\u4ecb\u7ecdAPK\u4e8c\u7ef4\u7801\u751f\u6210\u7684\u539f\u7406\u548c\u8be6\u7ec6\u6b65\u9aa4\u3002<\/p>\n

\u4e00\u3001\u539f\u7406\u4ecb\u7ecd\uff1a<\/p>\n

APK\u4e8c\u7ef4\u7801\u751f\u6210\u7684\u539f\u7406\u57fa\u4e8eQR\u7801\uff08Quick Response Code\uff09\uff0cQR\u7801\u662f\u4e00\u79cd\u4e8c\u7ef4\u7801\u7684\u6807\u51c6\uff0c\u53ef\u4ee5\u5b58\u50a8\u5f88\u591a\u4fe1\u606f\u3002APK\u4e8c\u7ef4\u7801\u751f\u6210\u7684\u76ee\u7684\u662f\u5c06\u4e00\u4e2aAPP\u7684\u4e0b\u8f7d\u5730\u5740\u6216\u5176\u4ed6\u76f8\u5173\u4fe1\u606f\u8f6c\u5316\u6210\u4e8c\u7ef4\u7801\u7684\u5f62\u5f0f\uff0c\u65b9\u4fbf\u7528\u6237\u901a\u8fc7\u626b\u63cf\u4e8c\u7ef4\u7801\u5feb\u901f\u8bbf\u95ee\u548c\u4e0b\u8f7dAPP\u3002<\/p>\n

\u5728\u751f\u6210APK\u4e8c\u7ef4\u7801\u65f6\uff0c\u4e3b\u8981\u7684\u539f\u7406\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a<\/p>\n

1. \u83b7\u53d6APK\u6587\u4ef6\u7684\u4e0b\u8f7d\u5730\u5740\u6216\u5176\u4ed6\u76f8\u5173\u4fe1\u606f\u3002<\/p>\n

2. \u4f7f\u7528\u4e8c\u7ef4\u7801\u751f\u6210\u5e93\u751f\u6210\u76f8\u5e94\u7684\u4e8c\u7ef4\u7801\u56fe\u7247\u3002<\/p>\n

3. \u5c06\u4e8c\u7ef4\u7801\u56fe\u7247\u63d2\u5165\u5230\u7f51\u9875\u3001APP\u754c\u9762\u6216\u5176\u4ed6\u5a92\u4ecb\u4e2d\uff0c\u4f9b\u7528\u6237\u626b\u63cf\u3002<\/p>\n

\u4e8c\u3001\u8be6\u7ec6\u4ecb\u7ecd\uff1a<\/p>\n

\u4e0b\u9762\u5c06\u9010\u6b65\u4ecb\u7ecdAPK\u4e8c\u7ef4\u7801\u751f\u6210\u7684\u8be6\u7ec6\u6b65\u9aa4\u3002<\/p>\n

1. \u83b7\u53d6APK\u6587\u4ef6\u7684\u4e0b\u8f7d\u5730\u5740\u6216\u5176\u4ed6\u76f8\u5173\u4fe1\u606f\uff1a<\/p>\n

\u5bf9\u4e8e\u4e00\u4e2a\u5df2\u7ecf\u53d1\u5e03\u7684APP\uff0c\u53ef\u4ee5\u4ece\u5e94\u7528\u5546\u5e97\u3001\u5b98\u65b9\u7f51\u7ad9\u6216\u5176\u4ed6\u6e20\u9053\u83b7\u53d6\u5230APK\u6587\u4ef6\u7684\u4e0b\u8f7d\u5730\u5740\u3002<\/p>\n

2. \u4f7f\u7528\u4e8c\u7ef4\u7801\u751f\u6210\u5e93\u751f\u6210\u4e8c\u7ef4\u7801\u56fe\u7247\uff1a<\/p>\n

\u5728Android\u5f00\u53d1\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\u6765\u751f\u6210\u4e8c\u7ef4\u7801\u56fe\u7247\u3002\u5e38\u7528\u7684\u5e93\u5305\u62ecZxing\u3001QRGen\u7b49\u3002\u4ee5Zxing\u4e3a\u4f8b\uff0c\u53ef\u4ee5\u5728Gradle\u6587\u4ef6\u4e2d\u5f15\u5165\u4f9d\u8d56\uff1a<\/p>\n

“`groovy<\/p>\n

implementation ‘com.google.zxing:core:3.3.3’<\/p>\n

implementation ‘com.journeyapps:zxing-android-embedded:4.2.0’<\/p>\n

“`<\/p>\n

\u7136\u540e\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u6765\u751f\u6210\u4e8c\u7ef4\u7801\u56fe\u7247\uff1a<\/p>\n

“`java<\/p>\n

String apkUrl = “http:\/\/example.com\/app.apk”;<\/p>\n

int width = 400;<\/p>\n

int height = 400;<\/p>\n

try {<\/p>\n

BitMatrix bitMatrix = new MultiFormatWriter().encode(apkUrl, BarcodeFormat.QR_CODE, width, height);<\/p>\n

BarcodeEncoder barcodeEncoder = new BarcodeEncoder();<\/p>\n

Bitmap bitmap = barcodeEncoder.createBitmap(bitMatrix);<\/p>\n

\/\/ \u5728\u754c\u9762\u4e0a\u5c55\u793a\u751f\u6210\u7684\u4e8c\u7ef4\u7801\u56fe\u7247<\/p>\n

} catch (WriterException e) {<\/p>\n

e.printStackTrace();<\/p>\n

}<\/p>\n

“`<\/p>\n

\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5b9a\u4e49\u4e86APK\u6587\u4ef6\u7684\u4e0b\u8f7d\u5730\u5740\uff0c\u7136\u540e\u8bbe\u7f6e\u4e86\u751f\u6210\u4e8c\u7ef4\u7801\u56fe\u7247\u7684\u5bbd\u5ea6\u548c\u9ad8\u5ea6\u3002\u63a5\u7740\u4f7f\u7528`MultiFormatWriter().encode()`\u65b9\u6cd5\u751f\u6210\u4e00\u4e2a\u4e8c\u7ef4\u7801\u7684`BitMatrix`\u5bf9\u8c61\uff0c\u518d\u901a\u8fc7`BarcodeEncoder().createBitmap()`\u65b9\u6253\u5305apk\u76f4\u63a5\u6253\u5305\u5931\u8d25<\/a>\u6cd5\u5c06`BitMatrix`\u5bf9\u8c61\u8f6c\u6362\u6210`Bitmap`\u5bf9\u8c61\uff0c\u6700\u540e\u53ef\u4ee5\u5c06\u751f\u6210\u7684\u4e8c\u7ef4\u7801\u56fe\u7247\u5c55\u793a\u5728\u754c\u9762\u4e0a\u3002<\/p>\n

3. \u5c06\u4e8c\u7ef4\u7801\u56fe\u7247\u63d2\u5165\u5230\u7f51\u9875\u3001APP\u754c\u9762\u6216\u5176\u4ed6\u5a92\u4ecb\u4e2d\uff1a<\/p>\n

\u5728\u751f\u6210\u4e86\u4e8c\u7ef4\u7801\u56fe\u7247\u4e4b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u5176\u63d2\u5165\u5230\u7f51\u9875\u3001APP\u754c\u9762\u6216\u5176\u4ed6\u5a92\u4ecb\u4e2d\uff0c\u4f9b\u7528\u6237\u626b\u63cf\u3002\u53ef\u4ee5\u4f7f\u7528`ImageView`\u6765\u5c55\u793a\u4e8c\u7ef4\u7801\u56fe\u7247\uff1a<\/p>\n

“`xml<\/p>\n<\/p>\n

android:id=”@+id\/qr_code_image”<\/p>\n

android:layout_width=”wrap_cont\u600e\u4e48\u6253\u5305apk\u4e0d\u62a5\u6bd2<\/a>ent”<\/p>\n

android:layout_height=”wrap_content” \/><\/p>\n

“`<\/p>\n

\u7136\u540e\u5728\u4ee3\u7801\u4e2d\u52a0\u8f7d\u751f\u6210\u7684\u4e8c\u7ef4\u7801\u56fe\u7247\uff1a<\/p>\n

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

“`java<\/p>\n

ImageView qrCodeImageView = findViewById(R.id.qr_code_image);<\/p>\n

qrCodeImageView.setImageBitmap(bitmap);<\/p>\n

“`<\/p>\n

\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5b9e\u73b0\u5728Android\u5e73\u53f0\u4e0a\u751f\u6210APK\u4e8c\u7ef4\u7801\uff0c\u5e76\u5c06\u5176\u5c55\u793a\u51fa\u6765\uff0c\u4f9b\u7528\u6237\u626b\u63cf\u3002<\/p>\n

\u603b\u7ed3\uff1a<\/p>\n

\u672c\u6587\u4ecb\u7ecd\u4e86APK\u4e8c\u7ef4\u7801\u751f\u6210\u7684\u539f\u7406\u548c\u8be6\u7ec6\u6b65\u9aa4\u3002\u901a\u8fc7\u83b7\u53d6APK\u6587\u4ef6\u7684\u4e0b\u8f7d\u5730\u5740\u6216\u5176\u4ed6\u76f8\u5173\u4fe1\u606f\uff0c\u4f7f\u7528\u4e8c\u7ef4\u7801\u751f\u6210\u5e93\u751f\u6210\u4e8c\u7ef4\u7801\u56fe\u7247\uff0c\u5e76\u5c06\u5176\u63d2\u5165\u5230\u7f51\u9875\u3001APP\u754c\u9762\u6216\u5176\u4ed6\u5a92\u4ecb\u4e2d\uff0c\u5b9e\u73b0\u4e86APK\u4e8c\u7ef4\u7801\u7684\u751f\u6210\u548c\u5c55\u793a\u3002\u901a\u8fc7\u626b\u63cf\u4e8c\u7ef4\u7801\uff0c\u7528\u6237\u53ef\u4ee5\u65b9\u4fbf\u5730\u8bbf\u95ee\u548c\u4e0b\u8f7dAPP\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

APK\u4e8c\u7ef4\u7801\u751f\u6210\u662f\u4e00\u79cd\u5728Android\u5e73\u53f0\u4e0a\u5b9e\u73b0\u7684\u529f\u80fd\uff0c\u901a\u8fc7\u751f\u6210\u4e8c\u7ef4\u7801\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8bc6\u522b\u548c\u5206\u4eabAPP\u4fe1\u606f\u3002\u672c\u6587\u5c06\u4ecb\u7ecdAPK\u4e8c\u7ef4\u7801\u751f\u6210\u7684\u539f\u7406\u548c\u8be6\u7ec6\u6b65\u9aa4\u3002\u4e00\u3001\u539f\u7406\u4ecb\u7ecd\uff1aAPK\u4e8c\u7ef4\u7801\u751f\u6210\u7684\u539f\u7406\u57fa\u4e8eQR\u7801\uff08Q<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[26432,2598,1189,26431,4993],"topic":[],"class_list":["post-27445","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-androidapk","tag-2598","tag-1189","tag-apk","tag-4993"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/27445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=27445"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/27445\/revisions"}],"predecessor-version":[{"id":27471,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/27445\/revisions\/27471"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=27445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=27445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=27445"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=27445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}