package connection;
public class NewTask extends AsyncTask<String, String, String> implements ActivitySorter{
private XMPPClient MainActivity;
private XMPPConnection setConnection;
public static XMPPConnection connection;
private Context context;
public String payload = "<question id='56 'text='Favorite Food'><option id='1'>chinese</option><option id='2'>indian</option><option id='3'>thai</option>";
private Activity activity;
public static String payload_data = "";
public NewTask(Context context)
{
this.context=context;
}
@Override
protected String doInBackground(String... params) {
ServiceProviders.Register_Providers(ProviderManager.getInstance());
String host = "web.vlivetech.com"; //getText(R.id.host);
String port = "5222";
String service = "web.vlivetech.com"; // getText(R.id.service);
String username ="has12345"; // getText(R.id.userid);
String password = "123"; // getText(R.id.password);
// Create a connection
ConnectionConfiguration connConfig =
new ConnectionConfiguration(host, Integer.parseInt(port), service);
connection = new XMPPConnection(connConfig);
ServiceProviders.Register_Providers(ProviderManager.getInstance());
try {
connection.connect();
Log.i("XMPPClient", "[SettingsDialog] Connected to " + connection.getHost());
connection.login(username, password);
Log.i("XMPPClient", "Logged in as " + connection.getUser());
// Set the status to available
Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
} catch (XMPPException ex) {
Log.e("XMPPClient", "[SettingsDialog] Failed to connect to " + connection.getHost());
//MainActivity.setConnection(null);
}
// CustomIQ iq=new CustomIQ("<questionrequest xmlns='naseebprofile' group='Overview and Background' action='buildprofile'></questionrequest>");
// // CustomIQ iq=new CustomIQ("<questionrequest xmlns='profile' from='1' to='10' />");
// // set the type
// iq.setType(IQ.Type.GET);
// iq.setTo("web.vlivetech.com");
// //iq.setFrom("test@hassaan/Smack");
//
//
// connection.sendPacket(iq);
// <!-- IQ For retrieving auto matches -->
CustomIQ iq=new CustomIQ("<automatches xmlns='naseebautomatch' action='automatch'></automatches>");
// CustomIQ iq=new CustomIQ("<successstory xmlns='naseebsuccess' action='allstories'></successstory>");
// CustomIQ iq=new CustomIQ("<questionrequest xmlns='profile' from='1' to='10' />");
// set the type
iq.setType(IQ.Type.GET);
iq.setTo("web.vlivetech.com");
//iq.setFrom("test@hassaan/Smack");
connection.sendPacket(iq);
PacketFilter filter1 = new IQTypeFilter(IQ.Type.RESULT);
((Connection) connection).addPacketListener(new PacketListener() {
public void processPacket(Packet packet) {
CustomIQ iq = (CustomIQ) packet;
Log.i("gotresult", iq.toXML());
payload_data = iq.getPayload();
while(iq.getPayload() != "" || iq.getPayload() != null){ }
payload = iq.getPayload();
try {
context.startActivity(new Intent(context,ParserResult.class));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//ParserResult pr = new ParserResult();
/*pr.setPayload(payload);
pr.start_parsing();
payload = pr.getPayload();*/
}
}, filter1);
return null;
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
int a;
try {
Intent i = new Intent();
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i.setClass(context,ParserResult.class));
// Intent i = new Intent(NewTask.this,ParserResult.class);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private String getText(int id) {
EditText widget = (EditText) this.findViewById(id);
return widget.getText().toString();
}
private EditText findViewById(int id) {
// TODO Auto-generated method stub
return null;
}
@Override
public void sort(Intent arg0, List<ActivityResolveInfo> arg1,
List<HistoricalRecord> arg2) {
// TODO Auto-generated method stub
}
}
文字在这里:
E/AndroidRuntime(1329): java.lang.NoClassDefFoundError: connection.NewTask
E/AndroidRuntime(1329): at org.apache.android.xmpp.XMPPClient$1$1.run(XMPPClient.java:69)
E/AndroidRuntime(1329): at android.os.Handler.handleCallback(Handler.java:725)
答案 0 :(得分:0)
this is my menifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tabs_example_practice"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="org.apache.android.xmpp.XMPPClient"
android:label="XMPPClient" >
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="org.apache.android.xmpp.MainActivity"
android:label="@+string/title_activity_main" >
</activity>
<activity
android:name="adapters.ParserResult1"
android:label="@+string/title_activity_parser_result" >
</activity>
<activity
android:name="adapters.OptionsParser"
android:label="@+string/title_activity_parser_result" >
</activity>
<activity
android:name="adapters.ParserResult"
android:label="@+string/title_activity_parser_result" >
</activity>
<activity
android:name="org.apache.android.xmpp.Connection"
android:label="@+string/title_activity_connection" >
</activity>
<activity
android:name="connection.NewTask"
android:label="@string/app_name" >
</activity>
<activity
android:name="connection.Connection_Create"
android:label="@+string/title_activity_connection" >
</activity>
<activity
android:name="org.apache.android.xmpp.Success"
android:label="@+string/title_activity_success" >
</activity>
<activity
android:name="com.example.tabs_example_practice.MainActivity"
android:label="@+string/app_name" >
</activity>
<activity
android:name="com.example.tabs_example_practice.signup"
android:label="@+string/app_name" >
</activity>
<activity
android:name="com.example.tabs_example_practice.login"
android:label="@string/app_name" >
</activity><activity
android:name="com.example.tabs_example_practice.splash"
android:label="@string/app_name" >
</activity>
</application>
</manifest>