b.activity配置,这里com.gan.mypay改成自己的包名(如果自己包名与src下的package 名不一样,这里要的是在manifest中配置的名称,同样需要在src建立以自己包 名为路经的package,一定确保有这个activity)这个activity是微信支付结果要回调的activty。
android:name=“com.gan.mypay.wxapi.WXPayEntryActivity”
android:exported=“true”
android:launchMode=“singleTop”/>
2.代码继承
(1)首先要有一个商品页MainActivity,用来收集商品信息,这里需要后台交互生成订单,我们这里做的一个假的订单。
MainActivity.java(这里用了xutils的注入)
@ContentView(R.layout.activity_main)
public class MainActivity extends Activity {
private Goods goods;
private String username;
private String mobile;
private String adress;
private int count;
@ViewInject(R.id.product_ordsubmit_username)
private TextView usernameTV;
@ViewInject(R.id.product_ordsubmit_phone)
private TextView phoneTV;
@ViewInject(R.id.product_ordsubmit_adress)
private TextView adressTV;
@ViewInject(R.id.product_ordsubmit_desc)
private TextView descTV;
@ViewInject(R.id.product_ordsubmit_price)
private TextView priceTV;
@ViewInject(R.id.product_ordsubmit_intg)
private TextView intgTV;
@ViewInject(R.id.product_ordsubmit_count1)
private TextView countTV1;
@ViewInject(R.id.product_ordsubmit_count)
private TextView countTV;
@ViewInject(R.id.product_ordsubmit_intgtotal1)
private TextView intgtotal1TV;
@ViewInject(R.id.product_ordsubmit_intgtotal2)
private TextView intgtotal2TV;
@ViewInject(R.id.product_ordsubmit_pricetotal1)
private TextView pricetotal1TV;
@ViewInject(R.id.product_ordsubmit_pricetotal2)
private TextView pricetotal2TV;
@ViewInject(R.id.product_ordsubmit_counttotal)
private TextView counttotalTV;
@ViewInject(R.id.product_ordsubmit_ok)
private Button okBtn;
@ViewInject(R.id.product_ordsubmit_say_et)
private TextView sayEt;
@ViewInject(R.id.product_ordsubmit_img)
private ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ViewUtils.inject(this);
goods = new Goods();
goods.costprice=100;
goods.productid=692356222;
goods.producttypeid=11;
goods.productname=“测试商品”;
goods.discountprice=0.01;
goods.productdescription=“商品描述”;
goods.companydesc=“测试商户简单描述”;
goods.comanyadress=“商户地址未知”;
goods.companyname=“测试商户”;
goods.score=1;
goods.status=1;
goods.stock=300;
count=1;
initData();
initView();
}
private void initData() {
username =“客户名称”;
mobile = “13800380038”;
adress=“客户地址”;
}
private void initView() {