我试图在 android 中实现应用购买。我已经正确设置了一切......我使用以下代码:
public void onClick(View v) {
switch (v.getId()) {
case R.id.main_purchase_yes:
if(BillingHelper.isBillingSupported()){
BillingHelper.requestPurchase(TopOption.this, "android.test.purchased");
// android.test.purchased or android.test.canceled or android.test.refunded or com.blundell.item.passport
} else {
Toast msg = Toast.makeText(TopOption.this, "Can't purchase on this device", Toast.LENGTH_LONG);
msg.setGravity(Gravity.CENTER, msg.getXOffset() / 2, msg.getYOffset() / 2);
msg.show();
Log.i(TAG,"Can't purchase on this device");
// XXX press button before service started will disable when it shouldnt
}
break;
default:
// nada
Log.i(TAG,"default. ID: "+v.getId());
break;
}
但是,如果我将产品 ID 而不是“android.test.purchased”设置为“com.company.item.itemID”,我从商店得到的响应是 ItemNotFound?有人知道该怎么做吗?
在我的 manifest.xml 中,我设置了所有内容,例如权限、服务和其他......而且我在任何地方都设置了 com.companyname.AppID。在谷歌解放军我已经设置了应用程序。以及我设置为已发布的项目。
有谁知道该怎么做?
更新:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.companyname.productid"
android:versionCode="1"
android:versionName="1.0" android:installLocation="preferExternal">
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="15" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.android.vending.BILLING" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/newname"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<activity
android:name=".TopOption"
android:label="@string/appName"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".mygame"
android:label="@string/title_activity_main"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".aboutclass"
android:label="@string/title_activity_main"
android:screenOrientation="portrait" >
</activity>
<service android:name=".BillingService" />
<receiver android:name=".BillingReceiver">
<intent-filter>
<action android:name="com.android.vending.billing.IN_APP_NOTIFY" />
<action android:name="com.android.vending.billing.RESPONSE_CODE" />
<action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED" />
</intent-filter>
</receiver>
</application>
</manifest>