<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="您的应用包名">
<!-- 权限声明 -->
<!--三星商店权限-->
<uses-permission android:name="com.samsung.android.iap.permission.BILLING"/>
<application
...>
<!-- 三星商店 IAP Activity ↓↓↓-->
<!--发起支付请求-->
<activity
android:name="com.samsung.android.sdk.iap.lib.activity.PaymentActivity"
android:theme="@style/Theme.Empty"
android:configChanges="orientation|screenSize"/>
<!--请求商品列表-->
<activity
android:name="com.samsung.android.sdk.iap.lib.activity.ProductActivity"
android:theme="@style/Theme.Empty"
android:configChanges="orientation|screenSize"/>
<!--请求已购物品列表-->
<activity
android:name="com.samsung.android.sdk.iap.lib.activity.OwnedProductActivity"
android:theme="@style/Theme.Empty"
android:configChanges="orientation|screenSize"/>
<!--请求已购物品的消耗情况-->
<activity
android:name="com.samsung.android.sdk.iap.lib.activity.ConsumePurchasedItemsActivity"
android:theme="@style/Theme.Empty"
android:configChanges="orientation|screenSize"/>
<!-- 三星商店 IAP Activity ↑↑↑-->
</application>
</manifest>
private SamsungBillingSupport mSamsungBillingSupport;
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
//初始化三星商店内购
mSamsungBillingSupport = SamsungBillingSupport.getInstance(this, new BillingCallback() {
@Override
public void onPurchased(String productId, String orderId) {
//购买成功
}
@Override
public void onBillingInitialized() {
}
@Override
public void onError(int errorCode) {
//购买失败
}
});
}
/**
* 初始化三星商店内购实例
* @param activity 当前Activity
* @param billingCallback 购买回调
* @return
*/
public static SamsungBillingSupport getInstance(Activity activity, BillingCallback billingCallback)
/**
* 设置三星商店调试模式
* @param isDebug
*/
public void setDebugMode(boolean isDebug)
//设置三星商店调试模式
mSamsungBillingSupport.setDebugMode(true);
/**
* 购买商品
* @param itemId 商品ID
* @param userId 用户ID
* @param userName 用户角色名称
* @param serverId 服务器ID
* @param serverName 服务器名称
*/
public void purchase(String itemId, String userId, String userName, String serverId, String serverName)
String itemId = "ipa.tg.na002";//商品ID
String userId = "1";//用户ID
String userName = "test";//用户名称
String serverId = "1";//服务器ID
String serverName = "test";//服务器名称
//购买商品
mSamsungBillingSupport.purchase(itemId, userId, userName, serverId, serverName);