To Infinity and Beyond

The following code is used to show you how to send and receive messages:

using System;
using Android.App;
using Android.Widget;
using Android.OS;
using xabetooLibrary;

namespace abetooApp.Droid
 [Activity (Label = "abetooApp.Droid", MainLauncher = true, 
 Icon = "@drawable/icon")]
 public class MainActivity : Activity
 protected override void OnCreate (Bundle bundle)
 base.OnCreate (bundle);


 // UI
 Button button = FindViewById<Button>(Resource.Id.sendMessagebutton);
 EditText fromText = FindViewById<EditText>(Resource.Id.frombox);
 EditText corridText = FindViewById<EditText>(Resource.Id.corridbox);
 EditText messageText = FindViewById<EditText>(Resource.Id.messagebox);

 // Abetoo connection
 String myChannel = "-uC6s1LfZaEuw9AK0Js1w9w636243459698606497#"+
 String title = "Abetoo Test";
 String description = "Abetoo test running";
 int heartBeat = 1;

 AbtooConnection abcn = AbtooDroidConnection.getService(this, myChannel, 
 heartBeat, Resource.Drawable.logo_black, title, description);

 // Abetoo Listener
 abcn.messageReceived = ((sender, e) =>
 AbtooMessage message = e;
 RunOnUiThread(() =>
 fromText.Text = message.from;
 corridText.Text = message.correlationid;
 messageText.Text = message.body;

 const String remoteChannel =
 "-TbVO-rqdA0iWg6-gWh0eeQ636243460528994051#" +
 button.Click += ((sender, e) =>
 abcn.sendMessage(remoteChannel, "Message sent from Android!");

 // Launch connection

It’s basically the hello world code, but this time you can see how it works with another Abetoo client (Visual Studio) working in parallel sending messages to the Android channel id.

As you can see in the video above the messages sent from the Visual Studio client are received at the Android phone. The showed phone is a mirror of a real phone, not a virtual one.

Was this article helpful?

Related Articles

Leave A Comment?