diff --git a/AndroidJavaClient/app/build.gradle b/AndroidJavaClient/app/build.gradle index cc5f3f8..bf4ff0d 100644 --- a/AndroidJavaClient/app/build.gradle +++ b/AndroidJavaClient/app/build.gradle @@ -4,7 +4,7 @@ android { compileSdkVersion 28 defaultConfig { applicationId "com.microsoft.aspnet.signalr.samples.androidjavaclient" - minSdkVersion 24 + minSdkVersion 26 targetSdkVersion 28 versionCode 1 versionName "1.0" @@ -29,5 +29,6 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' - implementation 'com.microsoft.aspnet:signalr:0.1.0-preview1-35029' + implementation group: 'com.microsoft.signalr', name: 'signalr', version: '1.0.0-preview3-35501' + implementation group: 'org.slf4j', name: 'slf4j-android', version: '1.7.7' } diff --git a/AndroidJavaClient/app/src/main/java/com/microsoft/aspnet/signalr/samples/androidjavaclient/MainActivity.java b/AndroidJavaClient/app/src/main/java/com/microsoft/aspnet/signalr/samples/androidjavaclient/MainActivity.java index f15e138..f5daba5 100644 --- a/AndroidJavaClient/app/src/main/java/com/microsoft/aspnet/signalr/samples/androidjavaclient/MainActivity.java +++ b/AndroidJavaClient/app/src/main/java/com/microsoft/aspnet/signalr/samples/androidjavaclient/MainActivity.java @@ -1,6 +1,7 @@ package com.microsoft.aspnet.signalr.samples.androidjavaclient; +import android.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; @@ -10,10 +11,8 @@ import android.widget.ListView; import android.widget.TextView; -import com.microsoft.aspnet.signalr.Action; -import com.microsoft.aspnet.signalr.HubConnection; -import com.microsoft.aspnet.signalr.HubConnectionBuilder; -import com.microsoft.aspnet.signalr.LogLevel; +import com.microsoft.signalr.HubConnection; +import com.microsoft.signalr.HubConnectionBuilder; import java.util.ArrayList; import java.util.List; @@ -24,7 +23,7 @@ public class MainActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - HubConnection hubConnection = new HubConnection("Your URL Here"); + HubConnection hubConnection = HubConnectionBuilder.create("YOUR URL HERE").build(); TextView textView = (TextView)findViewById(R.id.tvMain); ListView listView = (ListView)findViewById(R.id.lvMessages); Button sendButton = (Button)findViewById(R.id.bSend); @@ -58,11 +57,21 @@ public void onClick(View view) { } }); - try { - hubConnection.start(); - } catch (Exception e) { - e.printStackTrace(); - textView.setText("There was an error: " + e.getMessage()); + new HubConnectionTask().execute(hubConnection); + } + + class HubConnectionTask extends AsyncTask{ + + @Override + protected void onPreExecute() { + super.onPreExecute(); + } + + @Override + protected Void doInBackground(HubConnection... hubConnections) { + HubConnection hubConnection = hubConnections[0]; + hubConnection.start().blockingAwait(); + return null; } } -} +} \ No newline at end of file