2012-09-25 63 views
0

我開發了一個Listview應用程序使用肥皂WebServiceMySQL database.Now一個訂單插入我的數據庫意味着這個(新訂單插入)通知消息顯示在我的Android設備上。現在我點擊通知消息意味着該應用程序運行的時間,並且當我的MySQL數據庫中插入每個新訂單時,都會自動成功自動顯示Listview。這裏使用了哪些方法????請幫助我。在Android應用程序中推送通知

這是我的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成功displayed.but新訂單插在我的數據庫意味着一次新訂單插入Notification顯示Android設備上的消息。現在我必須點擊通知的meassage手段,它是顯示更新Listview。我能怎麼做????????我必須在這裏使用什麼方法?

+0

刷新你的listView使用... ur listView.getAdapter()。notifyDataSetChanged()...並確認你的resultArr被更改 – sheetal

+0

我希望在Android設備上需要推送通知消息top.how我可以做什麼? ?任何方法是...(例如)c2dm或gcm – user1676640

回答

1

如果您收到在ListView在新數據中的數據,那麼只有我認爲你必須做的事情是

adapter.notifyDataSetChanged(); // adapterArrayAdapter實例。

+0

我希望在android設備上需要推送通知消息top.how我可以做任何方法是...(例如)像c2dm或gcm – user1676640

+0

@ user1676640非常坦率地說,我已經使用了'parse.com' api來處理我的推送通知,它的簡單和真棒..通知自動到達頂部,點擊通知將直接帶您到應用程序,如果你想我可以帶你去一些具體的活動,你提到 –

+0

是的,我確實需要上面的概念only.where我可以學習parse.com.please幫助我 – user1676640

相關問題