android开发:传感器的实例light,proximity,accelerometer,SensorManager,Sensor(含步数计算原理)

package com.lanxin.testsensor;

import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

android开发:手势开发实例GestureOverlayView,GestureLibrary

private void init() {
mContext = this;
filename = Environment.getExternalStorageDirectory()+”/lanxin/gesture/gesture_1468729525348″;
Log.d(TAG,filename);

mGesture = GestureLibraries.fromFile(filename);

if (!mGesture.load()) {
Toast.makeText(this, “Could not load ” + filename, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(this,addAcitvity.class);
startActivity(intent);
finish();
}

Log.v(TAG, “>>>>>>>mGesture>>>>>>>>>:”);
Log.v(TAG, ” 方向样式: ” + mGesture.getOrientationStyle());
Log.v(TAG, ” 顺序类型: ” + mGesture.getSequenceType());

android开发:触摸屏触摸事件MotionEvent演示实例

mScaleGesture = new ScaleGestureDetector(this, new ScaleGestureDetector.OnScaleGestureListener() {
@Override
public boolean onScale(ScaleGestureDetector detector) {

mScaleFloat *= detector.getScaleFactor();

String str = “”;

str = “比例:”+detector.getScaleFactor()+” mScaleFloat:”+mScaleFloat+”\n”;

mScaleFloat = Math.max(0.1f,Math.min(mScaleFloat,5.0f));//图像比例,最小0.1,最大5

str += ” mScaleFloat:”+mScaleFloat;
text2.setText(str);

matrix.setScale(mScaleFloat, mScaleFloat);
img.setImageMatrix(matrix);
img.invalidate();

return true;//这里一定要返回真,否则不会继续监听事件
}

android invalid drawable tag vector解决办法

当android报这个错误:

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID

Android invalid drawable tag vector

 

一直都没找到什么好的解决方法,最后是修改appcompat-v7依赖包

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    //compile 'com.android.support:appcompat-v7:24.0.1-beta1'
    //noinspection GradleCompatible
    compile 'com.android.support:appcompat-v7:23.0.1'
}

从24.0.1改成23.0.1问题解决了.

dependencies {
 compile fileTree(include: ['*.jar'], dir: 'libs')
 testCompile 'junit:junit:4.12'
 compile 'com.android.support:appcompat-v7:23.2.1'
 compile 'com.android.support:design:23.2.1'
}

android开发:使用HttpURLConnection读取验证码,并且发送请求进行验证的方法

imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new Thread(new Runnable() {
@Override
public void run() {
try {
URL url = new URL(“http://192.168.1.205/verify.php?rand=29569″);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();//建立链接

InputStream in = conn.getInputStream();//读取图片先

bitmap = BitmapFactory.decodeStream(in);//解码图片
handler.sendEmptyMessage(1);//发送消息,把图片显示出去

 
Copyright © 2008-2021 lanxinbase.com Rights Reserved. | 粤ICP备14086738号-3 |