开发者

Android Intents - putExtra, what happens with multiple occurances?

Let's say that I'm using an intent to get info back to the main class that called the current activity.

What would happen if say, I had two methods that might overlap the same field, like:

myIntent.putExtra("returnVal1",1000);
 // many lines of code, later on...
myIntent.putExtra("returnVal1",5);

Would the "开发者_StackOverflowreturnVal1" be updated to 5 in the intent, will it stay at 1000, or will this cause runtime crashes?

Thanks in advance, sent from mobile, not at a computer with eclipse atm or I would test myself!


It will overwrite it. The extra attributes are essentially a single-value hash: new values overwrite any existing values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜