Can Manifest Receiver for In app payment be moved to Java code instead?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 14:10:01

问题


Google example for in-app payment suggests to add the manifest entry in order to receive the payment confirmations. But in Native Extension for AIR, the receiver will not be found as its a different package. So i moved the receiver part to code as follows

final IntentFilter filter = new IntentFilter("com.android.vending.billing.IN_APP_NOTIFY");
filter.addAction("com.android.vending.billing.RESPONSE_CODE");
filter.addAction("com.android.vending.billing.PURCHASE_STATE_CHANGED");

a.registerReceiver(billingReceiver, filter);   

But the service's onreceive() method never gets called.

Is there a different way of registering the activity to get receiver calls?


回答1:


According to some reference sites, adding the billing receiver in code doesn't work. So moved it to manifest file, removed the package and referred it from the root directory. So problem solved.

Manifest for AIR app would look like this for more info for those who are trying out!

<android>
    <manifestAdditions>

      <![CDATA[
      <manifest android:installLocation="auto">
       <uses-permission android:name="com.android.vending.BILLING" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.RECORD_AUDIO"/>
      <uses-permission android:name="android.permission.VIBRATE"/>

        <application>

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

        <receiver android:name="<package>.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>]]>
    </manifestAdditions>
  </android>


来源:https://stackoverflow.com/questions/10547507/can-manifest-receiver-for-in-app-payment-be-moved-to-java-code-instead

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!