This is my Roster class.
public class RosterList extends Activity {
/** Called when the activity is first created. */
Variables var = new Variables();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.roster);
Roster roster = var.connection.getRoster();
Collection<RosterEntry> entries = roster.getEntries();
TextView tv;
for (RosterEntry r : entries) {
tv = (TextView)findViewById(R.id.rosterString);
tv.append(r.getUser().toString()+ "\n");
}
}
}
I have created a separate class for hold variables which is Variables. There i have created my XMPPConnection-variable and others. But there are some runtime errors in this code.
Error occurs when roster-object is created. How can i access the XMPPConnection for this class? Why can’t i create an instance of the Variables class and access connection variable ?
Static variables solved the problem. 🙂