看了下源码的wifi jni部分的实现http://www.netmite.com/android/mydroid/donut/ frameworks /base/core/jni/android_net_wifi_wifi.cpp
然后在ubuntu下测试,
#include "wifi.h"
#include
#include
这3个头文件编译时报错,说找不到
以下是我jni的实现:
#include "com_test_myjni_myjni.h"
#include
#include
#include
#include
#include
#include
#include "wifi.h"
#include
#include
static int docommand(const char *cmd, char *replybuf, int replybuflen)
{
size_t reply_len = replybuflen - 1;
if (wifi_command(cmd, replybuf, &reply_len) != 0)
return -1;
else {
// strip off trailing newline
if (reply_len > 0 && replybuf[reply_len-1] == '/n')
replybuf[reply_len-1] = '/0';
else
replybuf[reply_len] = '/0';
return 0;
}
}
/* * class : com_test_myjni_myjni * method: testinit * signature: ()i */
jniexport jint jnicall java_com_test_myjni_myjni_testinit (jnienv *env, jclass object){ int rt = 100; return rt;}
/* * class: com_test_myjni_myjni * method: getmacaddress * signature: ()ljava/lang/string; */
jniexport jstring jnicall java_com_test_myjni_myjni_getmacaddress (jnienv *env, jclass object)
{
char reply[256]; char buf[256];
if (docommand("driver macaddr", reply, sizeof(reply)) != 0)
{
return (*env)->newstringutf(env, null);
}
// reply comes back in the form "macaddr = xx.xx.xx.xx.xx.xx" where xx // is the part of the string we're interested in.
if (sscanf(reply, "%*s = %255s", buf) == 1)
return (*env)->newstringutf(env, buf);
else return (*env)->newstringutf(env, null);
}
本文转载至: http://www.eoeandroid.com/thread-58810-1-1.html
推荐文章:
不知道主界面怎么变成这样的了,怎么恢复到原始状态?
android应用kindle阅读器最受欢迎
共享一些常用控件的用法!
android高手进阶教程(八)之----android widget开发案例(世界杯倒计时 ...
在android命令行启动程序的方法
android骨灰级文档,绝对值得信赖
android开发人员手册(jerome dimarzio )之阅读androidsdk
ramos蓝魔将于9月25号新品音悦汇上发布android mid
android 核心分析 之廿一------android应用框架之androidapplication
手机遭遇“千重门” 你的手机隐私安全吗
droid wall 手机防火墙【源代码】
今天发现android源码的fakecamera.cpp有一个bug,已解决
背景图片重复利用
进行android底层及应用开发需要那些库,这样写行不行
使用ndk编译.so文件心得
android开发
android编程
android教程
android资料下载
android sdk
android源代码
android教学
android入门
android开发视频
android系统
android开发论坛
棒槌网@Android相关文章推荐:
jni获取mac地址的问题
Android获取本机Mac地址及IP地址方法
Android的三个相关概念JNI,Eclipse,QEMU
Android 3D与JNI结合的小例子
Android中使用jni,ndk的C语言回调方法
Android平台从Froyo 2.2开始支持jni单步调试了! - Jinhill's Blog ...
有人在Mac OS X 10.6 Snow Leopard下Compiling Android Source成功的么
请教关于获取位置的问题
jni获取mac地址的问题  -  棒槌网@Android开发论坛 - Powered by phpwind
最新推荐文章于 2020-08-05 13:36:38 发布