android路由登录的问题,Android路由框架-ARouter使用以及遇到的问题

温馨提示:支持数据类型如下:

//基础类型

.withString( String key, String value )

.withBoolean( String key, boolean value)

.withChar( String key, char value )

.withShort( String key, short value)

.withInt( String key, int value)

.withLong( String key, long value)

.withDouble( String key, double value)

.withByte( String key, byte value)

.withFloat( String key, float value)

.withCharSequence( String key, CharSequence value)

//数组类型

.withParcelableArrayList( String key, ArrayList extends Parcelable > value)

.withStringArrayList( String key, ArrayList value)

.withIntegerArrayList( String key, ArrayList value)

.withSparseParcelableArray( String key, SparseArray extends Parcelable> value)

.withCharSequenceArrayList( String key, ArrayList value)

.withShortArray( String key, short[] value)

.withCharArray( String key, char[] value)

.withFloatArray( String key, float[] value)

.withCharSequenceArray( String key, CharSequence[] value)

//Bundle 类型

.with( Bundle bundle )

//Activity 跳转动画

.withTransition(int enterAnim, int exitAnim)

//其他类型

.withParcelable( String key, Parcelable value)

.withParcelableArray( String key, Parcelable[] value)

.withSerializable( String key, Serializable value)

.withByteArray( String key, byte[] value)

.withTransition(int enterAnim, int exitAnim)

三:遇到的问题

ARouter.getInstance().inject(this);

我们有一个singletask启动模式的activity,在onNewIntent方法中调用ARouter.getInstance().inject(this);得不到参数,查看ARouter在build过程中生成的代码可以知道它是调用了activity的getIntent来获取参数的,但是onNewIntent中的intent和在onCreate方法中的intent并不相同,所以需要在onNewIntent方法中调用setIntent方法,然后就能得到参数了。

ARouter::Compiler >>> No module name, for more information, look at gradle log.

检查项目依赖的全部module包括module依赖的module(没有页面的module也算),在每个module的 build.gradle中加上下面的代码。

defaultConfig {

javaCompileOptions {

annotationProcessorOptions {

arguments = [ AROUTER_MODULE_NAME : project.getName() ]

}

}

}

ARouter there's no route matched

不同module的一级路径必须不同,否则会导致一个moudle中的一级路径失效

下面是抛出异常的源代码

public synchronized static void completion(Postcard postcard) {

if (null == postcard) {

throw new NoRouteFoundException(TAG + "No postcard!");

}

//查找RouteMeta对象,如果存在说明路由成功,如果失败说明还没有被加载或者这个path就是错误的

RouteMeta routeMeta = Warehouse.routes.get(postcard.getPath());

if (null == routeMeta) {

// 通过groupsIndex去找IRouteGroup的实现类

Class extends IRouteGroup> groupMeta = Warehouse.groupsIndex.get(postcard.getGroup());

if (null == groupMeta) {

throw new NoRouteFoundException(TAG + "There is no route match the path [" + postcard.getPath() + "], in group [" + postcard.getGroup() + "]");

} else {

// 通过反射获取IRouteGroup的实现类,然后加载到内存

IRouteGroup iGroupInstance = groupMeta.getConstructor().newInstance();

iGroupInstance.loadInto(Warehouse.routes);

// 加载到内存后Warehouse.groupsIndex去掉这个group

Warehouse.groupsIndex.remove(postcard.getGroup());

}

} else {

//查找到路由地址

。。。。。

}

}

by:yzl

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值