大家好 :) 我正在尝试在我的应用程序中实现应用内计费,并在 GitHub 中观看 RobotMedia 的 README 我已经这样做了:
我正在尝试这个:
aba = new AbstractBillingActivity() {
@Override
public String getPublicKey() {
// TODO Auto-generated method stub
return null;
}
@Override
public byte[] getObfuscationSalt() {
// TODO Auto-generated method stub
return null;
}
@Override
public void onSubscriptionChecked(boolean supported) {
// TODO Auto-generated method stub
}
@Override
public void onRequestPurchaseResponse(String itemId, ResponseCode response) {
// TODO Auto-generated method stub
}
@Override
public void onPurchaseStateChanged(String itemId, PurchaseState state) {
// TODO Auto-generated method stub
}
@Override
public void onBillingChecked(boolean supported) {
// TODO Auto-generated method stub
}
};
当我尝试这样做时,字节:
aba.checkBillingSupported();
它给了我关于变量“aba”的NullPointerException
编辑
我已经这样做了:
public class Index extends AbstractBillingActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_index);
checkBillingSupported();
Button buy = (Button) findViewById(R.id.compra);
buy.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
requestPurchase("android.test.purchased");
}
});
}
@Override
public byte[] getObfuscationSalt() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getPublicKey() {
// TODO Auto-generated method stub
return null;
}
@Override
public void onBillingChecked(boolean supported) {
// TODO Auto-generated method stub
}
@Override
public void onSubscriptionChecked(boolean supported) {
// TODO Auto-generated method stub
}
@Override
public void onPurchaseStateChanged(String itemId, PurchaseState state) {
// TODO Auto-generated method stub
}
@Override
public void onRequestPurchaseResponse(String itemId, ResponseCode response) {
// TODO Auto-generated method stub
}
}