Android即时应用:是否可以从一个即时功能导航到其他子即时功能

bos*_*tan 0 android-instant-apps

我打算将当前的应用程序迁移到即时应用程序.所以我想知道是否可以从一个子即时功能模块导航到另一个即时功能模块.例如,我可能在一个详细信息功能,其中包含有关产品的必要信息,因此如果用户有兴趣购买该产品,那么我可以导航用户到支付功能模块(谷歌支付api目前不能满足我的目的,因为业务规则)即时模块目前支持这种导航吗?

Mus*_*tlu 5

当然这是支持的,否则使用即时应用程序非常有限.

您必须使用AppLink打开功能模块.拨打电话后,Android将根据需要下载该功能.

例如,这是Google Samples中使用的主要功能的开放详细信息功能流.

创建意图:

@NonNull
private static Intent getDetailActivityStartIntent(Context context,
                                                   int position,
                                                   PhotoViewHolder holder) {
    final Intent intent = new Intent(Intent.ACTION_VIEW,
            Uri.parse("https://multi-feature.instantappsample.com/detail/" + position));
    intent.setPackage(context.getPackageName());
    intent.addCategory(Intent.CATEGORY_BROWSABLE);

    TextView author =
            holder.itemView.findViewById(com.example.android.unsplash.base.R.id.author);

    // Working around unboxing issues with multiple dex files on platforms prior to N.
    intent.putExtra(IntentUtil.SELECTED_ITEM_POSITION, position);
    intent.putExtra(IntentUtil.FONT_SIZE, author.getTextSize());
    intent.putExtra(IntentUtil.PADDING,
            new Rect(author.getPaddingLeft(),
                    author.getPaddingTop(),
                    author.getPaddingRight(),
                    author.getPaddingBottom()));
    intent.putExtra(IntentUtil.TEXT_COLOR, author.getCurrentTextColor());
    return intent;
}
Run Code Online (Sandbox Code Playgroud)

开始吧:

final Intent intent = getDetailActivityStartIntent(activity, position, pvh);
final ActivityOptions activityOptions = getActivityOptions(pvh);
activity.startActivityForResult(intent, IntentUtil.REQUEST_CODE, 
    activityOptions.toBundle());
Run Code Online (Sandbox Code Playgroud)

结果的完成与非即时应用程序相同.

在DetailActivity中设置结果并完成它.获取MainActivity的onActivityResult结果.