如何测试Android的广播时,包括额外的捆绑? [英] How to include a bundle extra when testing Android broadcasts?
问题描述
我目前正在测试谷歌的App邀请,但我有一个艰难的时间测试 INSTALL_REFERRER
播放功能没有把一个应用程序了Play商店
I'm currently trying to test Google's App Invites, but I'm having a tough time testing the INSTALL_REFERRER
broadcast feature without putting an app up on the Play Store
应用程序邀请广播意图需要一个名为com.google.android.gms.appinvite.REFERRAL_BUNDLE
捆绑额外的,它在 AppInviteReferral <检查/ code>像这样:
App Invite broadcast intents require a bundle extra named "com.google.android.gms.appinvite.REFERRAL_BUNDLE"
and it's checked in AppInviteReferral
like so:
public static boolean hasReferral(Intent referralIntent) {
return referralIntent != null && referralIntent.getBundleExtra("com.google.android.gms.appinvite.REFERRAL_BUNDLE") != null;
}
在使用测试广播亚行外壳AM广播...
,我们所能做的最好的就是添加额外的,但有没有选择添加一个额外的包。 (这里 文档)
When testing broadcasts using adb shell am broadcast ...
, the best we can do is add extras, but there's not option to add a bundle extra. (documentation here)
任何人都知道一个包如何被纳入广播的一部分吗?
Anyone know how a bundle could be included as a part of the broadcast?
推荐答案
在此职位说这是不可能通过亚行把包额外的费用。你可以写简单的测试应用程序,应用程序发送邀请的意图你想要什么:
In this post say it is impossible to put bundle extra through adb. You can write simple test application and send app invite intent what you want:
Intent intent = new Intent("com.android.vending.INSTALL_REFERRER");
intent.setPackage("your_package");
Bundle bundle = new Bundle();
bundle.putString("com.android.vending.INSTALL_REFERRER", "your_invite_id");
bundle.putString("com.google.android.gms.appinvite.DEEP_LINK", "your_deep_link");
intent.putExtra("com.google.android.gms.appinvite.REFERRAL_BUNDLE", bundle);
sendBroadcast(intent);
我已经测试谷歌的应用程序以这种方式邀请,而是通过亚行试图发送意图太前。
I have tested google app invite in this way, but before tried to sent intent through adb too.
这篇关于如何测试Android的广播时,包括额外的捆绑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!