Intent 新方式

Intent 新方式

可以避免在传值的时候如果前后命名不统一出现的问题:

Class A extends Activity(){

        public static Intent newIntent(Context context,String url,String title) {
            Map<String,String> queryParameters=new LinkedHashMap<>();
            queryParameters.put(UrlConstant.USER_ID,"");
            queryParameters.put(UrlConstant.DEVICE_ID, "");
            url= UrlUtils.splitJoint(url,queryParameters);
            Bundle bundle=new Bundle();
            bundle.putString(A.WEB_VIEW_BUNDLE_TITLE,title);
            bundle.putString(A.WEB_VIEW_BUNDLE_LOAD_URL, url);
            Intent intent=new Intent(context, A.class);
            intent.putExtra(A.WEBVIEW_BUNDLE_NAME,bundle);
            return intent;
        }
    }


    Class B extends Activity{
    String incomeRuleUrl = ServiceUrlConstants.URL.getIncomeRuleUrl();
        startActivity(A.newIntent(this, incomeRuleUrl, "收益规则"));
    }