What is the difference between intent. putextra (bundle) and direct transfer with intent. putextra ("XX", YY )?

Source: Internet
Author: User

What is the difference between intent. putextra (bundle) and direct transfer with intent. putextra ("XX", YY )?

Reply

Guangdong-worms (346345565) 15:39:44

Let me answer this question.

Reply

Guangdong-worms (346345565) 15:39:54

I want to criticize you first

Reply

Guangdong-worms (346345565) 15:40:00

First, this is not a problem at all.

Reply

Guangdong-worms (346345565) 15:40:09

Second, this problem can be solved by Google.

Reply

Guangdong-worms (346345565) 15:40:14

Okay. Now let's get started.

Reply

Guangdong-worms (346345565) 15:40:24

First, Android is open-source

Reply

Guangdong-worms (346345565) 15:40:36

For any type, you can obtain the answer by viewing the source code.

Reply

Guangdong-worms (346345565) 15:40:59

What is the difference between bundle and intent? It feels like the two are used.

Reply

Guangdong-worms (346345565) 15:41:16

In fact, you can view the android source code, you will find

Reply

Guangdong-worms (346345565) 15:41:28

Both implement the parcelable and cloneable interfaces of Java.

Reply

Changsha-lysine (272803220) 15:41:38

 

Reply

Guangdong-worms (346345565) 15:41:51

These two interfaces can be used to serialize classes.

Reply

Guangdong-worms (346345565) 15:42:01

In layman's terms

Reply

Guangdong-worms (346345565) 15:42:08

These two interfaces can store classes

Reply

Guangdong-worms (346345565) 15:42:23

Therefore, bundle and intent are the same in the overall structure.

Reply

Guangdong-worms (346345565) 15:42:33

So why are both of them used?

Reply

Guangdong-worms (346345565) 15:42:41

The following is a scenario for you to answer:

Reply

Changsha-lysine (272803220) 15:42:44

Hmm

Reply

Guangdong-worms (346345565) 15:42:52

I have four activities, A, B, C, and D.

Reply

Guangdong-worms (346345565) 15:43:08

I want to pass 8 int types to D in

Reply

Guangdong-worms (346345565) 15:43:13

What do you do?

Reply

Guangdong-worms (346345565) 15:43:23

Of course, the path must go through B, c

Reply

Guangdong-worms (346345565) 15:43:33

That is, a-> B-> C-> d

Reply

Guangdong-worms (346345565) 15:43:45

If you use a traditional intent

Reply

Guangdong-worms (346345565) 15:44:03

You need putint8.

Reply

Changsha-lysine (272803220) 15:44:11

Yes

Reply

Guangdong-worms (346345565) 15:44:21

B. After receiving the goods with getintent ()

Reply

Guangdong-worms (346345565) 15:44:36

Again, send intent, Nima putint8 times

Reply

Guangdong-worms (346345565) 15:44:51

Similarly, it would take 8 times for C Nima to go there, so there would be no dead?

Reply

Guangdong-worms (346345565) 15:45:05

If a gets a bundle directly

Reply

Changsha-lysine (272803220) 15:45:11

Well, that's exactly what I want to do .. There are several pages that cannot be used

Reply

Guangdong-worms (346345565) 15:45:19

B and C can be directly transmitted to d by resolving a bundle.

Reply

Guangdong-worms (346345565) 15:46:06

Do you understand now?

Reply

Guangdong-worms (346345565) 15:46:15

OK. The answer is complete. Please applaud.

Reply

Wuhan-dreamer (498557849) 15:46:39

 

Reply

Changsha-lysine (272803220) 15:47:18

 

Reply

Shenyang-milk tea (627408355) 15:47:32

 

Reply

Changsha-lysine (272803220) 15:47:46

Still do not understand

Reply

BEIJING-wood (316297629) 15:50:20

Use your preferred method
(From mobile phone qq2012 [Android]: http://mobile.qq.com)

 

Reply

Changsha-lysine (272803220) 15:52:08

Sorry, I just read the source code of a netizen. It is true that the bundle is used directly in the Activity B. Correct without assigning values.

 

Reply

Wuhan-dreamer (498557849) 15:53:14

Don't assign values every time?

 

Reply

Wuhan-dreamer (498557849) 15:53:23

Is that the difference?

 

Reply

Guangdong-worms (346345565) 15:53:47

Basically

 

Reply

Wuhan-dreamer (498557849) 15:54:16

That's a bit the same as JSP containers. The lifecycle is different.

 

Reply

Changsha-lysine (272803220) 15:54:37

Yes. From bundle literally, English is the bundle, that is, after a packs data, we can use it directly in B c d.

 

Reply

Wuhan-dreamer (498557849) 15:54:37

Request, session, application or something

 

Reply

Guangdong-worms (346345565) 15:56:38

Once you read the intent code, you will find

 

Reply

Guangdong-worms (346345565) 15:56:51

Intent has a bundle field, so everything is clear.

 

Reply

Guangdong-worms (346345565) 15:57:04

You have rewritten the putxxx method.

 

Reply

Guangdong-worms (346345565) 15:57:18

Putxxx of intent is bundle goods

 

Reply

Guangdong-worms (346345565) 15:57:36

 

 

Reply

Shenzhen-... (125721515) 15:57:40

Bugs and ox x

 

Reply

Guangdong-worms (346345565) 15:58:05

The bundle can be putxxx, and you will understand the source code.

 

Reply

Guangdong-worms (346345565) 15:58:10

It's like hashmap.

 

Reply

Guangdong-worms (346345565) 15:59:24

 

Reply

Shenzhen-... (125721515) 15:59:42

 

 

Reply

Guangdong-worms (346345565) 15:59:46

We recommend that you prepare a copy of the android source code.

 

Reply

Guangdong-worms (346345565) 15:59:54

Source insight

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.