Intent extras 에 Hashtable 넘길 때

인텐트로 해시테이블 데이타를 passing 할 때 방법입니다.

인텐트에 해시테이블을 넘길 때
// A.class
Hashtable m_hash = new Hashtable();
m_hash.put("1", "aimh" );
m_hash.put("2", "tcher" );
m_hash.put("3", "picomax" );

Intent intent = new Intent(this, B.class);
intent.putExtra("data", m_hash);


해시테이블 데이타를 받을 때
// B.class
Serializable m_data = getIntent().getSerializableExtra("data");
Hashtable m_hash = new Hashtable((HashMap)m_data);
//m_hash.get("1");
//m_hash.get("2");
//m_hash.get("3");

Posted by Tcher

2010/02/22 13:42 2010/02/22 13:42
, , ,
Response
No Trackback , 5 Comments
RSS :
http://blog.inculab.net/rss/response/32

Trackback URL : http://blog.inculab.net/trackback/32

Comments List

  1. pandora jewellery 2011/04/14 15:17 # M/D Reply Permalink

    Hey! I just wish to give a huge thumbs up for the great information you have right here on this post. I might be coming again to your blog for extra soon.

  2. 소프트 2011/04/19 18:37 # M/D Reply Permalink

    넘길 때

  3. 자유 2011/05/20 16:52 # M/D Reply Permalink

    인텐트에 해시테이블을 넘길 때

  4. ray ban outlet 2011/10/20 12:20 # M/D Reply Permalink

    new style <a href="http://www.echeapraybansunglasses.com/"><strong>ray ban 2140</strong></a> sunglasses and <a href="http://www.echeapraybansunglasses.com/"><strong>ray bans outlet</strong></a> on there, people like cool <a href="http://www.echeapraybansunglasses.com/"><strong>ray ban 3025</strong></a>, no sunlight that buy <a href="http://www.echeapraybansunglasses.com/"><strong>aviator sunglasses for men</strong></a> nice.

  5. www.christianloubout 2011/12/12 21:57 # M/D Reply Permalink

    clx
    http://www.christianlouboutinsalessneakers.com/christian-louboutin-2011-c-36.html
    http://www.christianlouboutinsalessneakers.com/christian-louboutin-2011-c-36.html
    http://www.christianlouboutinsalessneakers.com/christian-louboutin-pumps-c-26.html
    http://www.christianlouboutinsalessneakers.com/christian-louboutin-sandals-c-31.html
    http://www.christianlouboutinsalessneakers.com/christian-louboutin-wedges-c-29.html
    http://www.christianlouboutinsalessneakers.com/christian-louboutin-slingback-c-30.html

Leave a comment
[로그인][오픈아이디란?]
인텐트를 가장 많이 사용하는 형태는 다음과 같이 다른 Activity 로 message 를
전달 하는 형태다.

 
1)
Intent intent = new Intent(this, A.class);
startActivity(intent);
위 코드는 다음과 같이도 구현이 가능하다.

2)
Intent intent = new Intent();
intent.setClassName(this, "com.inculab.android.Test.A") // full package path 사용
startActivity(intent);

다른 점을 보자면
1) 은 Class 를 직접 인자로 취하는 거고 2)는 String 을 인자로 취한다.

Login 을 구현할 일이 있었는데
Login 을 하고 난 이후 redirect activity 기능이 필요했다.
A 라는 Activity 에서 LoginForm Activity 에 메시지를 보내고
LoginForm Activity 에서는 A 에서 보낸 redirect activity 인 B Activity 로 다시
메시지를 보낸다.

// A.java
Intent intent = new Intent(this, LoginForm.class);
intent.putExtra("redirect_url", "com.inculab.android,Test.B");
startActivity(intent);

// LoginFom.java
Intent intent = getIntent();
String m_redirect_url = intent.getStringExtra("redirect_url");

Intent intent2 = new Intent();
intent2.setClassName(this, m_redirect_url);
startActivity(intent2);

LoginForm 에서 1) 과 같이 Class 를 바로 전달 하면 좋겠지만
intent 에서 받아 올 때 는 String, Float, Integer, Bundle 형태만 지원하는 것 같다.
String 형태로 받아 올 경우 2) 와 같이 처리하면 된다.


Posted by Tcher

2010/02/18 10:29 2010/02/18 10:29
, ,
Response
No Trackback , 4 Comments
RSS :
http://blog.inculab.net/rss/response/31

Trackback URL : http://blog.inculab.net/trackback/31

Comments List

  1. pandora jewellery 2011/04/14 15:16 # M/D Reply Permalink

    I've been waiting for a feature like this! Yesterday while I was listening to a nostalgic tune from high school I thought to myself, "I wish I could share this with my HS friends on my FB page", and now I can.

    Thanks for the update! Looking for more integration in the future.

  2. 코드는 2011/04/20 22:13 # M/D Reply Permalink

    다음과 같이도 구현이 가능하다.

  3. FX 2011/04/22 16:32 # M/D Reply Permalink

    인텐트를 가장 많이 사용하는 형태는 다음과 같이 다른 Activity 로 message 를
    전달 하는 형태다.

  4. message 2011/05/24 21:33 # M/D Reply Permalink

    전달 하는 형태다.

Leave a comment
[로그인][오픈아이디란?]

블로그 이미지

- Tcher

Notices

Site Stats

Total hits:
84624
Today:
60
Yesterday:
91