我想做什么


您好,我正在尝试为我的应用创建一些应用内商品,以供捐赠。因为我免费赠送我朋友的音乐-他说唱。无论如何,我在开发人员帐户上创建了5种应用内商品:

  • donate_small
  • donate_midsmall
  • donate_medium
  • donate_large
  • donate_xlarge

    这是我在此处生成的参考密钥。它们已保存并发布。现在,如果通过本教程编写了应用内服务:应用内简易教程。该代码似乎工作完美,没有错误,并且在我编译演示代码时可以正常工作。但是当我尝试它时,我总是遇到这个错误: 通用标签

    问题


    那我需要改变什么,用户可以选择不同的应用内商品?我需要在某个地方声明它们吗?另外,如果您有一个很棒的教程,并且所有内容都已很好地描述并且可以正常使用,请告诉我。

    这是我用于应用内服务的类:

    de.stepforward

    • ChannelActivity
    • SplashActivity

      de.stepforward.billing

      • AppMainTest.class->这是我的活动
      • BillingHelper.class
      • BillingReceiver.class
      • BillingSecurity.class
      • BillingService.class
      • C.class

        de.stepforward.billing.util

        • Base64.class
        • Base64DecoderException.class

          目前,我将为您提供BillingHelper和Activity的代码,如果您需要更多代码,请告诉我。

          代码


          AppMainTest.class 通用标签

          BillingHelper.class 通用标签


          谢谢您的帮助

          最好的问候

          野生动物园

          附录


          清单 通用标签

          LogCat(更多信息) 通用标签

有帮助吗?

解决方案

If you take a look at this method:

  private static boolean amIDead() {
    if (mService == null || mContext == null) {
        Log.e(TAG, "BillingHelper not fully instantiated");
        return true;
    } else {
        return false;
    }
}

That log is printed when your Service is null or your context. Aaaand your service is null when:

 protected static void instantiateHelper(Context context, IMarketBillingService service) {
            mService = service;
            mContext = context;
    }

instantiateHelper is not called aaand

 @Override
    public void onServiceConnected(ComponentName name, IBinder service) {
            Log.i(TAG, "Market Billing Service Connected.");
            mService = IMarketBillingService.Stub.asInterface(service);
            BillingHelper.instantiateHelper(getBaseContext(), mService);
    }

is called when your Service is connected, and I can see you attempt to connect to the service like this:

 startService(new Intent(mContext, BillingService.class));

SO:

Have you declared the service in your manifest?

 <application ...
     <service android:name=".BillingService" />
     ...
 </application>

EDIT

I was right :-) It's just your service tag is outside your application tag.

See here: https://stackoverflow.com/a/5439157/413127

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top