问题描述
我正在尝试设置两个android设备以通过wifi相互通信。我经过的一些链接建议使用alljoyn sdk来完成此操作。
右键单击项目->打开模块设置->应用程序->依赖关系。
使用绿色的[+]按钮,添加文件依赖关系。
导航到< project> / app / src / main / jniLibs /alljoyn.jar
并选择该jar。
这将在gradle中添加一行(编译文件(' src / main / jniLibs / alljoyn.jar')
),将允许代码完成等。
在您所在的文件中要使用alljoyn代码,请包含此代码段
/ *加载本机alljoyn_java库。 * /
静态{
System.loadLibrary( alljoyn_java);
}
例如:
公共类MainActivity扩展了AppCompatActivity {
/ *加载本机alljoyn_java库。 * /
静态{
System.loadLibrary( alljoyn_java);
}
@Override
public void onCreate(Bundle savedInstanceState){
...
}
}
您现在可以使用alljoyn SDK。
导入类org.alljoyn.bus.BusAttachment;
import org.alljoyn.bus.BusException;
import org.alljoyn.bus.BusListener;
等。
如果您更喜欢日食,请检查官方文档页,介绍如何设置日食环境。
I am trying to setup two android devices to communicate with each other through wifi. Some of the links I have gone through suggest alljoyn sdk in order to accomplish this.
There is an sdk download but there is no documentation for how to setup environment.
Here is how to set up an AllJoyn SDK development environment with android studio:
- Download the SDK from this page. Go for Android Core SDK - release (or debug).
- Create a new blank android project.
- Create directory
<project>/app/src/main/jniLibs
and<project>/app/src/main/jniLibs/armeabi
. - From
alljoyn-15.09.00-rel/java/jar
copy alljoyn.jar and fromalljoyn-15.09.00-rel/java/lib
copy liballjoyn_java.so. The directory to copy from might differ depending on the current version and your release/debug choice. Put alljoyn.jar in
/jniLibs
and put liballjoyn_java.so in/jniLibs/armeabi
. Should look like thisRight click project -> Open Module Settings -> app -> Dependencies.
With the green [+] button, add a file dependency.Navigate to
<project>/app/src/main/jniLibs/alljoyn.jar
and select that jar.This will add a line in your gradle (
compile files('src/main/jniLibs/alljoyn.jar')
) that will allow for code completion etc.In the file where you want to use alljoyn code, include this snippet
/* Load the native alljoyn_java library. */ static { System.loadLibrary("alljoyn_java"); }
for example:
public class MainActivity extends AppCompatActivity { /* Load the native alljoyn_java library. */ static { System.loadLibrary("alljoyn_java"); } @Override public void onCreate(Bundle savedInstanceState) { ... } }
You can now use the alljoyn SDK. Import classes with
import org.alljoyn.bus.BusAttachment; import org.alljoyn.bus.BusException; import org.alljoyn.bus.BusListener;
etc.
If you're more of an eclipse guy, check this official documentation page on how to setup an eclipse environment.
这篇关于如何在Android中设置AllJoyn SDK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!