2022-01-05 ARouter使用

Fragment内跳转activity,不能onActivityResult回调问题解决方案:

第一 首先,继承AppCompatActivity

public class IndexActivity extends AppCompatActivity {

第二 在fragment内跳转activity

Postcard postcard= ARouter.getInstance().build(RouterPath.VerifyComfirmActivity)

.withString("title",name)

.withString("username",username)

.withParcelableArrayList("list",(ArrayList)months);

LogisticsCenter.completion(postcard);

Intent intent =new Intent(mContext,postcard.getDestination());

intent.putExtras(postcard.getExtras());

((AppCompatActivity)mContext).startActivityFromFragment(this,intent,2);

第三,在fragment内直接使用onActivityResult,因为AppCompatActivity继承了FragmentActivity;FragmentActivity调用了fragment的onActivityResult方法

public void onActivityResult(int requestCode,int resultCode, Intent data) {

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • ARouter源码解读 以前看优秀的开源项目,看到了页面路由框架ARouter,心想页面路由是个啥东东,于是乎网上...
    陆元伟阅读 3,638评论 0 1
  • 一、Java语言规范 详见:Android开发java编写规范 二、Android资源文件命名与使用 1. 【推荐...
    王朋6阅读 4,542评论 0 0
  • ARouter入门使用篇 Android原生的路由方案是通过Intent来实现显式和隐式两种Activity跳转方...
    钟小明_阅读 10,445评论 0 0
  • 概述书接上回:ARouter源码分析上[https://www.jianshu.com/p/1e48c588d12...
    Horps阅读 3,073评论 0 1
  • What is ARouterA framework for assisting in the renovatio...
    Horps阅读 3,942评论 0 1