点击我的应用发送到Android TV的任何通知时,我只会从上次添加的通知中获取数据,而不是我点击的通知。
我的代码:
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);
}
导致此错误的原因是什么?如何解决?
答案 0 :(得分:1)
您必须在setContentIntentData中为每个通知传递不同的请求代码。
.setContentIntentData(ContentRecommendation.INTENT_TYPE_ACTIVITY,
detailsIntent, diff_value, null)