{"id":24623,"date":"2025-04-19T10:29:00","date_gmt":"2025-04-19T02:29:00","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/24623.html"},"modified":"2025-04-19T10:29:00","modified_gmt":"2025-04-19T02:29:00","slug":"android-arouter%e7%9a%84%e8%af%a6%e7%bb%86%e4%bd%bf%e7%94%a8%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/24623.html","title":{"rendered":"Android ARouter\u7684\u8be6\u7ec6\u4f7f\u7528\u6307\u5357"},"content":{"rendered":"<p>Android ARouter\u7684\u8be6\u7ec6\u4f7f\u7528\u6307\u5357\u3002\u6211\u9700\u8981\u5148\u786e\u5b9a\u7528\u6237\u7684\u57fa\u7840&#xff0c;\u53ef\u80fd\u4ed6\u4eec\u5df2\u7ecf\u6709Android\u5f00\u53d1\u7ecf\u9a8c&#xff0c;\u4f46\u5bf9ARouter\u4e0d\u592a\u719f\u6089\u3002\u9996\u5148&#xff0c;\u6211\u5e94\u8be5\u4ecb\u7ecdARouter\u662f\u4ec0\u4e48&#xff0c;\u89e3\u51b3\u4ec0\u4e48\u95ee\u9898&#xff0c;\u6bd4\u5982\u6a21\u5757\u5316\u4e2d\u7684\u9875\u9762\u8df3\u8f6c\u95ee\u9898\u3002\u7136\u540e&#xff0c;\u9700\u8981\u5206\u6b65\u9aa4\u8bb2\u89e3&#xff0c;\u4ece\u96c6\u6210\u5230\u57fa\u672c\u4f7f\u7528&#xff0c;\u518d\u5230\u9ad8\u7ea7\u529f\u80fd\u3002<\/p>\n<p>\u7528\u6237\u53ef\u80fd\u9700\u8981\u7684\u8be6\u7ec6\u6b65\u9aa4\u5305\u62ec\u5982\u4f55\u6dfb\u52a0\u4f9d\u8d56&#xff0c;\u8bb0\u5f97\u8981\u63d0\u5230Kotlin\u548cJava\u7684\u4e0d\u540c\u914d\u7f6e&#xff0c;\u8fd8\u6709annotationProcessor\u3002\u7136\u540e&#xff0c;\u521d\u59cb\u5316\u90e8\u5206&#xff0c;\u5982\u4f55\u5728Application\u4e2d\u521d\u59cb\u5316&#xff0c;\u4ee5\u53ca\u53ef\u80fd\u9047\u5230\u7684\u5751&#xff0c;\u6bd4\u5982\u6df7\u6dc6\u914d\u7f6e\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u662f\u57fa\u672c\u4f7f\u7528&#xff0c;\u5982\u4f55\u7528&#064;Route\u6ce8\u89e3\u6807\u6ce8Activity&#xff0c;\u5982\u4f55\u8df3\u8f6c&#xff0c;\u53ef\u80fd\u9700\u8981\u4ee3\u7801\u793a\u4f8b\u3002\u8fd9\u91cc\u8981\u533a\u5206Kotlin\u548cJava\u7684\u5199\u6cd5\u5417&#xff1f;\u6216\u8005\u7edf\u4e00\u7528Java&#xff1f;\u53ef\u80fd\u7528\u6237\u4e24\u79cd\u90fd\u6709&#xff0c;\u6240\u4ee5\u6700\u597d\u90fd\u63d0\u5230\u3002\u8fd8\u6709\u53c2\u6570\u4f20\u9012&#xff0c;\u7528withString\u4e4b\u7c7b\u7684&#xff0c;\u4ee5\u53ca\u5982\u4f55\u81ea\u52a8\u6ce8\u5165\u3002<\/p>\n<p>\u9ad8\u7ea7\u529f\u80fd\u90e8\u5206&#xff0c;\u62e6\u622a\u5668\u662f\u91cd\u70b9&#xff0c;\u7528\u6237\u53ef\u80fd\u60f3\u5b9e\u73b0\u767b\u5f55\u68c0\u67e5\u6216\u8005\u6743\u9650\u63a7\u5236\u3002\u9700\u8981\u7ed9\u51fa\u62e6\u622a\u5668\u7684\u4f8b\u5b50&#xff0c;\u8bf4\u660e\u6267\u884c\u987a\u5e8f\u548c\u6ce8\u610f\u4e8b\u9879\u3002\u8fd8\u6709\u8de8\u6a21\u5757\u8c03\u7528\u670d\u52a1&#xff0c;\u670d\u52a1\u6ce8\u518c\u548c\u53d1\u73b0\u7684\u6d41\u7a0b&#xff0c;\u8fd9\u91cc\u53ef\u80fd\u9700\u8981\u7528IProvider\u63a5\u53e3\u7684\u4f8b\u5b50\u3002<\/p>\n<p>\u53e6\u5916&#xff0c;\u7528\u6237\u53ef\u80fd\u4f1a\u9047\u5230\u95ee\u9898&#xff0c;\u6bd4\u5982Proguard\u914d\u7f6e&#xff0c;\u6216\u8005\u9875\u9762\u672a\u627e\u5230\u7684\u60c5\u51b5&#xff0c;\u5e38\u89c1\u95ee\u9898\u89e3\u7b54\u90e8\u5206\u5e94\u8be5\u6db5\u76d6\u8fd9\u4e9b\u3002\u6bd4\u5982\u68c0\u67e5\u6ce8\u89e3\u662f\u5426\u6b63\u786e&#xff0c;\u8def\u7531\u8def\u5f84\u662f\u5426\u6b63\u786e&#xff0c;\u521d\u59cb\u5316\u662f\u5426\u5b8c\u6210\u3002<\/p>\n<p>\u9700\u8981\u6ce8\u610f&#xff0c;\u7528\u6237\u53ef\u80fd\u662f\u5728\u8fdb\u884c\u6a21\u5757\u5316\u5f00\u53d1&#xff0c;\u6240\u4ee5\u9700\u8981\u5f3a\u8c03ARouter\u5728\u89e3\u8026\u65b9\u9762\u7684\u4f18\u52bf&#xff0c;\u6bd4\u5982\u4e0d\u540c\u6a21\u5757\u95f4\u4e0d\u9700\u8981\u76f4\u63a5\u4f9d\u8d56\u3002\u540c\u65f6&#xff0c;\u8981\u63d0\u9192\u7528\u6237\u8def\u5f84\u7684\u7ba1\u7406&#xff0c;\u6700\u597d\u7edf\u4e00\u7ba1\u7406\u8def\u7531\u8def\u5f84&#xff0c;\u907f\u514d\u786c\u7f16\u7801\u3002<\/p>\n<p>\u6700\u540e&#xff0c;\u603b\u7ed3\u4e00\u4e0bARouter\u7684\u597d\u5904&#xff0c;\u4ee5\u53ca\u9002\u7528\u7684\u573a\u666f\u3002\u53ef\u80fd\u8fd8\u9700\u8981\u7ed9\u51fa\u5b98\u65b9\u6587\u6863\u7684\u94fe\u63a5&#xff0c;\u65b9\u4fbf\u7528\u6237\u8fdb\u4e00\u6b65\u67e5\u9605\u3002\u786e\u4fdd\u6574\u4e2a\u6307\u5357\u7ed3\u6784\u6e05\u6670&#xff0c;\u6b65\u9aa4\u660e\u786e&#xff0c;\u4ee3\u7801\u793a\u4f8b\u6b63\u786e&#xff0c;\u5e76\u4e14\u8986\u76d6\u5e38\u89c1\u95ee\u9898\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4efd\u8be6\u7ec6\u7684\u00a0Android ARouter \u4f7f\u7528\u6307\u5357&#xff0c;\u6db5\u76d6\u57fa\u672c\u914d\u7f6e\u3001\u6838\u5fc3\u529f\u80fd\u53ca\u9ad8\u7ea7\u7528\u6cd5&#xff0c;\u5e2e\u52a9\u4f60\u5728\u9879\u76ee\u4e2d\u9ad8\u6548\u5b9e\u73b0\u7ec4\u4ef6\u5316\u901a\u4fe1\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001ARouter \u7b80\u4ecb<\/h3>\n<p>ARouter\u00a0\u662f\u963f\u91cc\u5f00\u6e90\u7684\u8def\u7531\u6846\u67b6&#xff0c;\u7528\u4e8e\u89e3\u51b3\u6a21\u5757\u95f4\u8df3\u8f6c\u3001\u670d\u52a1\u8c03\u7528\u7b49\u89e3\u8026\u95ee\u9898&#xff0c;\u9002\u7528\u4e8e\u7ec4\u4ef6\u5316\u5f00\u53d1\u573a\u666f\u3002\u5176\u6838\u5fc3\u80fd\u529b\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u9875\u9762\u8df3\u8f6c&#xff1a;\u652f\u6301\u8de8\u6a21\u5757\u3001\u8de8\u8fdb\u7a0b\u7684 Activity\/Fragment \u8df3\u8f6c\u3002<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u4f20\u9012&#xff1a;\u81ea\u52a8\u6ce8\u5165\u53c2\u6570&#xff0c;\u652f\u6301\u5e8f\u5217\u5316\u5bf9\u8c61\u3002<\/p>\n<\/li>\n<li>\n<p>\u62e6\u622a\u5668&#xff1a;\u5168\u5c40\u63a7\u5236\u8df3\u8f6c\u903b\u8f91&#xff08;\u5982\u767b\u5f55\u68c0\u67e5&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u670d\u52a1\u53d1\u73b0&#xff1a;\u8de8\u6a21\u5757\u8c03\u7528\u670d\u52a1&#xff0c;\u5b9e\u73b0\u63a5\u53e3\u4e0e\u5b9e\u73b0\u5206\u79bb\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e8c\u3001\u5feb\u901f\u96c6\u6210<\/h3>\n<h4>1. \u6dfb\u52a0\u4f9d\u8d56<\/h4>\n<p>\u5728\u00a0build.gradle\u00a0\u4e2d\u6dfb\u52a0&#xff1a;<\/p>\n<p>android {<br \/>\n    defaultConfig {<br \/>\n        \/\/ \u786e\u4fdd\u4f7f\u7528 Java 8<br \/>\n        compileOptions {<br \/>\n            sourceCompatibility JavaVersion.VERSION_1_8<br \/>\n            targetCompatibility JavaVersion.VERSION_1_8<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<p>dependencies {<br \/>\n    \/\/ ARouter \u6838\u5fc3\u5e93<br \/>\n    implementation &#039;com.alibaba:arouter-api:1.5.2&#039;<br \/>\n    annotationProcessor &#039;com.alibaba:arouter-compiler:1.5.2&#039;<\/p>\n<p>    \/\/ \u5982\u679c\u662f Kotlin \u9879\u76ee&#xff0c;\u4f7f\u7528 kapt<br \/>\n    kapt &#039;com.alibaba:arouter-compiler:1.5.2&#039;<br \/>\n} <\/p>\n<h4>2. \u521d\u59cb\u5316 ARouter<\/h4>\n<p>\u5728\u00a0Application\u00a0\u4e2d\u521d\u59cb\u5316&#xff1a;<\/p>\n<p>public class MyApp extends Application {<br \/>\n    &#064;Override<br \/>\n    public void onCreate() {<br \/>\n        super.onCreate();<br \/>\n        if (BuildConfig.DEBUG) {<br \/>\n            ARouter.openLog();     \/\/ \u5f00\u542f\u65e5\u5fd7<br \/>\n            ARouter.openDebug();   \/\/ \u5f00\u542f\u8c03\u8bd5\u6a21\u5f0f<br \/>\n        }<br \/>\n        ARouter.init(this); \/\/ \u521d\u59cb\u5316<br \/>\n    }<br \/>\n} <\/p>\n<h4>3. \u914d\u7f6e Proguard&#xff08;\u53ef\u9009&#xff09;<\/h4>\n<p>\u6dfb\u52a0\u6df7\u6dc6\u89c4\u5219&#xff1a;<\/p>\n<p>-keep public class com.alibaba.android.arouter.routes.**{*;}<br \/>\n-keep public class com.alibaba.android.arouter.facade.**{*;}<br \/>\n-keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;} <\/p>\n<hr \/>\n<h3>\u4e09\u3001\u57fa\u7840\u4f7f\u7528<\/h3>\n<h4>1. \u9875\u9762\u8df3\u8f6c<\/h4>\n<h5>1.1 \u6ce8\u518c\u8def\u7531<\/h5>\n<p>\u4e3a\u76ee\u6807\u9875\u9762\u6dfb\u52a0\u00a0&#064;Route\u00a0\u6ce8\u89e3&#xff1a;<\/p>\n<p>&#064;Route(path &#061; &#034;\/app\/main&#034;)<br \/>\npublic class MainActivity extends AppCompatActivity {<br \/>\n    \/\/ &#8230;<br \/>\n} <\/p>\n<h5>1.2 \u53d1\u8d77\u8df3\u8f6c<\/h5>\n<p>\u901a\u8fc7\u8def\u5f84\u8fdb\u884c\u8df3\u8f6c&#xff1a;<\/p>\n<p>\/\/ \u666e\u901a\u8df3\u8f6c<br \/>\nARouter.getInstance().build(&#034;\/app\/main&#034;).navigation();<\/p>\n<p>\/\/ \u5e26\u53c2\u6570\u8df3\u8f6c<br \/>\nARouter.getInstance()<br \/>\n    .build(&#034;\/app\/detail&#034;)<br \/>\n    .withString(&#034;title&#034;, &#034;\u8be6\u60c5\u9875&#034;)<br \/>\n    .withInt(&#034;id&#034;, 1001)<br \/>\n    .navigation(); <\/p>\n<h5>1.3 \u53c2\u6570\u81ea\u52a8\u6ce8\u5165<\/h5>\n<p>\u5728\u76ee\u6807\u9875\u9762\u4e2d\u81ea\u52a8\u6ce8\u5165\u53c2\u6570&#xff1a;<\/p>\n<p>&#064;Route(path &#061; &#034;\/app\/detail&#034;)<br \/>\npublic class DetailActivity extends AppCompatActivity {<br \/>\n    &#064;Autowired  \/\/ \u81ea\u52a8\u6ce8\u5165\u5b57\u6bb5<br \/>\n    String title;<\/p>\n<p>    &#064;Autowired(name &#061; &#034;id&#034;) \/\/ \u6307\u5b9a\u53c2\u6570\u540d<br \/>\n    int productId;<\/p>\n<p>    &#064;Override<br \/>\n    protected void onCreate(Bundle savedInstanceState) {<br \/>\n        super.onCreate(savedInstanceState);<br \/>\n        ARouter.getInstance().inject(this); \/\/ \u5fc5\u987b\u8c03\u7528\u6ce8\u5165\u65b9\u6cd5<br \/>\n        \/\/ \u76f4\u63a5\u4f7f\u7528 title \u548c productId<br \/>\n    }<br \/>\n} <\/p>\n<hr \/>\n<h4>2. \u83b7\u53d6 Fragment<\/h4>\n<p>&#064;Route(path &#061; &#034;\/app\/home_fragment&#034;)<br \/>\npublic class HomeFragment extends Fragment {<br \/>\n    \/\/ &#8230;<br \/>\n}<\/p>\n<p>\/\/ \u83b7\u53d6\u5b9e\u4f8b<br \/>\nFragment fragment &#061; (Fragment) ARouter.getInstance().build(&#034;\/app\/home_fragment&#034;).navigation(); <\/p>\n<hr \/>\n<h4>3. \u8df3\u8f6c\u7ed3\u679c\u56de\u8c03<\/h4>\n<p>ARouter.getInstance()<br \/>\n    .build(&#034;\/app\/login&#034;)<br \/>\n    .navigation(this, new NavigationCallback() {<br \/>\n        &#064;Override<br \/>\n        public void onFound(Postcard postcard) {<br \/>\n            \/\/ \u8def\u7531\u627e\u5230<br \/>\n        }<\/p>\n<p>        &#064;Override<br \/>\n        public void onLost(Postcard postcard) {<br \/>\n            \/\/ \u8def\u7531\u672a\u627e\u5230<br \/>\n        }<\/p>\n<p>        &#064;Override<br \/>\n        public void onArrival(Postcard postcard) {<br \/>\n            \/\/ \u8df3\u8f6c\u5b8c\u6210<br \/>\n        }<\/p>\n<p>        &#064;Override<br \/>\n        public void onInterrupt(Postcard postcard) {<br \/>\n            \/\/ \u88ab\u62e6\u622a\u5668\u4e2d\u65ad<br \/>\n        }<br \/>\n    }); <\/p>\n<hr \/>\n<h3>\u56db\u3001\u9ad8\u7ea7\u529f\u80fd<\/h3>\n<h4>1. \u62e6\u622a\u5668&#xff08;Interceptor&#xff09;<\/h4>\n<p>\u5b9e\u73b0\u5168\u5c40\u62e6\u622a\u903b\u8f91&#xff08;\u5982\u767b\u5f55\u68c0\u67e5&#xff09;&#xff1a;<\/p>\n<p>&#064;Interceptor(priority &#061; 8, name &#061; &#034;\u767b\u5f55\u62e6\u622a\u5668&#034;)<br \/>\npublic class LoginInterceptor implements IInterceptor {<br \/>\n    &#064;Override<br \/>\n    public void process(Postcard postcard, InterceptorCallback callback) {<br \/>\n        if (postcard.getPath().equals(&#034;\/app\/profile&#034;)) {<br \/>\n            if (!isLogin()) {<br \/>\n                \/\/ \u8df3\u8f6c\u5230\u767b\u5f55\u9875<br \/>\n                ARouter.getInstance().build(&#034;\/app\/login&#034;).navigation();<br \/>\n                callback.onInterrupt(null); \/\/ \u4e2d\u65ad\u5f53\u524d\u8def\u7531<br \/>\n                return;<br \/>\n            }<br \/>\n        }<br \/>\n        callback.onContinue(postcard); \/\/ \u7ee7\u7eed\u6267\u884c<br \/>\n    }<\/p>\n<p>    &#064;Override<br \/>\n    public void init(Context context) {<br \/>\n        \/\/ \u62e6\u622a\u5668\u521d\u59cb\u5316<br \/>\n    }<br \/>\n} <\/p>\n<hr \/>\n<h4>2. \u8de8\u6a21\u5757\u670d\u52a1\u8c03\u7528<\/h4>\n<h5>2.1 \u5b9a\u4e49\u670d\u52a1\u63a5\u53e3<\/h5>\n<p>public interface IUserService extends IProvider {<br \/>\n    String getUserName();<br \/>\n    boolean isLogin();<br \/>\n} <\/p>\n<h5>2.2 \u5b9e\u73b0\u670d\u52a1<\/h5>\n<p>&#064;Route(path &#061; &#034;\/service\/user&#034;)<br \/>\npublic class UserServiceImpl implements IUserService {<br \/>\n    &#064;Override<br \/>\n    public String getUserName() {<br \/>\n        return &#034;Alice&#034;;<br \/>\n    }<\/p>\n<p>    &#064;Override<br \/>\n    public boolean isLogin() {<br \/>\n        return true;<br \/>\n    }<\/p>\n<p>    &#064;Override<br \/>\n    public void init(Context context) {<br \/>\n        \/\/ \u521d\u59cb\u5316<br \/>\n    }<br \/>\n} <\/p>\n<h5>2.3 \u8c03\u7528\u670d\u52a1<\/h5>\n<p>IUserService userService &#061; ARouter.getInstance().navigation(IUserService.class);<br \/>\nif (userService !&#061; null &amp;&amp; userService.isLogin()) {<br \/>\n    String name &#061; userService.getUserName();<br \/>\n} <\/p>\n<hr \/>\n<h4>3. \u8def\u7531\u5206\u7ec4\u4e0e\u964d\u7ea7\u7b56\u7565<\/h4>\n<h5>3.1 \u5206\u7ec4\u7ba1\u7406<\/h5>\n<p>\u901a\u8fc7\u00a0group\u00a0\u53c2\u6570\u5206\u7ec4\u7ba1\u7406\u8def\u7531&#xff1a;<\/p>\n<p>&#064;Route(path &#061; &#034;\/group1\/activity1&#034;, group &#061; &#034;group1&#034;)<br \/>\npublic class Group1Activity extends AppCompatActivity { &#8230; } <\/p>\n<h5>3.2 \u964d\u7ea7\u7b56\u7565<\/h5>\n<p>\u5904\u7406\u672a\u627e\u5230\u7684\u8def\u7531&#xff1a;<\/p>\n<p>public class DegradeServiceImpl implements DegradeService {<br \/>\n    &#064;Override<br \/>\n    public void onLost(Context context, Postcard postcard) {<br \/>\n        \/\/ \u8df3\u8f6c\u5230\u7edf\u4e00\u9519\u8bef\u9875<br \/>\n        context.startActivity(new Intent(context, ErrorActivity.class));<br \/>\n    }<\/p>\n<p>    &#064;Override<br \/>\n    public void init(Context context) { &#8230; }<br \/>\n} <\/p>\n<hr \/>\n<h3>\u4e94\u3001\u5e38\u89c1\u95ee\u9898<\/h3>\n<h4>1. \u9875\u9762\u672a\u627e\u5230&#xff08;There&#039;s no route matched&#xff09;<\/h4>\n<ul>\n<li>\n<p>\u68c0\u67e5\u00a0&#064;Route\u00a0\u6ce8\u89e3\u662f\u5426\u6dfb\u52a0\u3002<\/p>\n<\/li>\n<li>\n<p>\u786e\u8ba4\u8def\u5f84\u662f\u5426\u62fc\u5199\u9519\u8bef\u3002<\/p>\n<\/li>\n<li>\n<p>\u786e\u4fdd\u6a21\u5757\u7684\u00a0ARouter\u00a0\u914d\u7f6e\u6b63\u786e\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>2. \u53c2\u6570\u6ce8\u5165\u5931\u8d25<\/h4>\n<ul>\n<li>\n<p>\u662f\u5426\u8c03\u7528\u00a0ARouter.getInstance().inject(this)&#xff1f;<\/p>\n<\/li>\n<li>\n<p>\u68c0\u67e5\u5b57\u6bb5\u7c7b\u578b\u4e0e\u4f20\u9012\u7c7b\u578b\u662f\u5426\u4e00\u81f4\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>3. \u62e6\u622a\u5668\u4e0d\u751f\u6548<\/h4>\n<ul>\n<li>\n<p>\u786e\u8ba4\u62e6\u622a\u5668\u7684\u00a0priority\u00a0\u4f18\u5148\u7ea7\u8bbe\u7f6e\u3002<\/p>\n<\/li>\n<li>\n<p>\u662f\u5426\u5728\u62e6\u622a\u5668\u4e2d\u8c03\u7528\u4e86\u00a0callback.onContinue()&#xff1f;<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>\u516d\u3001\u6700\u4f73\u5b9e\u8df5<\/h3>\n<ul>\n<li>\n<p>\u7edf\u4e00\u7ba1\u7406\u8def\u7531\u8def\u5f84&#xff1a;\u4f7f\u7528\u5e38\u91cf\u7c7b\u96c6\u4e2d\u7ba1\u7406\u6240\u6709\u8def\u7531\u8def\u5f84\u3002<\/p>\n<\/li>\n<li>\n<p>\u6a21\u5757\u5316\u5f00\u53d1&#xff1a;\u6bcf\u4e2a\u4e1a\u52a1\u6a21\u5757\u72ec\u7acb\u7ba1\u7406\u81ea\u5df1\u7684\u8def\u7531\u8868\u3002<\/p>\n<\/li>\n<li>\n<p>\u7ed3\u5408APT&#xff1a;\u5229\u7528\u6ce8\u89e3\u5904\u7406\u5668\u751f\u6210\u8def\u7531\u6587\u6863\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<p>\u901a\u8fc7\u672c\u6307\u5357&#xff0c;\u60a8\u5e94\u8be5\u80fd\u591f\u719f\u7ec3\u4f7f\u7528 ARouter \u5b9e\u73b0\u7ec4\u4ef6\u5316\u5f00\u53d1\u4e2d\u7684\u6838\u5fc3\u901a\u4fe1\u9700\u6c42\u3002\u66f4\u591a\u7ec6\u8282\u8bf7\u53c2\u8003\u00a0ARouter \u5b98\u65b9\u6587\u6863<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf25\u6b21\u3002ARouter\u662f\u963f\u91cc\u5f00\u6e90\u7684\u8def\u7531\u6846\u67b6\uff0c\u7528\u4e8e\u89e3\u51b3\u6a21\u5757\u95f4\u8df3\u8f6c\u3001\u670d\u52a1\u8c03\u7528\u7b49\u89e3\u8026\u95ee\u9898\uff0c\u9002\u7528\u4e8e\u7ec4\u4ef6\u5316\u5f00\u53d1\u573a\u666f\u3002\u9875\u9762\u8df3\u8f6c\uff1a\u652f\u6301\u8de8\u6a21\u5757\u3001\u8de8\u8fdb\u7a0b\u7684 Activity\/Fragment \u8df3\u8f6c\u3002\u53c2\u6570\u4f20\u9012\uff1a\u81ea\u52a8\u6ce8\u5165\u53c2\u6570\uff0c\u652f\u6301\u5e8f\u5217\u5316\u5bf9\u8c61\u3002\u62e6\u622a\u5668\uff1a\u5168\u5c40\u63a7\u5236\u8df3\u8f6c\u903b\u8f91\uff08\u5982\u767b\u5f55\u68c0\u67e5\uff09\u3002\u670d\u52a1\u53d1\u73b0\uff1a\u8de8\u6a21\u5757\u8c03\u7528\u670d\u52a1\uff0c\u5b9e\u73b0\u63a5\u53e3\u4e0e\u5b9e\u73b0\u5206\u79bb\u3002_\u5b89\u5353arouter<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[84,1916,99],"topic":[],"class_list":["post-24623","post","type-post","status-publish","format-standard","hentry","category-server","tag-android","tag-arouter","tag-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Android ARouter\u7684\u8be6\u7ec6\u4f7f\u7528\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/24623.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android ARouter\u7684\u8be6\u7ec6\u4f7f\u7528\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf25\u6b21\u3002ARouter\u662f\u963f\u91cc\u5f00\u6e90\u7684\u8def\u7531\u6846\u67b6\uff0c\u7528\u4e8e\u89e3\u51b3\u6a21\u5757\u95f4\u8df3\u8f6c\u3001\u670d\u52a1\u8c03\u7528\u7b49\u89e3\u8026\u95ee\u9898\uff0c\u9002\u7528\u4e8e\u7ec4\u4ef6\u5316\u5f00\u53d1\u573a\u666f\u3002\u9875\u9762\u8df3\u8f6c\uff1a\u652f\u6301\u8de8\u6a21\u5757\u3001\u8de8\u8fdb\u7a0b\u7684 Activity\/Fragment \u8df3\u8f6c\u3002\u53c2\u6570\u4f20\u9012\uff1a\u81ea\u52a8\u6ce8\u5165\u53c2\u6570\uff0c\u652f\u6301\u5e8f\u5217\u5316\u5bf9\u8c61\u3002\u62e6\u622a\u5668\uff1a\u5168\u5c40\u63a7\u5236\u8df3\u8f6c\u903b\u8f91\uff08\u5982\u767b\u5f55\u68c0\u67e5\uff09\u3002\u670d\u52a1\u53d1\u73b0\uff1a\u8de8\u6a21\u5757\u8c03\u7528\u670d\u52a1\uff0c\u5b9e\u73b0\u63a5\u53e3\u4e0e\u5b9e\u73b0\u5206\u79bb\u3002_\u5b89\u5353arouter\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/24623.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-19T02:29:00+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/24623.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/24623.html\",\"name\":\"Android ARouter\u7684\u8be6\u7ec6\u4f7f\u7528\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-19T02:29:00+00:00\",\"dateModified\":\"2025-04-19T02:29:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/24623.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/24623.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/24623.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android ARouter\u7684\u8be6\u7ec6\u4f7f\u7528\u6307\u5357\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android ARouter\u7684\u8be6\u7ec6\u4f7f\u7528\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/24623.html","og_locale":"zh_CN","og_type":"article","og_title":"Android ARouter\u7684\u8be6\u7ec6\u4f7f\u7528\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf25\u6b21\u3002ARouter\u662f\u963f\u91cc\u5f00\u6e90\u7684\u8def\u7531\u6846\u67b6\uff0c\u7528\u4e8e\u89e3\u51b3\u6a21\u5757\u95f4\u8df3\u8f6c\u3001\u670d\u52a1\u8c03\u7528\u7b49\u89e3\u8026\u95ee\u9898\uff0c\u9002\u7528\u4e8e\u7ec4\u4ef6\u5316\u5f00\u53d1\u573a\u666f\u3002\u9875\u9762\u8df3\u8f6c\uff1a\u652f\u6301\u8de8\u6a21\u5757\u3001\u8de8\u8fdb\u7a0b\u7684 Activity\/Fragment \u8df3\u8f6c\u3002\u53c2\u6570\u4f20\u9012\uff1a\u81ea\u52a8\u6ce8\u5165\u53c2\u6570\uff0c\u652f\u6301\u5e8f\u5217\u5316\u5bf9\u8c61\u3002\u62e6\u622a\u5668\uff1a\u5168\u5c40\u63a7\u5236\u8df3\u8f6c\u903b\u8f91\uff08\u5982\u767b\u5f55\u68c0\u67e5\uff09\u3002\u670d\u52a1\u53d1\u73b0\uff1a\u8de8\u6a21\u5757\u8c03\u7528\u670d\u52a1\uff0c\u5b9e\u73b0\u63a5\u53e3\u4e0e\u5b9e\u73b0\u5206\u79bb\u3002_\u5b89\u5353arouter","og_url":"https:\/\/www.wsisp.com\/helps\/24623.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-19T02:29:00+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/24623.html","url":"https:\/\/www.wsisp.com\/helps\/24623.html","name":"Android ARouter\u7684\u8be6\u7ec6\u4f7f\u7528\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-19T02:29:00+00:00","dateModified":"2025-04-19T02:29:00+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/24623.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/24623.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/24623.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Android ARouter\u7684\u8be6\u7ec6\u4f7f\u7528\u6307\u5357"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/24623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=24623"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/24623\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=24623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=24623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=24623"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=24623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}