首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >Android向后倾斜通知意向仅获取上一部电影的数据

Android向后倾斜通知意向仅获取上一部电影的数据
EN

Stack Overflow用户
提问于 2018-01-24 15:10:48
回答 1查看 174关注 0票数 0

当点击我的应用程序发送到我的Android电视的任何通知时,我只能得到来自最后添加的通知的数据,而不是我点击的通知。

我的代码:

代码语言:javascript
代码运行次数:0
运行
复制
for (Asset asset : assets) {
    ContentRecommendation.Builder builder = new ContentRecommendation.Builder()
            .setBadgeIcon(R.drawable.icon);
    int id = asset.getId().hashCode();

    Intent detailsIntent = new Intent(mContext, LoginActivity.class);
    Bundle bundle = new Bundle();
    bundle.putParcelable(mContext.getString(R.string.key_asset), asset);
    detailsIntent.putExtra(MainActivity.EXTRA_ASSET, bundle);
    detailsIntent.setAction(Intent.ACTION_VIEW);

    builder.setIdTag("Asset" + id)
        .setTitle(asset.getTitle())
        .setText(asset.getCast().replace(",", ", "))
        .setGenres(asset.getGenres().split(","))
        .setRunningTime(asset.getDuration())
        .setContentIntentData(ContentRecommendation.INTENT_TYPE_ACTIVITY,
                detailsIntent, 0, null)
        .setStatus(ContentRecommendation.CONTENT_STATUS_AVAILABLE)
        .setPricingInformation(ContentRecommendation.CONTENT_PRICING_SUBSCRIPTION, "$4.99")
        .setContentTypes(new String[]{ContentRecommendation.CONTENT_TYPE_MOVIE, ContentRecommendation.CONTENT_TYPE_SERIAL})
        .setContentImage(Picasso.with(mContext).load(asset.getThumbnailUrl()).get())
        .setProgress((int) (asset.getDuration() % 100000), (int) (asset.getPauseTime() % 100000))
        .setMaturityRating(asset.getRating());

    ContentRecommendation rec = builder.build();
    Notification notification = rec.getNotificationObject(mContext);
    mNotifManager.notify(id, notification);
}

是什么导致了这个错误?我该如何解决它?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-24 15:14:28

您必须在setContentIntentData中为每个通知传递不同的请求代码。

代码语言:javascript
代码运行次数:0
运行
复制
 .setContentIntentData(ContentRecommendation.INTENT_TYPE_ACTIVITY,
                detailsIntent, diff_value, null)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48416727

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档