2011-12-23 73 views
3

我有一個查詢。我正在設計一個小部件。我有2個應用程序。我可以將意圖傳遞給其中一個應用程序。但是當我嘗試點擊FB時,我面臨問題,意圖不起作用。我將數據從1項活動傳遞給另一項時出錯。數據沒有從1個活動傳遞到另一個活動。putExtra數據不在活動之間傳遞

代碼類第一:

Intent i = getIntent(); 
String show = i.getStringExtra("show"); 
if(show.equals("facebook")) 
{ 
viewFlipper.setDisplayedChild(0); 
mListView.setAdapter(mFacebookAdapter); 
currentView = 0; 
} 
else if(show.equals("twitter")) 
{ 
viewFlipper.setDisplayedChild(1); 
mListView.setAdapter(mTwitterAdapter); 
currentView = 1 ; 
}  

第二類:

Intent facebook = new Intent(context, SocialList.class); 
facebook.putExtra("show", "facebook"); 
PendingIntent pendingfb = PendingIntent.getActivity(context, 0, facebook, 0); 

我需要從一個類傳遞值到另一個。在第二節課中,我需要首先從課程中獲得顯示值作爲「臉譜」。我怎樣才能做到這一點。請指導我。

在此先感謝。

回答

6

我正在使用的代碼。

插入數據:

Intent intent = new Intent(this, ProfileActivity.class); 
    intent.putExtra("profileId", userId); 
    startActivity(intent); 

檢索數據:

profileId = getIntent().getExtras().getString("profileId"); 
+1

是惡劣的是正確的使用他的方式 – Sameer 2011-12-23 08:52:20

+0

這有可能把數據回收側? – TripleS 2012-04-13 09:05:41