Skip to content

Instantly share code, notes, and snippets.

@mr-wind
mr-wind / CustomXMLRequest
Last active April 27, 2016 08:14
Volley的一些应用
//配置同上
//第一步,仿照官方Volley框架,自己写一个类
public class XMLRequest extends Request<XmlPullParser> {
private final Response.Listener<XmlPullParser> mListener;
public XMLRequest(int method, String url, Response.Listener<XmlPullParser> listener,
Response.ErrorListener errorListener) {
super(method, url, errorListener);
mListener = listener;
String title = null;
try {
title = new String(i.getTitle().getBytes("ISO-8859-1"), "UTF-8");//转码
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
@mr-wind
mr-wind / SharedPreferencesDemo
Created June 13, 2016 03:08
Saved in SharedPreferences
public class Calc extends Activity {
public static final String PREFS_NAME = "MyPrefsFile";
@Override
protected void onCreate(Bundle state){
super.onCreate(state);
. . .
// Restore preferences
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
//在对应的module添加下面的代码
task makeJar(type: Copy) {
delete 'build/libs/mysdk.jar'
from('build/intermediates/bundles/release/')
into('build/libs/')
include('classes.jar')
rename ('classes.jar', 'mysdk.jar')
}
makeJar.dependsOn(build)
@mr-wind
mr-wind / num_keyboard_nine.xml
Created September 14, 2017 03:18
自定义键盘xml布局
<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:horizontalGap="0dp"
android:keyHeight="70dp"
android:keyWidth="100dp"
android:verticalGap="0dp">
<Row>
<Key android:codes="55" android:keyEdgeFlags="left" android:keyLabel="7"/>
<Key android:codes="56" android:keyLabel="8"/>
<Key android:codes="57" android:keyLabel="9"/>
@mr-wind
mr-wind / CustomKeyboard.java
Created September 14, 2017 03:21
自定义键盘组装类
import android.app.Activity;
import android.content.Context;
import android.graphics.PixelFormat;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView;
import android.text.Editable;
import android.text.InputType;
import android.view.ActionMode;
import android.view.Gravity;
import android.view.Menu;
@mr-wind
mr-wind / SpeakerUtil.java
Created September 18, 2017 10:08
文字转语音工具类(需要有tts引擎)
import android.content.Context;
import android.content.Intent;
import android.media.AudioAttributes;
import android.media.MediaPlayer;
import android.speech.tts.TextToSpeech;
import android.speech.tts.UtteranceProgressListener;
import android.text.TextUtils;
import android.util.Log;
import com.gojiejiao.like.pos.Constants;
@mr-wind
mr-wind / build.gradle
Created September 19, 2017 09:03
较完整的一份gradle配置
apply plugin: 'com.android.application'
//加载本地签名
def keystorePropertiesFile = rootProject.file("local.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
signingConfigs {
ExampleSign {
@mr-wind
mr-wind / NetworkUtil.java
Created September 21, 2017 08:32
查Ip地址和mac地址的方法
/**
* 获取手机的Mac地址,在Wifi未开启或者未连接的情况下也能获取手机Mac地址
*/
public static String getMacAddress(Context context) {
String macAddress = null;
WifiInfo wifiInfo = getWifiInfo(context);
if (wifiInfo != null) {
macAddress = wifiInfo.getMacAddress();
}
return macAddress;