{"id":35,"date":"2021-01-19T09:41:00","date_gmt":"2021-01-19T01:41:00","guid":{"rendered":"https:\/\/sunnydays.info\/?p=1386"},"modified":"2021-05-06T14:33:08","modified_gmt":"2021-05-06T06:33:08","slug":"1386","status":"publish","type":"post","link":"https:\/\/sunnydays.info\/?p=35","title":{"rendered":"Android \u5b66\u4e60\u7b14\u8bb0\uff1a\u63a5\u6536\u5e7f\u64ad\u5f00\u542factivity\u65f6\u9047\u5230Exception\u7684\u95ee\u9898"},"content":{"rendered":"<p>\u5728\u522b\u7684\u5b89\u5353\u673a\u5668\u4e0a\u8c03\u8bd5\u6210\u529f\u7684\u4ee3\u7801\uff0c\u5728\u53e6\u5916\u4e00\u53f0\u673a\u5668\u4e0a\u6d4b\u8bd5\u7684\u65f6\u5019\uff0c\u53d1\u73b0\u6536\u5230\u5e7f\u64ad\u542f\u52a8activity\u7684\u65f6\u5019\uff0c\u4f1a\u51fa\u73b0<br \/><code>android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?<\/code><br \/>\u7684\u5f02\u5e38\u63d0\u793a\u3002\u7f51\u4e0a\u641c\u4e86\u4e00\u4e0b\uff0c\u53d1\u73b0\u5fc5\u987b\u8bbe\u7f6eIntent\u6807\u5fd7\u4e3aFLAG_ACTIVITY_NEW_TASK\u3002\u6211\u662f\u8fd9\u6837\u8bbe\u7f6e\u7684\uff1a<\/p>\n<p>\u00a0<\/p>\n\n\n<pre class=\"wp-block-code\"><code>Intent intentS= new Intent(getApplicationContext(), RunActivity.class);\r\nintentS.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK);\r\nstartActivity(intentS);<\/code><\/pre>\n\n\n\n<p>\u8bbe\u7f6e\u4e4b\u540e\u91cd\u65b0\u8fd0\u884c\uff0c\u5c31\u4e0d\u4f1a\u629b\u51fa\u4e0a\u9762\u7684\u5f02\u5e38\u4e86\u3002<\/p>\n\n\n\n<p>\u672c\u6587\u53c2\u8003\u94fe\u63a5\uff1ahttps:\/\/willy2016.pixnet.net\/blog\/post\/215860320-android&#8211;api-%E7%B4%9A%E5%88%A5%E5%8D%87%E7%B4%9A-28%2C-android-pie-9.0-%E9%81%87%E5%88%B0-error<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u522b\u7684\u5b89\u5353\u673a\u5668\u4e0a\u8c03\u8bd5\u6210\u529f\u7684\u4ee3\u7801\uff0c\u5728\u53e6\u5916\u4e00\u53f0\u673a\u5668\u4e0a\u6d4b\u8bd5\u7684\u65f6\u5019\uff0c\u53d1\u73b0\u6536\u5230\u5e7f\u64ad\u542f\u52a8activity\u7684\u65f6\u5019\uff0c\u4f1a\u51fa\u73b0an &hellip; <a href=\"https:\/\/sunnydays.info\/?p=35\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Android \u5b66\u4e60\u7b14\u8bb0\uff1a\u63a5\u6536\u5e7f\u64ad\u5f00\u542factivity\u65f6\u9047\u5230Exception\u7684\u95ee\u9898<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[103],"tags":[8],"class_list":["post-35","post","type-post","status-publish","format-standard","hentry","category-android","tag-android"],"_links":{"self":[{"href":"https:\/\/sunnydays.info\/index.php?rest_route=\/wp\/v2\/posts\/35","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sunnydays.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sunnydays.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sunnydays.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sunnydays.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=35"}],"version-history":[{"count":3,"href":"https:\/\/sunnydays.info\/index.php?rest_route=\/wp\/v2\/posts\/35\/revisions"}],"predecessor-version":[{"id":81,"href":"https:\/\/sunnydays.info\/index.php?rest_route=\/wp\/v2\/posts\/35\/revisions\/81"}],"wp:attachment":[{"href":"https:\/\/sunnydays.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sunnydays.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sunnydays.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}