Since my version has a minimum of 2.2, so only the source down to change their own, if you think too much can be compiled into a jar reference, I am not very familiar with Java, if this version of the error also please point out, this figure shows the Android 2.2 and 4.0 version.
Chat_hub Code:
<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout xmlns:android=
"http://schemas.android.com/apk/" Res/android "
android:layout_width=" match_parent "
android:layout_height=" match_parent "
android:o" rientation= "vertical" >
<edittext
android:id= "@+id/chat_text" android:layout_width= "Match_"
Parent "
android:layout_height=" match_parent "
android:layout_margin=" 20DP "
android:gravity=" Top "
android:inputtype= "Textmultiline"
android:text= ""/>
</LinearLayout>
Chathub.java Code:
Package com.loan.zhironghuimobile;
Import Org.json.JSONArray;
Import com.zsoft.SignalA.Hubs.HubConnection;
Import Com.zsoft.SignalA.Hubs.HubOnDataCallback;
Import Com.zsoft.SignalA.Hubs.IHubProxy;
Import Com.zsoft.SignalA.Transport.StateBase;
Import Com.zsoft.SignalA.Transport.Longpolling.LongPollingTransport;
Import android.app.Activity;
Import android.content.OperationApplicationException;
Import Android.os.Bundle;
Import Android.widget.EditText;
public class Chathub extends activity {Private final static String hub_url= "Http://192.168.1.200:82/signalr/hubs"; @Override protected void OnCreate (Bundle savedinstancestate) {//TODO auto-generated method stub super.o
Ncreate (savedinstancestate);
Setcontentview (R.layout.chat_hub);
BeginConnect ();
/** * HUB link/private hubconnection conn=new hubconnection (Hub_url, this, New Longpollingtransport ()) {
@Override public void OnError (Exception Exception) {} @Override public void OnMessage (String message) {} @Override the public void onstatechanged (statebase
Oldstate, Statebase newstate) {}};
/** * Hub Agent Panderman 2013-10-25 * * Private ihubproxy hub = null; /** * Open Push service Panderman 2013-10-25/private void BeginConnect () {try {hub=conn.
Createhubproxy ("Chathub");
catch (Operationapplicationexception e) {e.printstacktrace (); } hub.
On (' Addnewmessagetopage ', new Hubondatacallback () {@Override public void onreceived (Jsonarray args) {
EditText chattext= (EditText) Findviewbyid (R.id.chat_text);
Chattext.settext (Args.tostring ());
for (int i=0; i<args.length (); i++) {Chattext.append (args.opt (i). toString ());
}
}
}); Conn.
Start ();
}
}
SIGNALR server-side code reference HTTP://WWW.ASP.NET/SIGNALR to write
More usage Reference Signala official documents