相关疑难解决方法(0)

从Fragment调用startIntentSenderForResult(Android Billing v3)

新的Android Billing v3文档和帮助程序代码startIntentSenderForResult()在启动购买流程时使用.我想从a开始购买流程(并收到结果)Fragment.

例如,文档建议调用

startIntentSenderForResult(pendingIntent.getIntentSender(),
    1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0),
    Integer.valueOf(0));
Run Code Online (Sandbox Code Playgroud)

帮助程序代码调用

mHelper.launchPurchaseFlow(this, SKU_GAS, 10001,   
    mPurchaseFinishedListener, "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
Run Code Online (Sandbox Code Playgroud)

哪个叫startIntentSenderForResult().

问题是,在父节点上调用调用startIntentSenderForResult()原因而不是从调用它的位置(调用位置)调用原因.onActivityResult()ActivityFragmentIabHelper

我无法接受的onActivityResult()Activity,然后手动调用onActivityResult()Fragment,但有一种方法,使一个呼叫startIntentSenderForResult()从一个Fragment直接结果返回到FragmentonActivityResult()

android android-fragments android-activity android-billing

53
推荐指数
2
解决办法
2万
查看次数

Android In App Billing:无法启动launchPurchaseFlow,因为launchPurchaseFlow正在进行中

我是第一次实施In App Billing,我正在使用静态SKU ID测试我的第一次购买.

它第一次运作良好.我致电mHelper.launchPurchaseFlow(...)并完成了测试购买.我的活动收到onActivityResult回调,我确保处理它mHelper.handleActivityResult(...).一切都很棒.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Pass on the activity result to the helper for handling
    log("onActivityResult");
    if (!this.mHelper.handleActivityResult(requestCode, resultCode, data)) {
        log("cleared the launch flow");
        // not handled, so handle it ourselves (here's where you'd
        // perform any handling of activity results not related to in-app
        // billing...
        super.onActivityResult(requestCode, resultCode, data);
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,我想测试下一部分,所以我重新启动了应用并尝试购买相同的SKU(静态purchasedSKU).

mHelper.launchPurchaseFlow(rootActivity, "android.test.purchased", 10002,   
       new IabHelper.OnIabPurchaseFinishedListener() {

        @Override …
Run Code Online (Sandbox Code Playgroud)

android in-app-billing android-billing

36
推荐指数
4
解决办法
3万
查看次数

永远不会调用onIabPurchaseFinishedListener

onIabPurchaseFinishedListener永远不会被调用,即使我在inapp对话框中单击立即购买,logcat也不会打印任何内容.

public class CreateAlbumActivity extends Activity {
IabHelper mHelper;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_create_album);
        mHelper = new IabHelper(this, Global.inapp);

    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
           public void onIabSetupFinished(IabResult result) {
              if (!result.isSuccess()) {
                 // Oh noes, there was a problem.
                 // AlertDialogHelper.CreateNormalDialog(context, "Failed to set In-App Billing: " +result);
                 Log.d(Global.TAG, "Problem setting up In-app Billing: " + result);
                 return;
              }            
                 // Hooray, IAB is fully set up!  

           }
        });
    }
 public void createAlbumEvent(){

                    mHelper.launchPurchaseFlow(CreateAlbumActivity.this, "android.test.purchased", 10001,   
                           mPurchaseFinishedListener, "bGoa+V7g/yqDXvKRqq"); …
Run Code Online (Sandbox Code Playgroud)

android in-app-purchase in-app-billing

6
推荐指数
2
解决办法
4611
查看次数