////// in first Activity
@Override
public void onClick(View v) {
if(v==btn){
Intent i= new Intent(ChatActivity.this ,MainActivity.class);
i.putExtra("name",0);
startActivity(i);
}
}
//////////// in second activity oncreate method
Intent i=getIntent();
int name=i.getIntExtra("name",10);
demo(name);
////// in demo method
private void demo(int name) {
if(name==0){
purchase();
}
}
////// in purchase method
public void purchase(){
bp.purchase(MainActivity.this,PRODUCT_ID);
showToast("in purchase Method !!!");
}
inApp购买所有类包含在我的应用程序中,但第一个语句不起作用,第二个工作。如果我分开运行第二个类没有开关工作正确.plz帮助。
答案 0 :(得分:0)
更改你的onClick()方法,如下所示:
@Override
public void onClick(View v) {
if(v.getId()== btn){// this can be also used as v.getId() == R.id.btn
Intent i= new Intent(ChatActivity.this ,MainActivity.class);
i.putExtra("name",0);
startActivity(i);
}
}
希望这有帮助。