Commit 80bbf5c0 authored by Jidong Chen's avatar Jidong Chen

Android params problem.

parent f6567808
...@@ -10,6 +10,7 @@ import com.taobao.idlefish.flutterboost.FlutterBoostPlugin; ...@@ -10,6 +10,7 @@ import com.taobao.idlefish.flutterboost.FlutterBoostPlugin;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
public class MainActivity extends AppCompatActivity implements View.OnClickListener { public class MainActivity extends AppCompatActivity implements View.OnClickListener {
...@@ -45,13 +46,15 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -45,13 +46,15 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Map params = new HashMap();
//Add some params if needed.
if (v == mOpenNative) { if (v == mOpenNative) {
PageRouter.openPageByUrl(this, PageRouter.NATIVE_PAGE_URL); PageRouter.openPageByUrl(this, PageRouter.NATIVE_PAGE_URL , params);
} else if (v == mOpenFlutter) { } else if (v == mOpenFlutter) {
PageRouter.openPageByUrl(this, PageRouter.FLUTTER_PAGE_URL); PageRouter.openPageByUrl(this, PageRouter.FLUTTER_PAGE_URL,params);
FlutterBoostPlugin.onPageResult("result_id_100",new HashMap(),new HashMap()); FlutterBoostPlugin.onPageResult("result_id_100",new HashMap(),new HashMap());
} else if (v == mOpenFlutterFragment) { } else if (v == mOpenFlutterFragment) {
PageRouter.openPageByUrl(this, PageRouter.FLUTTER_FRAGMENT_PAGE_URL); PageRouter.openPageByUrl(this, PageRouter.FLUTTER_FRAGMENT_PAGE_URL,params);
} }
} }
} }
...@@ -56,10 +56,10 @@ public class MyApplication extends FlutterApplication { ...@@ -56,10 +56,10 @@ public class MyApplication extends FlutterApplication {
* @return * @return
*/ */
@Override @Override
public boolean startActivity(Context context, String url, int requestCode) { public boolean startActivity(Context context, String url, Map params, int requestCode) {
Debuger.log("startActivity url="+url); Debuger.log("startActivity url="+url);
return PageRouter.openPageByUrl(context,url,requestCode); return PageRouter.openPageByUrl(context,url,params,requestCode);
} }
@Override @Override
......
...@@ -6,6 +6,9 @@ import android.support.v7.app.AppCompatActivity; ...@@ -6,6 +6,9 @@ import android.support.v7.app.AppCompatActivity;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import java.util.HashMap;
import java.util.Map;
public class NativePageActivity extends AppCompatActivity implements View.OnClickListener { public class NativePageActivity extends AppCompatActivity implements View.OnClickListener {
private TextView mOpenNative; private TextView mOpenNative;
...@@ -29,12 +32,13 @@ public class NativePageActivity extends AppCompatActivity implements View.OnClic ...@@ -29,12 +32,13 @@ public class NativePageActivity extends AppCompatActivity implements View.OnClic
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Map params = new HashMap();
if (v == mOpenNative) { if (v == mOpenNative) {
PageRouter.openPageByUrl(this, PageRouter.NATIVE_PAGE_URL); PageRouter.openPageByUrl(this, PageRouter.NATIVE_PAGE_URL,params);
} else if (v == mOpenFlutter) { } else if (v == mOpenFlutter) {
PageRouter.openPageByUrl(this, PageRouter.FLUTTER_PAGE_URL); PageRouter.openPageByUrl(this, PageRouter.FLUTTER_PAGE_URL,params);
} else if (v == mOpenFlutterFragment) { } else if (v == mOpenFlutterFragment) {
PageRouter.openPageByUrl(this, PageRouter.FLUTTER_FRAGMENT_PAGE_URL); PageRouter.openPageByUrl(this, PageRouter.FLUTTER_FRAGMENT_PAGE_URL,params);
} }
} }
} }
\ No newline at end of file
...@@ -4,17 +4,19 @@ import android.content.Context; ...@@ -4,17 +4,19 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.text.TextUtils; import android.text.TextUtils;
import java.util.Map;
public class PageRouter { public class PageRouter {
public static final String NATIVE_PAGE_URL = "sample://nativePage"; public static final String NATIVE_PAGE_URL = "sample://nativePage";
public static final String FLUTTER_PAGE_URL = "sample://flutterPage"; public static final String FLUTTER_PAGE_URL = "sample://flutterPage";
public static final String FLUTTER_FRAGMENT_PAGE_URL = "sample://flutterFragmentPage"; public static final String FLUTTER_FRAGMENT_PAGE_URL = "sample://flutterFragmentPage";
public static boolean openPageByUrl(Context context, String url) { public static boolean openPageByUrl(Context context, String url,Map params) {
return openPageByUrl(context, url, 0); return openPageByUrl(context, url,params, 0);
} }
public static boolean openPageByUrl(Context context, String url, int requestCode) { public static boolean openPageByUrl(Context context, String url, Map params, int requestCode) {
try { try {
if (url.startsWith(FLUTTER_PAGE_URL)) { if (url.startsWith(FLUTTER_PAGE_URL)) {
context.startActivity(new Intent(context, FlutterPageActivity.class)); context.startActivity(new Intent(context, FlutterPageActivity.class));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment