与谷歌应用内结算工作吗? [英] Working with Google in-app billing?
本文介绍了与谷歌应用内结算工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的应用程序使用谷歌在应用程序内结算。我的code剂量没有任何错误在Eclipse中,但是当我在我的手机是强制关闭运行它!和日志猫点错误新的Thread行。有什么问题?我应该心存感激,如果有人可以提供帮助。
I'm trying to use Google in app billing in my app. My code dose not have any error in eclipse but when I run it on my phone it force closes! and log cat points error to "new Thread" line. what is the problem? I'll be thankful if someone could help.
下面是我的code:
在的onCreate下捐赠按钮:
in onCreate under donate button:
@Override
public void onClick(View v) {
new Thread(new Runnable() {
public void run() {
ArrayList<String> skuList = new ArrayList<String>();
skuList.add("My Selling Obj ID");
Bundle querySkus = new Bundle();
querySkus.putStringArrayList("My App’s RSA Key"
, skuList);
Bundle skuDetails;
try {
skuDetails = mService.getSkuDetails(3, getPackageName(), "inapp", querySkus);
int response = skuDetails.getInt("RESPONSE_CODE");
if (response == 0) {
ArrayList<String> responseList
= skuDetails.getStringArrayList("DETAILS_LIST");
for (String thisResponse : responseList) {
JSONObject object = new JSONObject(thisResponse);
String sku = object.getString("productId");
String price = object.getString("price");
if (sku.equals("My Selling Obj ID"))
pool = price;
}
}
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Bundle buyIntentBundle;
try {
buyIntentBundle = mService.getBuyIntent(3, getPackageName(),
"My Selling Obj ID", "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
startIntentSenderForResult(pendingIntent.getIntentSender(),
1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0),
Integer.valueOf(0));
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SendIntentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}).start();
}
在的onActivityResult:
in onActivityResult:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1001) {
int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
if (resultCode == RESULT_OK) {
try {
JSONObject jo = new JSONObject(purchaseData);
String sku = jo.getString("productId");
Toast.makeText(Main.this, "thanks for Donation!", Toast.LENGTH_SHORT).show();
Toast.makeText(Main.this, pool,
isdonated = 1;
}
catch (JSONException e) {
//alert("Failed to parse purchase data.");
Toast.makeText(Main.this, "Donation Failed!", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
}
}
下面是logcat的错误:
http://upload7.ir/imgs/2014-02/08566691322028747175.jpg
here is logcat errors: http://upload7.ir/imgs/2014-02/08566691322028747175.jpg
推荐答案
你有没有加入这个权限您清单文件?
Have you added this permission to you manifest file?
<uses-permission android:name="com.android.vending.BILLING"/>
这篇关于与谷歌应用内结算工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文