隐式意图与startService是不是安全InAppPurchase [英] Implicit intents with startService are not safe InAppPurchase
问题描述
我实现了应用程序内购买在我的应用程序,我面对这个问题
I've implemented In-app purchase in my application and I face this problem
隐性意图与startService是不是安全:意向{行为= com.android.vending.billing.InAppBillingService.BIND} android.content.ContextWrapper.bindService:538 com.bulbulapps.bulbul.v3.BillingProcessor.bindPlayServices:106 com.bulbulapps.bulbul.v3.BillingProcessor:99
Implicit intents with startService are not safe: Intent { act=com.android.vending.billing.InAppBillingService.BIND } android.content.ContextWrapper.bindService:538 com.bulbulapps.bulbul.v3.BillingProcessor.bindPlayServices:106 com.bulbulapps.bulbul.v3.BillingProcessor.:99
我的code:
getContext().bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), serviceConnection, Context.BIND_AUTO_CREATE);
但该行正在生成一个警告隐性意图与startService并不安全。
but that line is generating a warning Implicit intents with startService are not safe.
付款弹出来了,也支付成功,但成功后不来OnActivity结果
Payment popup coming and payment also success, but after success it is not coming to OnActivity result
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (!bp.handleActivityResult(requestCode, resultCode, data))
super.onActivityResult(requestCode, resultCode, data);
Toast.makeText(getApplicationContext(), "onActivityResult", Toast.LENGTH_LONG).show();
}
我的要求是我要处理成功购买后。
My requirement is I have to handle after successful purchase.
推荐答案
做这样的:
Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
使用明确的目的只是为了绑定服务,否则会在安卓5.0及以上抛出异常。
Use explicit intent only to bind a service otherwise it will throw exception in Android 5.0 and above.
安卓5.0还之前,建议使用明确的意图只有绑定的服务。
Before Android 5.0 also it is suggested to use explicit intent only to bind a service.
在Context.bindService()方法现在需要一个明确的意图,并 抛出一个异常,如果给定一个隐含的意图。为确保您的应用程序是 安全,启动或绑定您的服务时,使用一个明确的意图, 和不申报的意图过滤器的服务。
The Context.bindService() method now requires an explicit Intent, and throws an exception if given an implicit intent. To ensure your app is secure, use an explicit intent when starting or binding your Service, and do not declare intent filters for the service.
检查这种行为的改变这里。
这篇关于隐式意图与startService是不是安全InAppPurchase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!