{"id":412,"date":"2020-05-14T17:09:18","date_gmt":"2020-05-14T09:09:18","guid":{"rendered":"https:\/\/badgameshow.com\/fly\/?p=412"},"modified":"2020-05-19T12:02:10","modified_gmt":"2020-05-19T04:02:10","slug":"github-%e5%a5%bd%e7%94%a8%e5%88%86%e4%ba%abandroid-android-foreback%e5%88%a4%e6%96%b7%e9%a0%81%e9%9d%a2%e5%89%8d%e5%be%8c%e5%8f%b0","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/fly\/github-%e5%a5%bd%e7%94%a8%e5%88%86%e4%ba%abandroid-android-foreback%e5%88%a4%e6%96%b7%e9%a0%81%e9%9d%a2%e5%89%8d%e5%be%8c%e5%8f%b0\/","title":{"rendered":"Github \u597d\u7528\u5206\u4eabAndroid Android-Foreback(\u5224\u65b7\u9801\u9762\u524d\u5f8c\u53f0)"},"content":{"rendered":"<h3>1.\u5148\u5c0e\u5165\u51fd\u793a\u5eab(build.gradle: Module)<\/h3>\n<pre><code class=\"language-Gradle line-numbers\">dependencies {\n    implementation 'com.takwolf.android:foreback:0.1.1'\n}\n<\/code><\/pre>\n<h3>2.\u5275\u5efa\u4e00\u500b\u985e\u5225\u7e7c\u627fApplication\u4e26\u5be6\u73feForeback.Listener<\/h3>\n<pre><code class=\"language-Kotlin line-numbers\">import android.app.Activity\nimport android.app.Application\nimport android.util.Log\nimport com.takwolf.android.foreback.Foreback\n\nclass MyApplication : Application(), Foreback.Listener {\n\n   override fun onCreate() {\n       super.onCreate()\n       Foreback.init(this)\n       Foreback.registerListener(this)\n  }\n\n   override fun onApplicationEnterForeground(activity: Activity?) {\n       Toast.makeText(activity, \"\u524d\u53f0\", Toast.LENGTH_SHORT).show()\n   }\n\n  override fun onApplicationEnterBackground(activity: Activity?) {\n      Toast.makeText(activity, \"\u5f8c\u53f0\", Toast.LENGTH_SHORT).show()\n  }\n}\n<\/code><\/pre>\n<h3>3.\u5230AndroidManifest.xml\u8a3b\u518a \u5df2\u7e7c\u627fApplication\u8ddf\u5be6\u73feForeback.Listener\u7684\u985e\u5225<\/h3>\n<pre><code class=\"language-XML line-numbers\">&lt;application\n       android:name=\".MyApplication\"\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap\/ic_launcher\"\n        android:label=\"@string\/app_name\"\n        android:roundIcon=\"@mipmap\/ic_launcher_round\"\n        android:supportsRtl=\"true\"\n       android:theme=\"@style\/AppTheme\"&gt;\n       &lt;activity android:name=\".MainActivity\"&gt;\n          &lt;intent-filter&gt;\n             &lt;action android:name=\"android.intent.action.MAIN\" \/&gt;\n\n               &lt;category android:name=\"android.intent.category.LAUNCHER\" \/&gt;\n         &lt;\/intent-filter&gt;\n      &lt;\/activity&gt;\n  &lt;\/application&gt;\n<\/code><\/pre>\n<h3>4.\u6548\u679c\u5c55\u793a<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/05\/37.gif\" alt=\"\" \/><\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>1.\u5148\u5c0e\u5165\u51fd\u793a\u5eab(build.gradle: Module) dependencies { implement &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[57],"tags":[71,56,15],"class_list":["post-412","post","type-post","status-publish","format-standard","hentry","category-github","tag-foreback","tag-github","tag-kotlin"],"_links":{"self":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/comments?post=412"}],"version-history":[{"count":5,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/412\/revisions"}],"predecessor-version":[{"id":431,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/412\/revisions\/431"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/media?parent=412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/categories?post=412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/tags?post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}