1

是否可以在不使用Eclipse而是使用 Visual Studio 和 C#的情况下使用Mono for Android创建应用程序并控制Arduino ?

我检查了一些示例,但每个人都使用 Java 和 Eclipse。

4

1 回答 1

2

简单地说,答案是肯定的,有可能。真正的问题是:如何?我假设你已经用 Mono 编写了你的​​第一个 Android 应用程序

接下来,您需要决定如何将您的 Android 设备连接到 Arduino。蓝牙无线网络?网络?

接下来,只需使用适当的 Android API。查看适用于 Android 的 Xamarin 文档

更新

移植的 MonoDroid 示例应用程序提供的功能远不止我在下面介绍的。具体来说,您会对BluetoothChat 示例感兴趣。

确保您还查看了向清单文件添加权限,当然还有Android Developer Guide for Bluetooth

也就是说,这里有一个小东西可以帮助您入门,基于Android Quick Look:BluetoothAdapter

txtStatus.Text = "Getting Bluetooth adapter...";
BluetoothAdapter bluetooth = BluetoothAdapter.DefaultAdapter;
if( bluetooth == null )
{
    txtStatus.Text = "No Bluetooth adapter found.";
    return;
}

txtStatus.Text = "Checking Bluetooth status...";
if (!bluetooth.IsEnabled )
{
    Toast.MakeText(this, "Bluetooth not enabled. Enabling...", 
        ToastLength.Short).Show();
    bluetooth.Enable();
}

if (bluetooth.State == State.On)
{
    txtStatus.Text = 
        "State: " + bluetooth.State + System.Environment.NewLine +
        "Address: " + bluetooth.Address + System.Environment.NewLine + 
        "Name: " + bluetooth.Name + System.Environment.NewLine; 
} 
else
{
    txtStatus.Text = "State: " + bluetooth.State;
}
于 2013-03-27T10:09:15.547 回答