在Android应用中推送通知

时间:2012-09-25 09:12:19

标签: java android push-notification

我使用来自Listview数据库的soap WebService开发了一个MySQL应用。现在我的数据库中插入了一个订单意味着此时间(插入新订单)通知消息显示在我的Android设备上。如果我点击通知消息意味着应用程序运行的时间并在我的Listview数据库中插入每个新订单时自动成功显示MySQL。我在这里使用的方法是什么?请帮帮我。

这是我的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成功显示。但新订单插入我的数据库意味着插入新订单的时间Notification消息显示在Android设备上。现在我必须点击通知meassage意味着它是显示更新Listview。我该怎么办????????我必须在这里使用什么方法????

1 个答案:

答案 0 :(得分:1)

如果您在ListView中获取新数据中的数据,那么我认为您必须做的只是

adapter.notifyDataSetChanged(); // adapterArrayAdapter的实例。