2011-12-23 69 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