欢迎来到一句话经典语录网
我要投稿 投诉建议
当前位置:一句话经典语录 > 口号 > 安卓串口号获取

安卓串口号获取

时间:2014-12-21 00:22

串口怎么获取android event

代码如下:import com.friendlyarm.AndroidSDK.HardwareControler;import android.app.Activity;import android.os.Bundle;import android.os.Handler;import android.os.Looper;import android.os.Message;public class MapGuider_Activity extends Activity{ private int serial_fd=0; private byte[] serial_RevBuf=new byte[100]; private byte[] serial_SendBuf=fsjajd.getBytes(); @Override protected void onCreate(Bundle savedInstanceState) { \\\/\\\/ TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.mapguider); serial_fd=HardwareControler.openSerialPort(\\\/dev\\\/s3c2410_serial1, 115200, 8, 1); if(serial_fd!=-1) { System.out.println(打开串口成功); HardwareControler.write(serial_fd, serial_SendBuf); lac_handler.post(RevicePosDataThread); } else { System.out.println(指定的串口不存在或在其它进程中已被打开); } } @Override protected void onDestroy() { \\\/\\\/ TODO Auto-generated method stub HardwareControler.close(serial_fd); System.out.println(关闭串口); lac_handler.removeCallbacks(RevicePosDataThread); super.onDestroy(); } Handler lac_handler =new Handler(){ @Override public void handleMessage(Message msg) { \\\/\\\/ TODO Auto-generated method stub super.handleMessage(msg); } }; Runnable RevicePosDataThread =new Runnable() { int err=0; String s; public void run() { \\\/\\\/ TODO Auto-generated method stub while(true) { \\\/\\\/Looper.prepare(); err=HardwareControler.select(serial_fd, 1, 0); if(err==1)\\\/\\\/有数据可读 { HardwareControler.read(serial_fd, serial_RevBuf, 10); s=new String(serial_RevBuf); System.out.println(接收到串口数据+s); } else if(err==0) \\\/\\\/无数据可读 { System.out.println(没有接收到串口数据); } else \\\/\\\/出错 { System.out.println(接收到串口数据出错); } try { Thread.sleep(2); } catch (InterruptedException e) { \\\/\\\/ TODO Auto-generated catch block e.printStackTrace(); } } } };}

怎么查看android 设备的串口

1. 如果是linux,不需要单独安装什么串口驱动2. 但需要使用ls \\\/dev\\\/tty * 查看usb 串口设备是否被检测到2. 然后使用linux下的MINICOM进行串口信息打印,具体配置和用法可以baidu一下

android串口读取数据

代码片段上传一下 private static final UUID MY_UUID = UUID.fromString(00001101-0000-1000-8000-00805F9B34FB);BluetoothServerSocket bss = BluetoothAdapter.getDefaultAdapter() .listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID);就可以对SOCKET进行读写操作了

android串口通信

你使用谷歌提供的串口通信包还是自己写的通信接口

如何使用android studio实现串口通信

为了帮助网友解决“Android studio使用http”相关的问题,中国学网通过互联网对“Android studio使用http”相关的解决方案进行了整理,用户详细问题包括:androidandroid?studiohttp协议 本人新手,在使用android Studio编写网站展示的应用程序中,使用HttpClient httpClient = new DefaultHttpClient();获取客服端时,编译器显示没有HttpClient这个类。

网上查资料,换成CloseableHttpClient httpclient = HttpClients.createDefault();也同样没有类CloseableHttpClient 这个类。

上面两个类都是被deprecated了。

请问android Studio 1.2.1.1这个版本,实现http协议GET数据的接口是哪个

在哪个包

,具体解决方案如下:解决方案1:HttpURLConnectionconn.setRequestMethod(GET);包的话应该是:import java.net.HttpURLConnection; sdk带了解决方案2:引用 1 楼 inquisitive_plus 的回复:HttpURLConnectionconn.setRequestMethod(GET);包的话应该是:import java.net.HttpURLConnection; sdk带了你好

这个是使用URLConnection方式实现Android的网络通信。

难道android Studio 1.2.1.1这个工具不支持使用HTTPClient方式来实现android的网络通信

解决方案3:HttpClient httpclient = new DefaultHttpClient();HttpGet httpget = new HttpGet();HttpResponse response = httpclient.execute(httpget);HttpEntity entity = response.getEntity();if (entity != null) {InputStream instream = entity.getContent();int l;byte[] tmp = new byte[2048];while ((l = instream.read(tmp)) != -1) {}}解决方案4:引用 3 楼 stublue 的回复:HttpClient httpclient = new DefaultHttpClient();HttpGet httpget = new HttpGet();HttpResponse response = httpclient.execute(httpget);HttpEntity entity = response.getEntity();if (entity != null) {InputStream instream = entity.getContent();int l;byte[] tmp = new byte[2048];while ((l = instream.read(tmp)) != -1) {}}你好

你用的开发环境应该是Eclipse吧

我用的工具是android Studio 1.2.1.1,上面提示'org.apache.http.impl.client.DefaultHttpClient' is deprecated。

不能使用

我不想换开发环境

难道android Studio 1.2.1.1这个工具不支持使用HTTPClient方式来实现android的网络通信

解决方案5:引用 2 楼 iloyou19 的回复:Quote: 引用 1 楼 inquisitive_plus 的回复:HttpURLConnectionconn.setRequestMethod(GET);包的话应该是:import java.net.HttpURLConnection; sdk带了你好

这个是使用URLConnection方式实现Android的网络通信。

难道android Studio 1.2.1.1这个工具不支持使用HTTPClient方式来实现android的网络通信

1.2.1.1支持的,我就是这个版本64位在Android studio\\\/lib里你可以找到HttpClient-XXX.jar你需要的java常规jar包在lib里都能找到解决方案6:引用 4 楼 iloyou19 的回复:Quote: 引用 3 楼 stublue 的回复:HttpClient httpclient = new DefaultHttpClient();HttpGet httpget = new HttpGet();HttpResponse response = httpclient.execute(httpget);HttpEntity entity = response.getEntity();if (entity != null) {InputStream instream = entity.getContent();int l;byte[] tmp = new byte[2048];while ((l = instream.read(tmp)) != -1) {}}你好

你用的开发环境应该是Eclipse吧

我用的工具是android Studio 1.2.1.1,上面提示'org.apache.http.impl.client.DefaultHttpClient' is deprecated。

不能使用

我不想换开发环境

难道android Studio 1.2.1.1这个工具不支持使用HTTPClient方式来实现android的网络通信

我的就是在Android studio中啊

版本是1.2.2要想不提示deprecated,在类上加个注解 @SuppressWarnings(deprecation)解决方案7:你没有导入包吧解决方案8:引用 6 楼 stublue 的回复:Quote: 引用 4 楼 iloyou19 的回复:Quote: 引用 3 楼 stublue 的回复:HttpClient httpclient = new DefaultHttpClient();HttpGet httpget = new HttpGet();HttpResponse response = httpclient.execute(httpget);HttpEntity entity = response.getEntity();if (entity != null) {InputStream instream = entity.getContent();int l;byte[] tmp = new byte[2048];while ((l = instream.read(tmp)) != -1) {}}你好

你用的开发环境应该是Eclipse吧

我用的工具是android Studio 1.2.1.1,上面提示'org.apache.http.impl.client.DefaultHttpClient' is deprecated。

不能使用

我不想换开发环境

难道android Studio 1.2.1.1这个工具不支持使用HTTPClient方式来实现android的网络通信

我的就是在Android studio中啊

版本是1.2.2要想不提示deprecated,在类上加个注解 @SuppressWarnings(deprecation)你好

这个注解我不知道怎么用

麻烦能给我一个完整的工程吗

谢谢

解决方案9:导的包对

import org.apache.http.HttpEntity;import org.apache.http.HttpResponse;import org.apache.http.client.ClientProtocolException;import org.apache.http.client.HttpClient;import org.apache.http.client.methods.HttpGet;import org.apache.http.conn.ConnectTimeoutException;import org.apache.http.impl.client.DefaultHttpClient;import org.apache.http.params.CoreConnectionPNames;import org.apache.http.util.EntityUtils;解决方案10:引用 5 楼 inquisitive_plus 的回复:Quote: 引用 2 楼 iloyou19 的回复:Quote: 引用 1 楼 inquisitive_plus 的回复:HttpURLConnectionconn.setRequestMethod(GET);包的话应该是:import java.net.HttpURLConnection; sdk带了你好

这个是使用URLConnection方式实现Android的网络通信。

难道android Studio 1.2.1.1这个工具不支持使用HTTPClient方式来实现android的网络通信

1.2.1.1支持的,我就是这个版本64位在Android studio\\\/lib里你可以找到HttpClient-XXX.jar你需要的java常规jar包在lib里都能找到我的androidstudio\\\/lib里面也有httpclient-4.3.6.jsr,可是就是解析不出来这个import org.apache.http.NameValuePair这里显示红色我在另一台机的1.0版本的Androidstudio就能解析出来这个好像不用另外配置引入jar的吧解决方案11:用volley吧,大文件下载不适用!!!参考:解决方案12:我现在也遇到了这个问题,楼主你解决了没有呀

解决方案13:HttpClient是SDK自带的啊 为什么会没有解决方案14:API9之上不再支持httpclient,从官方网站可以查到。

换成HttpURLConnection解决方案15:解决方案16:我也遇到这种问题搞了半天都没弄好,最后还是直接把httpclient这个包直接导到工程去了。

解决方案17:android sdk中就已经包含了这个包(如上图,我截的是sdk22版本),跟android studio版本没有关系。

解决方案18:这个问题现在我没有弄了,感谢大家的回答

有位大神给我私信了

好像能用(我没有试),遇到相同问题的各位试一下吧

silence12s21给你发了私信silence12s21 : httpmime-4.5.jar httpcore-4.4.1.jar httpclient-4.5.jar 同时导入了这三个包后就可以用了。

声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。联系xxxxxxxx.com

Copyright©2020 一句话经典语录 www.yiyyy.com 版权所有

友情链接

心理测试 图片大全 壁纸图片