Reputation: 635
i have developed one Listview
app using soap WebService
from MySQL
database.Now one order is inserted on my database means that time this (new order is inserted) notify message is display on my android device.now i click the notification message means that time the app is run and display Listview
successfully automatically when each and every new order is insert on my MySQL
database.what methods am use here????please help me.
This is my RetailerActivity.java
code:
public class RetailerActivity extends Activity {
ListView list;
private static final String SOAP_ACTION = "http://xcart.com/customerData1";
private static final String METHOD_NAME = "customerData1";
private static final String NAMESPACE = "http://xcart.com";
private static final String URL = "http://192.168.1.168:8089/XcartLogin/services/RetailerWs?wsdl";
private static final String KEY_STATUS = "status";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE ht = new HttpTransportSE(URL);
try {
ht.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
SoapPrimitive s = response;
String str = s.toString();
String resultArr[] = str.split("&");
list=(ListView)findViewById(R.id.list);
list.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1,resultArr));
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String status = parent.getItemAtPosition(position).toString();
String[] status1 = status.split(" ");
String StrStatus = status1[1].toString();
Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
in.putExtra(KEY_STATUS, StrStatus);
startActivity(in);
}
});
}
catch (Exception e) {
e.printStackTrace();
}
}
}
please here the Listview
is successfully displayed.but the new order is inserted on my database means that time the new order is inserted Notification
message is displayed on android device.now i have to click the notified meassage means it is display update Listview
.how can i do???????? what methods i have to use here????
Upvotes: 0
Views: 645
Reputation: 33544
If you are getting the data in the new data in the ListView, then only thing that i think you will have to do is
adapter.notifyDataSetChanged();
// adapter
is the instance of ArrayAdapter
.
Upvotes: 1