[英]push notification in android app
我已經使用MySQL
數據庫的soap WebService
開發了一個Listview
應用程序。現在在我的數據庫中插入一個訂單意味着在我的android設備上顯示此消息(插入新訂單)的時間。現在我單擊通知消息意味着該時間當我的MySQL
數據庫中插入每個新訂單時,該應用會運行並自動成功顯示Listview
。這里有什么方法?請幫幫我。
這是我的RetailerActivity.java
代碼:
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();
}
}
}
請在這里成功顯示Listview
但是新訂單已插入到我的數據庫中,這意味着插入新訂單的時間是在Android設備上顯示Notification
消息。現在我必須單擊通知的消息意味着它正在顯示更新Listview
如何我做???????? 我必須在這里使用什么方法????
如果您要在ListView的新數據中獲取數據,那么我認為您要做的就是
adapter.notifyDataSetChanged();
// adapter
是ArrayAdapter
的實例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.