Fra*_*ina 5 java android in-app-purchase google-play
我让我的应用内计费工作,但后来我移动了一些代码以获得更大的可扩展性,但它坏了。本质上,我试图做的是为我的插件制作一个适配器,以便以后可以更轻松地将它们添加到更少的编程工作中。我的项目在清单中具有计费权限,并且配置为在 Google Play 商店中计费,因此这不是问题。
广告活动
public class AdOnsActivity extends AppCompatActivity {
private IInAppBillingService mService;
private ServiceConnection mServiceConn = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ad_ons);
Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
listAdOns = findViewById(R.id.listAdOns);
Handler handler = new Handler();
handler.post(new Runnable() {
@Override
public void run() {
try {
...
listAdOns.setAdapter(new AdOnAdapter(AdOnsActivity.this, json.getJSONArray("adOns"), mService));
} catch (Exception e) {
Toast.makeText(AdOnsActivity.this, getResources().getString(R.string.error_load_ad_ons), Toast.LENGTH_SHORT).show();
e.printStackTrace();
finish();
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
AdOnAdapter
public class AdOnAdapter extends BaseAdapter {
public AdOnAdapter(Activity activity, JSONArray adOns, IInAppBillingService mService) throws RemoteException {
Bundle querySkus = new Bundle();
this.activity = activity;
this.adOns = adOns;
this.mService = mService;
skuDetails = mService.getSkuDetails(3, activity.getPackageName(), "inapp", querySkus);
responseDetails = skuDetails.getInt("RESPONSE_CODE");
ownedItems = mService.getPurchases(3, activity.getPackageName(), "inapp", null);
responseOwned = ownedItems.getInt("RESPONSE_CODE");
}
Run Code Online (Sandbox Code Playgroud)
此处列出了所有响应代码。
5 表示您正在使用无效参数调用 API。您以某种方式破坏了 API 调用。也许可以比较新旧版本代码下的 API 调用内容(您正在使用源代码控制吗?)。
| 归档时间: |
|
| 查看次数: |
3918 次 |
| 最近记录: |