我通过this1,this 2 和
I could know where my problem is what I am doing in this code is: Here is my code what I done so far.
public class Registration extends Activity implements OnClickListener {
private final static String SERVER_HOST = "10.0.2.2";
private final static int SERVER_PORT = 5222;
private static final String TAG = null;
private ProviderManager pm;
private EditText username;
private Button btn;
private XMPPConnection connection;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.registration);
try {
initConnection();
} catch (XMPPException e) {
e.printStackTrace();
}
username = (EditText) this.findViewById(R.id.txtregusername);
btn=(Button) this.findViewById(R.id.btncheck);
btn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch(v.getId())
{
case R.id.btncheck:
try {
check();
} catch (XMPPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break;
}
}
private void check() throws XMPPException{
Toast.makeText(this,"Function called",Toast.LENGTH_SHORT).show();
pm.addIQProvider("query","jabber:iq:search", new UserSearch.Provider());
UserSearchManager search = new UserSearchManager(connection);
Form searchForm = search.getSearchForm("search."+connection.getServiceName());
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("Username", true);
Toast.makeText(this,username.getText().toString(),Toast.LENGTH_SHORT).show();
answerForm.setAnswer("search", username.getText().toString());
ReportedData data = search.getSearchResults(answerForm,"search."+connection.getServiceName());
if(data.getRows() != null)
{
Toast.makeText(this,"Username Exists",Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(this,"Username Available",Toast.LENGTH_SHORT).show();
}
}
private void initConnection() throws XMPPException{
ConnectionConfiguration config=new ConnectionConfiguration(SERVER_HOST,SERVER_PORT);
config.setSecurityMode(SecurityMode.enabled);
config.setSASLAuthenticationEnabled(true);
connection=new XMPPConnection(config);
try {
connection.connect();
}
catch (XMPPException e) {
Log.e(TAG, "Error connection to XMPP Server");
e.printStackTrace();
}
}
}
I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...