diff --git a/README.md b/README.md
index 622e1e7a..0c65aa9a 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,7 @@
8. 支持用户指定全局降级与局部降级策略
9. 页面、拦截器、服务等组件均自动注册到框架
10. 支持多种方式配置转场动画
+11. 支持获取Fragment
#### 二、典型应用
1. 从外部URL映射到内部页面,以及参数传递与解析
@@ -298,6 +299,9 @@
.withFlags();
.navigation();
+ // 获取Fragment
+ Fragment fragment = (Fragment) ARouter.getInstance().build("/test/fragment").navigation();
+
// 对象传递
ARouter.getInstance()
.withObject("key", new TestObj("Jack", "Rose"))
diff --git a/README_CN.md b/README_CN.md
index 7c097f9a..a840b9b2 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -27,6 +27,7 @@
8. 支持用户指定全局降级与局部降级策略
9. 页面、拦截器、服务等组件均自动注册到框架
10. 支持多种方式配置转场动画
+11. 支持获取Fragment
#### 二、典型应用
1. 从外部URL映射到内部页面,以及参数传递与解析
@@ -300,6 +301,9 @@
ARouter.getInstance()
.withObject("key", new TestObj("Jack", "Rose"))
.navigation();
+
+ // 获取Fragment
+ Fragment fragment = (Fragment) ARouter.getInstance().build("/test/fragment").navigation();
// 觉得接口不够多,可以直接拿出Bundle赋值
ARouter.getInstance()
diff --git a/app/src/main/java/com/alibaba/android/arouter/demo/BlankFragment.java b/app/src/main/java/com/alibaba/android/arouter/demo/BlankFragment.java
index 88f11a36..8b64afbf 100644
--- a/app/src/main/java/com/alibaba/android/arouter/demo/BlankFragment.java
+++ b/app/src/main/java/com/alibaba/android/arouter/demo/BlankFragment.java
@@ -9,10 +9,12 @@
import android.widget.TextView;
import com.alibaba.android.arouter.facade.annotation.Autowired;
+import com.alibaba.android.arouter.facade.annotation.Route;
/**
* A simple {@link Fragment} subclass.
*/
+@Route(path = "/test/fragment")
public class BlankFragment extends Fragment {
@Autowired
diff --git a/app/src/main/java/com/alibaba/android/arouter/demo/MainActivity.java b/app/src/main/java/com/alibaba/android/arouter/demo/MainActivity.java
index 2d1cce8d..cbc7ae93 100644
--- a/app/src/main/java/com/alibaba/android/arouter/demo/MainActivity.java
+++ b/app/src/main/java/com/alibaba/android/arouter/demo/MainActivity.java
@@ -5,6 +5,7 @@
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityOptionsCompat;
+import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
@@ -151,6 +152,10 @@ public void onLost(Postcard postcard) {
.build("/test/activity2")
.navigation(this, 666);
break;
+ case R.id.getFragment:
+ Fragment fragment = (Fragment) ARouter.getInstance().build("/test/fragment").navigation();
+ Toast.makeText(this, "找到Fragment:" + fragment.toString(), Toast.LENGTH_SHORT).show();
+ break;
default:
break;
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 82b64231..52a86809 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -88,6 +88,13 @@
android:onClick="onClick"
android:text="跳转ForResult" />
+
+