我正在为我的应用程序中的App共享集成Branch IO。我已经在Branch的帮助下实现了共享URL功能,代码如下:
fun ShareApp(){
val appShare = BranchUniversalObject()
.setCanonicalIdentifier("app-share")
.setTitle(resources.getString(R.string.app_name))
.setContentImageUrl(AppConstants.AppIconURL)
.setContentIndexingMode(BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC)
val lp = LinkProperties()
.setChannel("facebook")
.setFeature("sharing")
val ss = ShareSheetStyle(this, appName, Message)
.setAsFullWidthStyle(true)
.setSharingTitle("Share With")
appShare.showShareSheet(this, lp, ss, object : Branch.BranchLinkShareListener {
override fun onShareLinkDialogLaunched() {}
override fun onShareLinkDialogDismissed() {}
override fun onLinkShareResponse(sharedLink: String, sharedChannel: String, error: BranchError) {}
override fun onChannelSelected(channelName: String) {}
})
}
每当我点击任何频道说Whatsapp,有时它会工作并带我去whatsapp。但很多时候频道没有被选中,它给了我下面的崩溃:
FATAL EXCEPTION: main
Process: com.eonian.reelo, PID: 10038
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter error
at com.eonian.reelo.ui.profile.profileSettings.ProfileSettingsActivity$ShareApp$1.onLinkShareResponse(ProfileSettingsActivity.kt:0)
at io.branch.indexing.BranchUniversalObject$LinkShareListenerWrapper.onLinkShareResponse(BranchUniversalObject.java:980)
at io.branch.referral.ShareLinkManager.shareWithClient(ShareLinkManager.java:309)
at io.branch.referral.ShareLinkManager.access$700(ShareLinkManager.java:32)
at io.branch.referral.ShareLinkManager$3.onLinkCreate(ShareLinkManager.java:282)
at io.branch.referral.ServerRequestCreateUrl.onUrlAvailable(ServerRequestCreateUrl.java:142)
at io.branch.referral.Branch.generateShortLinkInternal(Branch.java:2052)
at io.branch.referral.BranchUrlBuilder.generateUrlInternal(BranchUrlBuilder.java:140)
at io.branch.referral.BranchShortLinkBuilder.generateShortUrlInternal(BranchShortLinkBuilder.java:144)
at io.branch.referral.ShareLinkManager.invokeSharingClient(ShareLinkManager.java:278)
at io.branch.referral.ShareLinkManager.access$500(ShareLinkManager.java:32)
at io.branch.referral.ShareLinkManager$1.onItemClick(ShareLinkManager.java:233)
at android.widget.AdapterView.performItemClick(AdapterView.java:310)
at android.widget.AbsListView.performItemClick(AbsListView.java:1155)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3152)
at android.widget.AbsListView.onTouchUp(AbsListView.java:4079)
at android.widget.AbsListView.onTouchEvent(AbsListView.java:3838)
at android.view.View.dispatchTouchEvent(View.java:9942)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2344)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:411)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1810)
at android.app.Dialog.dispatchTouchEvent(Dialog.java:793)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:373)
at android.view.View.dispatchPointerEvent(View.java:10162)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4446)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4314)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3861)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3914)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3880)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4007)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3888)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4064)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3861)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3914)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3880)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3888)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3861)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6257)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6196)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6157)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6360)
大多数情况下,它最终会因为未被选中的频道名称而崩溃。实施中是否有任何问题?
由于
答案 0 :(得分:0)
为避免崩溃,请使用此签名:
override fun onLinkShareResponse(
sharedLink: String?,
sharedChannel: String?,
error: BranchError?)
然后你可以检查什么是null而不是获得低级异常。
我在Branch的网站上看到了代码,Kotlin样本看起来很破碎。我不认为error
总是非空的,即使没有错误也是如此。如果出现错误,sharedChannel
可能为空。