{"id":462,"date":"2012-08-13T00:23:51","date_gmt":"2012-08-12T16:23:51","guid":{"rendered":"http:\/\/guoh.ai\/lifelog\/?p=462"},"modified":"2012-08-13T00:23:51","modified_gmt":"2012-08-12T16:23:51","slug":"asop-camera-source-code-reading-start-camera-app-from-camera-button","status":"publish","type":"post","link":"https:\/\/guoh.ai\/lifelog\/2012\/08\/asop-camera-source-code-reading-start-camera-app-from-camera-button\/","title":{"rendered":"\u8bfbAOSP\u7684Camera\u6e90\u7801\u4e4bCamera Button\u542f\u52a8Camera APP"},"content":{"rendered":"<p>\u6253\u7b97\u628a\u5e73\u65f6\u9605\u8bfbAOSP Camera\u6e90\u7801\u7684\u8fc7\u7a0b\u8bb0\u5f55\u4e0b\uff0c\u6709\u4e9b\u5730\u65b9\u6ca1\u6709\u5f88\u7cbe\u786e\u7684\u53bb\u63e3\u6469\uff0c\u6240\u4ee5\u5982\u679c\u7406\u89e3\u6709\u8bef\uff0c\u70e6\u8bf7\u5927\u5bb6\u6307\u51fa\uff01<\/p>\n<p>Camera Button\u542f\u52a8APP\uff0c\u8fd9\u4e2a\u6bd4\u8f83\u7b80\u5355\u3002\u539f\u7406\u5c31\u662f\u5f53\u4f60\u957f\u6309Camera Button\u7684\u65f6\u5019\uff0c\u7cfb\u7edf\u4f1a\u53d1\u51fa\u4e00\u4e2aBroadcast\uff0c\u6240\u4ee5APP\u53ea\u9700\u8981\u6ce8\u518c\u4e00\u4e2aReceiver\u6765\u63a5\u6536\u8fd9\u4e2abroadcast message\u5c31\u597d\uff0c\u5f53\u6536\u5230\u8fd9\u4e2a\u6d88\u606f\u540e\u5c31\u53bb\u542f\u52a8APP\u3002<\/p>\n<p>\u76f4\u63a5\u7528\u4ee3\u7801\u8bf4\u660e<\/p>\n<p>Manifest\u5f53\u4e2d\u6709\u8fd9\u6bb5\u914d\u7f6e<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;receiver android:name=&quot;com.android.camera.CameraButtonIntentReceiver&quot;&gt;\r\n    &lt;intent-filter&gt;\r\n        &lt;action android:name=&quot;android.intent.action.CAMERA_BUTTON&quot;\/&gt;\r\n    &lt;\/intent-filter&gt;\r\n&lt;\/receiver&gt;<\/pre>\n<p>\u8fd9\u4e2aCameraButtonIntentReceiver\u4e2d\u4f1a\u53bb\u542f\u52a8APP\uff0c\u4f46\u662f\u5b83\u91cc\u9762\u6709\u4e2a\u5224\u65ad\uff0c\u5148\u5224\u65adHardware\u53ef\u4e0d\u53ef\u4ee5\u7528\uff0c\u5982\u679c\u53ef\u4ee5\u7528\uff0c\u5c31\u53bb\u542f\u52a8APP\uff0c\u4e0d\u53ef\u4ee5\u7528\u5c31\u4ec0\u4e48\u90fd\u4e0d\u505a\uff0c\u76f4\u63a5return\u6389\u3002\u597d\u5904\u5927\u6982\u5c31\u662f\u9632\u6b62\u5f53\u4f60\u7cfb\u7edf\u8fd0\u884c\u4e86\u5f88\u591a\u6307\u4ee4\u4e4b\u540e\uff0c\u53d1\u73b0HW\u4e0d\u53ef\u4ee5\u7528\uff0c\u5c3d\u65e9\u7684\u628a\u9519\u8bef\u544a\u8bc9\u7528\u6237\uff0c\u8fd9\u662f\u4e00\u4e2a\u826f\u597d\u7684\u7a0b\u5e8f\u8bbe\u8ba1\u601d\u8def\u3002<\/p>\n<p>\u8fd9\u91cc\u9700\u8981\u5173\u6ce8\u7684\u5c31\u662fCameraHolder\uff0c\u5b83\u7684\u4f5c\u7528\u7ea7\u662f\u4fdd\u6301\u4e00\u4e2aandroid.hardware.Camera\u5b9e\u4f8b\uff0c\u5e76\u4e14\u8bb0\u5f55\u6709\u591a\u5c11\u201c\u7528\u6237\u201d\u6253\u5f00\u4e86android.hardware.Camera\u8fd9\u4e2a\u8d44\u6e90\uff0c\u4ece\u5b83\u7684mUsers\u5c5e\u6027\u53ef\u4ee5\u770b\u51fa\u3002<br \/>\nCameraHolder\u8fd9\u4e2a\u6709\u4e2a\u5c0f\u5c0f\u7684\u7279\u6b8a\u7684\u5730\u65b9\uff0c\u5c31\u662f\u5982\u679c\u4f60\u6709call\u5b83\u7684keep\u65b9\u6cd5\uff0c\u5b83\u4f1a\u5728\u4f60call\u5b83\u7684release\u65b9\u6cd5\u7684\u65f6\u5019\u77ed\u6682\u7684\u4fdd\u6301android.hardware.Camera\u4e0d\u88ab\u91ca\u653e\u6389(\u8fd9\u91cc\u662f3\u79d2)\uff0c\u8fd9\u65f6\u5982\u679c\u4f60\u518d\u6b21\u8c03\u7528open\u65b9\u6cd5\uff0c\u5c31\u4f1a\u8282\u7701\u4e00\u4e9b\u4e0d\u5fc5\u8981\u7684\u5f00\u9500\u3002<\/p>\n<p>\u8fd9\u91cc\u5f00\u542f\u7684\u8fc7\u7a0b\u5c31\u4e0d\u8bf4\u4e86\uff0c\u6bd4\u8f83\u7b80\u5355\u660e\u4e86\u3002Receiver\u4e2d\u4e00\u4e2astartActivity\u5c31\u5b8c\u6210\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6253\u7b97\u628a\u5e73\u65f6\u9605\u8bfbAOSP Camera\u6e90\u7801\u7684\u8fc7\u7a0b\u8bb0\u5f55\u4e0b\uff0c\u6709\u4e9b\u5730\u65b9\u6ca1\u6709\u5f88\u7cbe\u786e\u7684\u53bb\u63e3\u6469\uff0c\u6240\u4ee5\u5982\u679c\u7406\u89e3\u6709\u8bef\uff0c\u70e6\u8bf7\u5927\u5bb6\u6307\u51fa\uff01 Camera Button\u542f\u52a8APP\uff0c\u8fd9\u4e2a\u6bd4\u8f83\u7b80\u5355\u3002\u539f\u7406\u5c31\u662f\u5f53\u4f60\u957f\u6309Camera Button\u7684\u65f6\u5019\uff0c\u7cfb\u7edf\u4f1a\u53d1\u51fa\u4e00\u4e2aBroadcast\uff0c\u6240\u4ee5APP\u53ea\u9700\u8981\u6ce8\u518c\u4e00\u4e2aReceiver\u6765\u63a5\u6536\u8fd9\u4e2abroadcast message\u5c31\u597d\uff0c\u5f53\u6536\u5230\u8fd9\u4e2a\u6d88\u606f\u540e\u5c31\u53bb\u542f\u52a8APP\u3002 \u76f4\u63a5\u7528\u4ee3\u7801\u8bf4\u660e Manifest\u5f53\u4e2d\u6709\u8fd9\u6bb5\u914d\u7f6e &lt;receiver android:name=&quot;com.android.camera.CameraButtonIntentReceiver&quot;&gt; &lt;intent-filter&gt; &lt;action android:name=&quot;android.intent.action.CAMERA_BUTTON&quot;\/&gt; &lt;\/intent-filter&gt; &lt;\/receiver&gt; \u8fd9\u4e2aCameraButtonIntentReceiver\u4e2d\u4f1a\u53bb\u542f\u52a8APP\uff0c\u4f46\u662f\u5b83\u91cc\u9762\u6709\u4e2a\u5224\u65ad\uff0c\u5148\u5224\u65adHardware\u53ef\u4e0d\u53ef\u4ee5\u7528\uff0c\u5982\u679c\u53ef\u4ee5\u7528\uff0c\u5c31\u53bb\u542f\u52a8APP\uff0c\u4e0d\u53ef\u4ee5\u7528\u5c31\u4ec0\u4e48\u90fd\u4e0d\u505a\uff0c\u76f4\u63a5return\u6389\u3002\u597d\u5904\u5927\u6982\u5c31\u662f\u9632\u6b62\u5f53\u4f60\u7cfb\u7edf\u8fd0\u884c\u4e86\u5f88\u591a\u6307\u4ee4\u4e4b\u540e\uff0c\u53d1\u73b0HW\u4e0d\u53ef\u4ee5\u7528\uff0c\u5c3d\u65e9\u7684\u628a\u9519\u8bef\u544a\u8bc9\u7528\u6237\uff0c\u8fd9\u662f\u4e00\u4e2a\u826f\u597d\u7684\u7a0b\u5e8f\u8bbe\u8ba1\u601d\u8def\u3002 \u8fd9\u91cc\u9700\u8981\u5173\u6ce8\u7684\u5c31\u662fCameraHolder\uff0c\u5b83\u7684\u4f5c\u7528\u7ea7\u662f\u4fdd\u6301\u4e00\u4e2aandroid.hardware.Camera\u5b9e\u4f8b\uff0c\u5e76\u4e14\u8bb0\u5f55\u6709\u591a\u5c11\u201c\u7528\u6237\u201d\u6253\u5f00\u4e86android.hardware.Camera\u8fd9\u4e2a\u8d44\u6e90\uff0c\u4ece\u5b83\u7684mUsers\u5c5e\u6027\u53ef\u4ee5\u770b\u51fa\u3002 CameraHolder\u8fd9\u4e2a\u6709\u4e2a\u5c0f\u5c0f\u7684\u7279\u6b8a\u7684\u5730\u65b9\uff0c\u5c31\u662f\u5982\u679c\u4f60\u6709call\u5b83\u7684keep\u65b9\u6cd5\uff0c\u5b83\u4f1a\u5728\u4f60call\u5b83\u7684release\u65b9\u6cd5\u7684\u65f6\u5019\u77ed\u6682\u7684\u4fdd\u6301android.hardware.Camera\u4e0d\u88ab\u91ca\u653e\u6389(\u8fd9\u91cc\u662f3\u79d2)\uff0c\u8fd9\u65f6\u5982\u679c\u4f60\u518d\u6b21\u8c03\u7528open\u65b9\u6cd5\uff0c\u5c31\u4f1a\u8282\u7701\u4e00\u4e9b\u4e0d\u5fc5\u8981\u7684\u5f00\u9500\u3002 \u8fd9\u91cc\u5f00\u542f\u7684\u8fc7\u7a0b\u5c31\u4e0d\u8bf4\u4e86\uff0c\u6bd4\u8f83\u7b80\u5355\u660e\u4e86\u3002Receiver\u4e2d\u4e00\u4e2astartActivity\u5c31\u5b8c\u6210\u4e86\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_gfmr_meta_descriptions":[],"_gfmr_multilingual_taxonomy_terms":[],"footnotes":""},"categories":[7],"tags":[27],"class_list":["post-462","post","type-post","status-publish","format-standard","hentry","category-android","tag-camera"],"_links":{"self":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/462","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/comments?post=462"}],"version-history":[{"count":2,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/462\/revisions"}],"predecessor-version":[{"id":464,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/462\/revisions\/464"}],"wp:attachment":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/media?parent=462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/categories?post=462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/tags?post=462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}