本文介绍了Clearning活动的意图数据随机回来,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有启动时的意图被发送到与下面的意图额外的玩家活动播放媒体的应用;数据路径的音乐,然后键入哑剧/音频格式。

I have a media application which starts playback when the intent is sent to the player activity with the following intent extras; data "path to the music" and type "mime/audio format".

我拿起在玩家活动的意图数据执行开始播放,我从打算删除通过临时演员,以避免翻转屏幕或活动被带回前台后,同样的请求再次去。

I pick up the intent data at the player activity execute to start playback and I remove the passed extras from the intent to avoid having the same request going again after flipping the screen or the activity being brought back to the foreground.

这是我如何处理意向:

final String data = getIntent().getDataString();
final String type = getIntent().getType();

// start playback
    requestPlay( data, type );

    // remove intents because they are needed only once per call!
    this.getIntent().setDataAndType(Uri.parse(""), "");
    this.getIntent().removeExtra("data");
    this.getIntent().removeExtra("type");

我遇到的问题是随机的,很少,我会打开应用程序,并继续在玩家活动时,意图将包含previous额外的数据,并开始播放...这是烦人我和我的好...用户

The issue I'm having is that randomly and rarely, I will open the application and when it resumes at the player activity, the intent will contain the previous extra data and start playing... This is annoying to me and well my users...

任何人有任何的想法是什么,清除意图数据的最佳方式是什么?某些原因,ActivityManager可能会保持此数据存储...?

Anyone have any ideas what's the best way to clear the intents data? Some reason the ActivityManager might be keeping this data stored...?

谢谢!

-Jona

推荐答案

我的解决方法:

Bundle mExtrass = null;
getIntent().replaceExtras(mExtrass);

这清除多余的数据。

And this clear the extra data.

这篇关于Clearning活动的意图数据随机回来,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 14:30