我的片段中有下一个代码(不是所有代码,而是一般部分):
public void BuySubscription(int number)
{
string vvalue = Security.Unify(
new string[] {
SpecialStringOne,
SpecialStringTwo,
SpecialStringThree,
SpecialStringFour,
SpecialStringFive,
SpecialStringSix,
new int[] { 3, 2, 0, 5, 1, 4 });
_serviceConnection = new InAppBillingServiceConnection(Activity, vvalue);
_serviceConnection.OnConnected += async () =>
{
await GetInventory();
_serviceConnection.BillingHandler.OnProductPurchased += delegate
{
// Reaction if product was bought
ExtraTools.StringWorker.ShowMessage("I have bought it!", false);
};
_serviceConnection.BillingHandler.BuyProduct(products[number]);
};
_serviceConnection.Connect();
}
我从未获得OnProductPurchased事件。
这是MainActivity中的通用代码:
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
{
Fragments.BillingFragment billingFragment = new Fragments.BillingFragment();
base.OnActivityResult(requestCode, resultCode, data);
if (billingFragment != null)
{
try
{
Fragments.BillingFragment._serviceConnection.BillingHandler.HandleActivityResult(requestCode, resultCode, data);
int code = data.GetIntExtra("ResponseCode", 2);
}
catch (NullReferenceException exc)
{
Toast.MakeText(Application.Context, "Some error occurred", ToastLength.Short).Show();
}
}
}
片段内部有什么问题?请帮帮我。
答案 0 :(得分:0)
我从未想过它可能是我的问题的原因,但当我从MainActivity中删除 LaunchMode = LaunchMode.SingleInstance 时,我已经被要求举办活动。
非常奇怪!