{"id":191,"date":"2014-05-24T14:30:58","date_gmt":"2014-05-24T06:30:58","guid":{"rendered":"http:\/\/weitaoc.com\/?p=191"},"modified":"2014-05-24T14:31:29","modified_gmt":"2014-05-24T06:31:29","slug":"android-%e5%8f%8c%e5%87%bb%e8%bf%94%e5%9b%9e%e9%94%ae%e9%80%80%e5%87%ba%e7%a8%8b%e5%ba%8f-%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"http:\/\/weitaoc.com\/?p=191","title":{"rendered":"Android \u53cc\u51fb\u8fd4\u56de\u952e\u9000\u51fa\u7a0b\u5e8f \u5b9e\u73b0"},"content":{"rendered":"<p>\u7528\u6237\u6309\u4e0b\u8fd4\u56de\u952e\u65f6\u8bbe\u5b9a\u4e00\u4e2a\u5b9a\u65f6\u5668\u6765\u76d1\u63a7\u662f\u54262\u79d2\u5185\u5b9e\u73b0\u4e86\u9000\u51fa\uff0c\u5982\u679c\u7528\u6237\u6ca1\u6709\u63a5\u7740\u6309\u8fd4\u56de\u952e\uff0c\u5219\u6e05\u9664\u7b2c\u4e00\u6b21\u6309\u8fd4\u56de\u952e\u7684\u6548\u679c\uff0c\u4f7f\u7a0b\u5e8f\u8fd8\u539f\u5230\u7b2c\u4e00\u6b21\u6309\u4e0b\u8fd4\u56de\u952e\u4e4b\u524d\u7684\u72b6\u6001\u3002\u5b9a\u65f6\u5668\u662f\u6bcf\u6b21\u7528\u6237\u6309\u4e0b\u8fd4\u56de\u952e\u624d\u53bb\u521b\u5efa\u3002<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<div class=\"codecolorer-container java geshi\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/><\/div><\/td><td><div class=\"java codecolorer\" style=\"white-space:nowrap\"><span style=\"color: #008000; font-style: italic; font-weight: bold;\">\/**<br \/>\n* \u83dc\u5355\u3001\u8fd4\u56de\u952e\u54cd\u5e94<br \/>\n*\/<\/span><br \/>\n@Override<br \/>\n<span style=\"color: #000000; font-weight: bold;\">public<\/span> <span style=\"color: #000066; font-weight: bold;\">boolean<\/span> onKeyDown<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #000066; font-weight: bold;\">int<\/span> keyCode, <span style=\"color: #003399;\">KeyEvent<\/span> event<span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\n<span style=\"color: #666666; font-style: italic;\">\/\/ TODO Auto-generated method stub<\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">if<\/span><span style=\"color: #009900;\">&#40;<\/span>keyCode <span style=\"color: #339933;\">==<\/span> <span style=\"color: #003399;\">KeyEvent<\/span>.<span style=\"color: #006633;\">KEYCODE_BACK<\/span><span style=\"color: #009900;\">&#41;<\/span><br \/>\n<span style=\"color: #009900;\">&#123;<\/span><br \/>\nexitBy2Click<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span> <span style=\"color: #666666; font-style: italic;\">\/\/\u8c03\u7528\u53cc\u51fb\u9000\u51fa\u51fd\u6570<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">return<\/span> <span style=\"color: #000066; font-weight: bold;\">false<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><br \/>\n<span style=\"color: #008000; font-style: italic; font-weight: bold;\">\/**<br \/>\n* \u53cc\u51fb\u9000\u51fa\u51fd\u6570<br \/>\n*\/<\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">private<\/span> <span style=\"color: #000000; font-weight: bold;\">static<\/span> <span style=\"color: #003399;\">Boolean<\/span> isExit <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000066; font-weight: bold;\">false<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<br \/>\n<span style=\"color: #000000; font-weight: bold;\">private<\/span> <span style=\"color: #000066; font-weight: bold;\">void<\/span> exitBy2Click<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\n<span style=\"color: #003399;\">Timer<\/span> tExit <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000066; font-weight: bold;\">null<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #000000; font-weight: bold;\">if<\/span> <span style=\"color: #009900;\">&#40;<\/span>isExit <span style=\"color: #339933;\">==<\/span> <span style=\"color: #000066; font-weight: bold;\">false<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\nisExit <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000066; font-weight: bold;\">true<\/span><span style=\"color: #339933;\">;<\/span> <span style=\"color: #666666; font-style: italic;\">\/\/ \u51c6\u5907\u9000\u51fa<\/span><br \/>\nToast.<span style=\"color: #006633;\">makeText<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #000000; font-weight: bold;\">this<\/span>, <span style=\"color: #0000ff;\">&quot;\u518d\u6309\u4e00\u6b21\u9000\u51fa\u7a0b\u5e8f&quot;<\/span>, Toast.<span style=\"color: #006633;\">LENGTH_SHORT<\/span><span style=\"color: #009900;\">&#41;<\/span>.<span style=\"color: #006633;\">show<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\ntExit <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000000; font-weight: bold;\">new<\/span> <span style=\"color: #003399;\">Timer<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\ntExit.<span style=\"color: #006633;\">schedule<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #000000; font-weight: bold;\">new<\/span> <span style=\"color: #003399;\">TimerTask<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\n@Override<br \/>\n<span style=\"color: #000000; font-weight: bold;\">public<\/span> <span style=\"color: #000066; font-weight: bold;\">void<\/span> run<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\nisExit <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000066; font-weight: bold;\">false<\/span><span style=\"color: #339933;\">;<\/span> <span style=\"color: #666666; font-style: italic;\">\/\/ \u53d6\u6d88\u9000\u51fa<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span>, <span style=\"color: #cc66cc;\">2000<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span> <span style=\"color: #666666; font-style: italic;\">\/\/ \u5982\u679c2\u79d2\u949f\u5185\u6ca1\u6709\u6309\u4e0b\u8fd4\u56de\u952e\uff0c\u5219\u542f\u52a8\u5b9a\u65f6\u5668\u53d6\u6d88\u6389\u521a\u624d\u6267\u884c\u7684\u4efb\u52a1<\/span><br \/>\n<br \/>\n<span style=\"color: #009900;\">&#125;<\/span> <span style=\"color: #000000; font-weight: bold;\">else<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\nfinish<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #003399;\">System<\/span>.<span style=\"color: #006633;\">exit<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #cc66cc;\">0<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p><a href=\"http:\/\/weitaoc.com\/archives\/188\/1-2\" rel=\"attachment wp-att-189\"><img loading=\"lazy\" decoding=\"async\" alt=\"1\" src=\"http:\/\/weitaoc.com\/wp-content\/uploads\/2014\/05\/1.jpg\" width=\"293\" height=\"220\" \/><\/a><\/p>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"http:\/\/weitaoc.com\">\u8ff7\u8def\u7684\u8001\u9f20<\/a> &raquo; <a href=\"http:\/\/weitaoc.com\/?p=191\">Android \u53cc\u51fb\u8fd4\u56de\u952e\u9000\u51fa\u7a0b\u5e8f \u5b9e\u73b0<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u7528\u6237\u6309\u4e0b\u8fd4\u56de\u952e\u65f6\u8bbe\u5b9a\u4e00\u4e2a\u5b9a\u65f6\u5668\u6765\u76d1\u63a7\u662f\u54262\u79d2\u5185\u5b9e\u73b0\u4e86\u9000\u51fa\uff0c\u5982\u679c\u7528\u6237\u6ca1\u6709\u63a5\u7740\u6309\u8fd4\u56de\u952e\uff0c\u5219\u6e05\u9664\u7b2c\u4e00\u6b21\u6309\u8fd4\u56de\u952e\u7684\u6548\u679c\uff0c\u4f7f\u7a0b\u5e8f\u8fd8\u539f\u5230\u7b2c\u4e00\u6b21\u6309\u4e0b\u8fd4\u56de\u952e\u4e4b\u524d\u7684\u72b6\u6001\u3002\u5b9a\u65f6\u5668\u662f\u6bcf\u6b21\u7528\u6237\u6309\u4e0b\u8fd4\u56de\u952e\u624d\u53bb\u521b\u5efa\u3002 \u4ee3\u7801\u5982\u4e0b\uff1a 123456789101112131415161 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[55],"class_list":["post-191","post","type-post","status-publish","format-standard","hentry","category-technology","tag-android"],"views":4766,"_links":{"self":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/posts\/191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=191"}],"version-history":[{"count":0,"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions"}],"wp:attachment":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=191"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}