Venscar
Venscar
采纳率100%
2020-03-29 17:40

ARouter初学者,想问一下什么是在application中初始化

5
已采纳

在学习安卓开发和ARouter,官网上和很多教程上都是说推荐在application中初始化ARouter,但是不清楚这段代码应该贴在哪里,什么是application?

if (isDebug()) {           // These two lines must be written before init, otherwise these configurations will be invalid in the init process
    ARouter.openLog();     // Print log
    ARouter.openDebug();   // Turn on debugging mode (If you are running in InstantRun mode, you must turn on debug mode! Online version needs to be closed, otherwise there is a security risk)
}
ARouter.init(mApplication); // As early as possible, it is recommended to initialize in the Application
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • u011186789 妃夏 1年前

    新建一个类继承extends Application,然后在onCreate里做初始化操作,最后在AndroidManifest.xml里找到<application,设置 android:name= “你刚才新建的application类路径名”

    点赞 评论 复制链接分享