{"id":17,"date":"2015-02-14T15:28:14","date_gmt":"2015-02-14T15:28:14","guid":{"rendered":"https:\/\/boochlin.com\/?p=17"},"modified":"2015-03-30T02:03:48","modified_gmt":"2015-03-30T02:03:48","slug":"fmradio-%e9%96%8b%e7%99%bc%e7%ad%86%e8%a8%98-%ef%bc%88%e4%ba%94%ef%bc%89-other","status":"publish","type":"post","link":"https:\/\/boochlin.com\/?p=17","title":{"rendered":"FMRadio \u958b\u767c\u7b46\u8a18 \uff08\u4e94\uff09- Other"},"content":{"rendered":"<p><b>\u9019\u7bc7\u529f\u80fd\u55ae\u7d14\uff0c\u7d00\u9304\u5176\u4ed6\u6bd4\u8f03\u5c0f\u7684\u5143\u4ef6\u7528\u6cd5\uff0c\u4e5f\u662fFMRadio\u6700\u5f8c\u4e00\u7bc7\u3002<\/b><\/p>\n<p>1.\u6311\u51faManifest\u6c92\u7528\u904e\u7684\u53c3\u6578\uff0c\u7b46\u8a18\u4e0b\u4f86<\/p>\n<p>2.FMMediaButtonIntentReceiver.java \u7684 ACTION \u76f8\u95dc<\/p>\n<p><!--more--><\/p>\n<h2>1.Android Manifest note:<\/h2>\n<pre>[supports-screens\r\n \u00a0\u00a0\u00a0android:largeScreens=\"true\"\r\n\r\n \u00a0\u00a0\u00a0android:normalScreens=\"true\"\r\n\r\n \u00a0\u00a0\u00a0android:smallScreens=\"true\"\r\n\r\n \u00a0\u00a0\u00a0android:anyDensity=\"false\"\/]\r\n<\/pre>\n<p>\u300cnormalScreens\u300d\u4ee3\u8868\u7684\u662f\u4e00\u822c\u89e3\u6790\u5ea6\uff08\u5982 G1, Hero\uff09\uff0c\u300csmallScreens\u300d\u4ee3\u8868\u7684\u662f\u8f03\u4f4e\u89e3\u6790\u5ea6\uff08\u5982 Tatoo\uff09\u3002<\/p>\n<p>\u73fe\u5728\u5c07\u7a0b\u5f0f\u767c\u4f48\u5230 Android Market \u6642\u82e5\u6c92\u505a\u4ee5\u4e0a\u8a2d\u5b9a\uff0c\u4f60\u5beb\u7684\u7a0b\u5f0f\u5c07\u4e0d\u6703\u986f\u793a\u5728 QVGA\/WVGA \u6a5f\u5668\u7684 Market \u4e2d\u3002<\/p>\n<p>PS: \u5c07 Target \u8a2d\u70ba 1.6 \u8ddf\u5728 AndroidManifest \u6e05\u55ae\u4e2d\u8a2d\u5b9a minSdkVersion \u6700\u4f4e\u76f8\u5bb9\u7248\u672c\u4e26\u4e0d\u885d\u7a81\uff0c\u53ea\u8981 minSdkVersion \u7dad\u6301\u4e0d\u8b8a\uff0c\u4f4e\u65bc 1.6 \u7248\u7684\u6a5f\u5668\u9084\u662f\u53ef\u4ee5\u4f7f\u7528\u4f60\u7684\u7a0b\u5f0f\u3002<\/p>\n<p>update: \u4e8b\u5be6\u4e0a\u300csmallScreens\u300d\u4ee3\u8868\u7684\u662f\u5c0f\u87a2\u5e55\uff0c\u300cnormalScreens\u300d\u662f\u4e00\u822c\u87a2\u5e55\uff0c\u300clargeScreens\u300d\u7576\u7136\u662f\u5927\u87a2\u5e55\u3002\u4e00\u822c\u4e09\u8005\u7684\u5206\u754c\u9ede\u5927\u6982\u57283\u540b\u8ddf4\u540b\u3002\u6240\u4ee5 Tattoo (2.8&#8243;) \u88ab\u6b78\u5728\u300csmallScreens\u300d\u7bc4\u7587\u3002<\/p>\n<p><strong><strong>\u00a0<\/strong><\/strong><\/p>\n<pre>android:lunchmode = singleTask\r\n<\/pre>\n<p><strong><strong>\u00a0<\/strong><\/strong><\/p>\n<p>\u8be5\u6a21\u5f0f\u7684Activity\u662f\u5355\u4f8b\u7684\uff0c\u5373\u5728\u540c\u4e00\u65f6\u523bAndroid\u7cfb\u7edf\u4e2d\u53ea\u80fd\u5b58\u5728\u8be5Activity<\/p>\n<p>\u7684\u4e00\u4e2a\u5b9e\u4f8b\uff0c\u6240\u4ee5\u5f53\u91cd\u590d\u542f\u52a8\u8be5Activity\u65f6\u5e76\u4e0d\u4f1a\u521b\u5efa\u8be5Activity\u7684\u65b0\u5b9e\u4f8b\uff0c\u800c<\/p>\n<p>\u662f\u91cd\u65b0\u4f7f\u8be5Activity\u7684\u5b9e\u4f8b\u8fdb\u5165\u4ea4\u4e92\u72b6\u6001\uff0c\u5982\u679c\u8be5Activity\u7684\u5b9e\u4f8b\u4e0d\u4f4d\u4e8e\u5f53\u524d\u4efb<\/p>\n<p>\u52a1\u7684\u6808\u9876\uff0c\u5219\u5c06\u8be5\u5b9e\u4f8b\u4e4b\u4e0a\u7684\u6240\u6709Activity\u91ca\u653e\uff0c\u4ee5\u4f7f\u8be5Activity\u91cd\u65b0\u6210\u4e3a\u6808\u9876\u3002<\/p>\n<p><span style=\"color: #ff0000;\">ps.\u70ba\u4e86\u8b93fmradiomain\u6c38\u9060\u53ea\u6709\u4e00\u500b<\/span><\/p>\n<p><strong><strong>\u00a0<\/strong><\/strong><\/p>\n<p><b>receiver\u4e2d\u7684<\/b><\/p>\n<pre>ACTION_MEDIA_BUTTON \u00a0=\"android.intent.action.MEDIA_BUTTON\"\r\n<\/pre>\n<p>Intent \u9644\u52a0\u503c\u4e3a(Extra)\u70b9\u51fbMEDIA_BUTTON\u7684\u6309\u952e\u7801 \uff1a<\/p>\n<p>\/\/\u83b7\u5f97KeyEvent\u5bf9\u8c61<\/p>\n<pre>KeyEvent keyEvent = (KeyEvent)intent.getParcelableExtra(Intent.<i>EXTRA_KEY_EVENT<\/i>);\r\n<\/pre>\n<p>\/\/\u83b7\u5f97Action<\/p>\n<pre>String intentAction = intent.getAction() ;\r\n<\/pre>\n<p><span style=\"color: #ff0000;\">ps.\u76e3\u807d\u8033\u6a5f\u4e0a\u7684\u6309\u9215\u4e8b\u4ef6<\/span><\/p>\n<p>ref:http:\/\/blog.gasolin.idv.tw\/2009\/10\/android-market.html<\/p>\n<p><strong>\u6709\u4e9bref\u5fd8\u8a18\uff0csorry<\/strong><\/p>\n<h2>2.FMMediaButtonIntentReceiver.java<\/h2>\n<p>extend broadcastReceiver<\/p>\n<p>\u76e3\u807d<\/p>\n<p>android.intent.action.MEDIA_BUTTON<\/p>\n<p>(\u8033\u6a5f\u4e0a\u7684\u4e0b\u4e00\u9996\uff0c\u66ab\u505c)<\/p>\n<p>\u5229\u7528<\/p>\n<pre>KeyEvent event = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);\r\n<\/pre>\n<p>\u53d6\u51fa\u4e8b\u4ef6\u985e\u578b<\/p>\n<p>\u6839\u64daKEYCODE &amp; key_action<\/p>\n<p>\u8fa8\u8b58<\/p>\n<p>KEYCODE_HEADSETHOOK \u70ba\u5fc5\u50b3\u5230\u8981\u689d\u4ef6<\/p>\n<p>ACTION_DOWN \u70ba\u78ba\u5be6\u6309\u4e0b<\/p>\n<p>MEDIA_PAUSE OR MEDIA PLAY \u7b49\u7b26\u5408\u9700\u6c42\u7684ACTION\u78ba\u8a8d\u5f8c<\/p>\n<p>\u6700\u5f8c\u7528<\/p>\n<p>FM_MEDIA_BUTTON = &#8220;xxxxx \u00a0 \u516c\u53f8\u6a5f\u5bc6 \u00a0 xxxxx&#8221;\u70baaction\u70ba\u76ee\u6a19<\/p>\n<p>\u5c07KeyEvent event \u5305\u5728Intent.EXTRA_KEY_EVENT\u7528 context.sendBroadcast\u50b3\u7d66service\u4f7f\u7528<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9019\u7bc7\u529f\u80fd\u55ae\u7d14\uff0c\u7d00\u9304\u5176\u4ed6\u6bd4\u8f03\u5c0f\u7684\u5143\u4ef6\u7528\u6cd5\uff0c\u4e5f\u662fFMRadio\u6700\u5f8c\u4e00\u7bc7\u3002 1.\u6311\u51faManifest\u6c92\u7528\u904e\u7684\u53c3\u6578\uff0c\u7b46 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[46],"_links":{"self":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/17"}],"collection":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17"}],"version-history":[{"count":1,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":34,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions\/34"}],"wp:attachment":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}