1
我在android中的appbiling服務中是全新的,它對我來說似乎有點複雜,我已經完成了所有的初始程序來實現它,但我陷入購買狀態(我認爲是這樣)。有一個列表視圖,並在onitem點擊收聽我已經做到了這一點:如何在Android的應用程序結算服務中正確使用?
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
purchaseposition= position;
if(list.get(position).getPurchase().contentEquals("Buy")){
val = billingService.requestPurchase("android.test.purchased", payloadContents);
}else{
SharedPreferences.Editor editor = preference.edit();
editor.putInt("URLPOSITION", position);
editor.commit();
Intent quiz=new Intent("com.powergroupbd.appbil.QUIZACTIVITY");
startActivity(quiz);
}
}
這意味着如果列表視圖包含一個文本「買入」,然後我送請求到市場與測試購入ID購買。現在,我希望如果購買成功,那麼我會將列表視圖的文本從「購買」更改爲「播放」,並啓用測驗。但是我認爲我錯過了這個部分。在購買狀態變化我寫了這個代碼來做到這一點:
@Override
public void onPurchaseStateChange(PurchaseState purchaseState,
String itemId, int quantity, long purchaseTime,
String developerPayload) {
if (Consts.DEBUG) {
Log.i("Tag", "onPurchaseStateChange() itemId: " + itemId + " "
+ purchaseState);
}
if (purchaseState == PurchaseState.PURCHASED) {
ownedItems.add(itemId);
list.get(purchaseposition).setPurchase("Play");
}
// YOU can also add other checks here
}
,但它永遠不會改變列表視圖的文本,我可以永遠玩測驗,請我需要一個完整的想法,我怎麼能做到這一點,在那裏是我的錯誤?謝謝