{"id":1839,"date":"2023-03-29T21:50:17","date_gmt":"2023-03-29T13:50:17","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1839"},"modified":"2023-04-22T09:12:37","modified_gmt":"2023-04-22T01:12:37","slug":"freereflection-is-a-library-that-allows-you-to-use-reflection-on-android-p-without-any-restrictions","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/29\/freereflection-is-a-library-that-allows-you-to-use-reflection-on-android-p-without-any-restrictions\/","title":{"rendered":"FreeReflection\u4e00\u4e2a\u5141\u8bb8\u4f60\u5728Android P\u4e0a\u4f7f\u7528\u53cd\u5c04\u800c\u6ca1\u6709\u4efb\u4f55\u9650\u5236\u7684\u5e93"},"content":{"rendered":"<h3>FreeReflection<\/h3>\n<p><strong>FreeReflection<\/strong> is a library that lets you use reflection without any restriction above Android P (includes Q).<\/p>\n<p>Github: <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/tiann\/FreeReflection\/\">https:\/\/github.com\/tiann\/FreeReflection\/<\/a><\/p>\n<p><!-- more --><\/p>\n<h3>Usage<\/h3>\n<ol>\n<li>Add dependency to your project(jcenter):<\/li>\n<\/ol>\n<pre><code>implementation &#039;me.weishu:free_reflection:2.2.0&#039;<\/code><\/pre>\n<ol start=\"2\">\n<li>Add one line to your Application.attachBaseContext:<\/li>\n<\/ol>\n<pre><code class=\"language-java\">@Override\nprotected void attachBaseContext(Context base) {\n    super.attachBaseContext(base);\n    Reflection.unseal(base);\n}<\/code><\/pre>\n<p>Then you can use the reflection API normally, all the restrictions are gone. Enjoy yourself \ud83d\ude42<\/p>\n<h3>Under the hood<\/h3>\n<p><a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/weishu.me\/2018\/06\/07\/free-reflection-above-android-p\/\" title=\"free reflection above android p\">free reflection above android p<\/a><\/p>\n<p><a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/weishu.me\/2019\/03\/16\/another-free-reflection-above-android-p\/\" title=\"another way to use reflection api above android p\">another way to use reflection api above android p<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>FreeReflection FreeReflection is a library that lets yo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[325],"tags":[199],"class_list":["post-1839","post","type-post","status-publish","format-standard","hentry","category-android-adaptation","tag-199"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1839"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1839\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}