首页 文章 精选 留言 我的

精选列表

搜索[android things],共10000篇文章
优秀的个人博客,低调大师

Android:Sensor传感器

Sensor传感器:温度、重力、加速度、磁场、近距离等 1 2 3 4 5 6 7 8 // 步骤: // 1) 得到SensorManager // 2) 得到某个传感器对象 // mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION); // 3) 监听传感器 // mSensorManager.registerListener(mListener, mSensor, // SensorManager.SENSOR_DELAY_GAME); // 4) 实现监听器 本文转自 glblong 51CTO博客,原文链接:http://blog.51cto.com/glblong/1228597,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android EditText OnTouchListener事件重复

今天在做数字键盘输入法的时候,监听EditText的OnTouchListener事件,然后弹出输入法,发现事件里面的方法居然执行了两次。 代码如下: Java代码 edit.setOnTouchListener(newOnTouchListener(){ @Override publicbooleanonTouch(Viewv,MotionEventevent){ NumberInputApp.setEdit(edit); Intentintent=newIntent(); intent.setClass(NumberKeyBoardActivity.this,NumberInputActivity.class); startActivity(intent); returnfalse; } }); 经过同事的提示,发现有可能是EditText的事件太过灵敏了,在MotionEvent.ACTION_DOWN和MotionEvent.ACTION_UP各执行了一次,于是把代码改成如下即可: Java代码 edit.setOnTouchListener(newOnTouchListener(){ @Override publicbooleanonTouch(Viewv,MotionEventevent){ /**加这个判断,防止该事件被执行两次*/ if(event.getAction()==MotionEvent.ACTION_DOWN){ NumberInputApp.setEdit(edit); Intentintent=newIntent(); intent.setClass(NumberKeyBoardActivity.this,NumberInputActivity.class); startActivity(intent); } returnfalse; } }); 本文转自06peng 51CTO博客,原文链接:http://blog.51cto.com/06peng/963236,如需转载请自行联系原作者

优秀的个人博客,低调大师

android网络编程——http post

前一篇给出了HttpGet的实例,这一篇给出HttpPost的实例。 public class HttpPostDemo extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); BufferedReader in = null; try { HttpClient client = new DefaultHttpClient(); HttpPost request = new HttpPost("http://mysomewebsite.com/services/doSomething.do"); List<NameValuePair> postParameters = new ArrayList<NameValuePair>(); postParameters.add(new BasicNameValuePair("username", "test")); postParameters.add(new BasicNameValuePair("password", "test1234")); UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity( postParameters); request.setEntity(formEntity); HttpResponse response = client.execute(request); in = new BufferedReader( new InputStreamReader( response.getEntity().getContent())); StringBuffer sb = new StringBuffer(""); String line = ""; String NL = System.getProperty("line.separator"); while ((line = in.readLine()) != null) { sb.append(line + NL); } in.close(); String result = sb.toString(); System.out.println(result); } catch(Exception e) { // Do something about exceptions } finally { if (in != null) { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } } } } 本文转自xyz_lmn51CTO博客,原文链接:http://blog.51cto.com/xyzlmn/1230791,如需转载请自行联系原作者

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

用户登录
用户注册