I am working on an Android application which allow user to write feedback and then the articleID, ticketID and ticketnumber of the user will be generated by the server and be returned to the user.
There are two activity in this application. MainActivity allow the user to enter their details and a submit button will start Process activity that will send the details to the server and shows the articleID, ticketID and ticketnumber that are returned.
The problem is, it will only work once every time the application is started. For example, a user open the application and enter his details, the submit button is pressed and the corresponding articleID, ticketID and ticketnumber are returned. Then he tries to submit a second one by returning to the previous activity. He enters his detail again and press submit. This time, null is returned.
Images of example is shown here https://i.stack.imgur.com/unf2N.jpg
However, the application works again if it is quitted and the RAM is cleared.
I tried to use this method here to restart the application but still it did not work.
Below is the kSoap code in the Process activity.
public class Process extends Activity{
private String URL = " /*WORKING URL*/";
private String NAMESPACE = "/*WORKING URL*/";
private String soapUsername = "/*WORKING USERNAME*/";
private String soapPass = "/*WORKING PASSWORD*/";
private String METHOD_NAME = "TicketCreate";
private String SOAP_ACTION = "/*WORKING URL*/";
private Handler handler = new Handler();
private Thread thread;
TextView emailT, subjectT, complaintT, responseT, nameT;
String email, subject, complaint, name;
String articleid , ticketid ,ticketnumber;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.process);
webservice();
nameT = (TextView) findViewById(R.id.name);
emailT = (TextView) findViewById(R.id.email);
subjectT = (TextView) findViewById(R.id.subject);
complaintT = (TextView) findViewById(R.id.complaint);
responseT = (TextView) findViewById(R.id.responsevalue);
Intent i = getIntent();
// Receiving the Data
name = i.getStringExtra("name");
email = i.getStringExtra("email");
subject = i.getStringExtra("subject");
complaint = i.getStringExtra("complaint");
// Displaying Received data
nameT.setText(name);
emailT.setText(email);
subjectT.setText(subject);
complaintT.setText(complaint);
Button fin= (Button)findViewById(R.id.finish);
fin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
finish();
}
});
}
public void webservice(){
thread = new Thread(){
public void run(){
try
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
// Set all input params
request.addProperty("UserLogin", soapUsername);
request.addProperty("Password", soapPass);
Hashtable<String, String> ticket = new Hashtable<String, String>();
ticket.put("Title", subject);
ticket.put("CustomerUser", email);
ticket.put("CustomerID", "soapwebnologin");
ticket.put("QueueID", "3");
ticket.put("State", "new");
ticket.put("PriorityID", "1");
ticket.put("Lock", "unlock");
ticket.put("OwnerID", "1");
request.addProperty("Ticket", ticket);
Hashtable<String, String> article = new Hashtable<String, String>();
article.put("Subject", subject);
article.put("Body", complaint);
article.put("ContentType", "text/plain; charset=utf8");
request.addProperty("Article", article);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
new MarshalHashtable().register(envelope);
envelope.dotNet = true;
envelope.bodyOut = request;
String check = checkSSL(URL);
if(check == "SSL"){
KeepAliveHttpsTransportSE httpT = new KeepAliveHttpsTransportSE("/*WORKING URL*/", /*WORKING PORT*/, METHOD_NAME, 15000);
httpT.debug = true;
httpT.call(SOAP_ACTION, envelope);
KvmSerializable ks = (KvmSerializable)envelope.bodyIn;
articleid = ks.getProperty(0).toString();
ticketid = ks.getProperty(1).toString();
ticketnumber = ks.getProperty(2).toString();
Log.e("dump Request: " ,httpT.requestDump);
Log.e("dump response: " ,httpT.responseDump);
Log.e("object response : ", ks.toString());
}
else{
HttpTransportSE httpT = new HttpTransportSE(URL);
httpT.debug = true;
httpT.call(SOAP_ACTION, envelope);
KvmSerializable ks = (KvmSerializable)envelope.bodyIn;
articleid = ks.getProperty(0).toString();
ticketid = ks.getProperty(1).toString();
ticketnumber = ks.getProperty(2).toString();
Log.e("dump Request: " ,httpT.requestDump);
Log.e("dump response: " ,httpT.responseDump);
Log.e("object response : ", ks.toString());
}
}
catch(Exception e)
{
e.printStackTrace();
}
handler.post(createUI);
}
};
thread.start();
}
final Runnable createUI = new Runnable() {
public void run(){
responseT.setText("Your ticket id =" + ticketid+ " Article id ="+ articleid+" TICKET NUMBER ="+ ticketnumber);
}
};
protected String checkSSL(String url){
String https = url.substring(0, 4);
if(https == "https"){
return "SSL";
}
else{
return "noSSL";
}
}
}
EDIT: When I rotate the the screen, it requested another ticket from the server and it actually works. I am so confused.