e品通讯模板:资料设置,修改头像失败
话时代:语音验证 混淆问题
eclipse 布局不显示:api过低,不支持显示editView
eclipse 导入第三方包报classnotfind 打开build path ,把导入的第三方包打钩就可以了
Error generating final archive: Found duplicate file fogr APK: classes.dex
hashmap的key获取方法
invalidate 重新绘制调用者
String.substring:定义一个String类型的变量去存储number截取第i个位置到第i+1个位置的字符串
java 转大小写toLowerCase
scrollview嵌套listview
//自定义listview,修改了长度测量方式,解决scrollview嵌套listview只显示一个item问题
import android.content.Context;
import android.util.AttributeSet;
import android.view.View.MeasureSpec;
import android.widget.ListView;
public class MyListView extends ListView {
public MyListView(Context context) {
super(context);
}
public MyListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
listview item点击事件失效 http://www.cnblogs.com/dj168/p/3950890.html
调用系统发送短信:
Uri smsToUri = Uri.parse("smsto:10000");
Intent intent = new Intent(Intent.ACTION_SENDTO, smsToUri);
intent.putExtra("sms_body", smsBody);
startActivity(intent);
调用系统新增联系人
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType("vnd.android.cursor.dir/person");
intent.setType("vnd.android.cursor.dir/contact");
intent.setType("vnd.android.cursor.dir/raw_contact");
mContext.startActivity(intent);
除了报错,还有可能是报异常
如果没有达到如期效果,要找报错信息,或者异常信息
测量控件的高度
int w = View.MeasureSpec.makeMeasureSpec(0,
View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0,
View.MeasureSpec.UNSPECIFIED);
mNumBarAndKeyboardLl.measure(w, h);
int height = mNumBarAndKeyboardLl.getMeasuredHeight();
int width = mNumBarAndKeyboardLl.getMeasuredWidth();s
glide使用
Glide
.with(this)
.load("http://inthecheesefactory.com/uploads/source/nestedfragment/fragments.png")
.placeholder(R.mipmap.ic_launcher) // 也可以是一个drawable,加载时的图片
.error(R.mipmap.future_studio_launcher)//错误时的图片
.into(imageView);
时间日期的转换
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");// 小写的mm表示的是分钟
// 有效期的期限
Date endDate = sdf.parse(valid_time);
Calendar calendar = Calendar.getInstance();
calendar.setTime(endDate);
calendar.add(Calendar.YEAR, -1);
// 有限期往前1年
Date startDate = calendar.getTime();
SimpleDateFormat sf = new SimpleDateFormat("yyyy年MM月dd日");
String endTime = sf.format(endDate);
String startTime = sf.format(startDate);
按键音 ToneGenerator
倒计时
// 倒计时
private void startCountDownTime(final long time) {
timer = new CountDownTimer((time + 2) * 1000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
if (mDataList != null) {
Intent splashAd = new Intent(SplashActivity.this,
SplashAdActivity.class);
splashAd.putStringArrayListExtra("list", mDataList);
startActivity(splashAd);
} else {
if ("".equals(mPhoneNum) && "".equals(mPwd)) {
Intent login = new Intent(SplashActivity.this,
LoginActivity.class);
startActivity(login);
} else {
Intent dialer = new Intent(SplashActivity.this,
DialerActivity.class);
startActivity(dialer);
}
}
finish();
}
};
timer.start();// 开始计时
// timer.cancel(); // 取消
}
固定竖屏
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
拼音工具类辨识不了乱码的字
小米6 获取通讯录号码有间隔
// 按返回键不退出应用
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
Intent i = new Intent(Intent.ACTION_MAIN);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addCategory(Intent.CATEGORY_HOME);
startActivity(i);
return true;
}
return super.onKeyDown(keyCode, event);
}
webView
private class WebChromeClientImpl extends WebChromeClient {
private String mTitle;
private WebChromeClientImpl() {
}
// 获取网址的标题
@Override
public void onReceivedTitle(WebView view, String title) {
mTitle = title;
super.onReceivedTitle(view, title);
}
// 判断加载情况
public void onProgressChanged(WebView paramWebView, int paramInt) {
if ((paramInt == 0) || (paramInt == 100)) {
mTvTitel.setText(mTitle);
} else {
mTvTitel.setText("加载中···");
}
super.onProgressChanged(paramWebView, paramInt);
}
}
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.v("simon", "url:" + url);
if (url != null && url.contains("tel:")) {
Intent dialIntent = new Intent(Intent.ACTION_CALL, Uri
.parse(url));
startActivity(dialIntent);
return true;
}
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public void onPageFinished(WebView view, String url) {
String title = view.getTitle();
if (title == null) {
title = "";
}
mTvTitel.setText(title);
super.onPageFinished(view, url);
}
});
svn
出现报错,报错有冲突,但是查看了文件没有发现冲突,可以先把文件删除,然后再恢复,就可以解决问题
点击空白时隐藏键盘
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN
&& getCurrentFocus() != null
&& getCurrentFocus().getWindowToken() != null) {
View v = getCurrentFocus();
if (isShouldHideKeyboard(v, event)) {
hideKeyboard(v.getWindowToken());
}
}
return super.dispatchTouchEvent(event);
}
/**
* 根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘,因为当用户点击EditText时则不能隐藏
*/
private boolean isShouldHideKeyboard(View v, MotionEvent event) {
if (v != null && (v instanceof EditText)) {
int[] l = { 0, 0 };
v.getLocationOnScreen(l);
int left = l[0], top = l[1], bottom = top + v.getHeight(), right = left
+ v.getWidth();
if (event.getRawX() > left && event.getRawX() < right
&& event.getRawY() > top && event.getRawY() < bottom) {
// 点击EditText的事件,忽略它。
return false;
} else {
return true;
}
}
// 如果焦点不是EditText则忽略,这个发生在视图刚绘制完,第一个焦点不在EditText上,和用户用轨迹球选择其他的焦点
return false;
}
/**
* 获取InputMethodManager,隐藏软键盘
*/
private void hideKeyboard(IBinder token) {
if (token != null) {
InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
mInputMethodManager.hideSoftInputFromWindow(token,
InputMethodManager.HIDE_NOT_ALWAYS);
}
}
EventBus
发送消息
EventBus.getDefault().post(new MessageBean("DialActivity", 0));
注册
EventBus.getDefault().register(this);
接收消息
@Subscribe(threadMode = ThreadMode.MAIN)
public void messageEventBus(MessageBean event) {
}
反注册
EventBus.getDefault().unregister(this);
多线程进行不要只能更新数据,不要同时更新ui,会没有效果
requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉标题栏
今天突然发现一个bug,自己的EditText在删除内容时,总会触发Activity的返回事件,可是昨天明明是好好的。于是调试一番才突然醒悟:原来是我今天重写了onKeyDown监听,但是忘记过滤KeyCode了,如此简单……
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
//返回事件
}
}
软键盘的删除键,会触发onKeyDown事件监听,这里的keyCode == KeyEvent.KEYCODE_DEL,如果不过滤,当然出错。
eventbus 执行了两次
webview适应屏幕
myWebView.getSettings().setUseWideViewPort(true);
myWebView.getSettings().setLoadWithOverviewMode(true);
更新显示
androidMenifest里的verisionname代表更新时的版本状态
监听电话状态
// phoneServiceName是服务名,一般是 "phone" -->
// Context.TELEPHONY_SERVICE
TelephonyManager telephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
telephony.listen(new OnePhoneStateListener(),
PhoneStateListener.LISTEN_CALL_STATE);
// /**
// * 电话状态监听.
// *
// * @author stephen
// *
// */
class OnePhoneStateListener extends PhoneStateListener {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
finish();
break;
case TelephonyManager.CALL_STATE_IDLE:
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
finish();
break;
}
super.onCallStateChanged(state, incomingNumber);
}
}
三星插入通话记录(必须写全,其他品牌可以不用写全)
ContentValues _ContentValues = new ContentValues();
_ContentValues.put(CallLog.Calls.NUMBER, number);
_ContentValues.put(CallLog.Calls.DATE, System.currentTimeMillis());
_ContentValues.put(CallLog.Calls.TYPE, CallLog.Calls.OUTGOING_TYPE);
_ContentValues.put(CallLog.Calls.DURATION, 1000);
_ContentValues.put(CallLog.Calls.NEW, 1);
_ContentValues.put(CallLog.Calls.CACHED_NUMBER_TYPE, 0);
_ContentValues.put(CallLog.Calls.CACHED_NUMBER_LABEL, "");
_ContentValues.put(CallLog.Calls.CACHED_NAME, name);
c.getContentResolver()
.insert(CallLog.Calls.CONTENT_URI, _ContentValues);
蒲公英,app发布平台
ScrollView嵌套ListView显示不全
//继承livtview,重写onMeasure方法
public class MyListView extends ListView {
public MyListView(Context context) {
super(context);
}
public MyListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
getSupportFragmentManager爆红
您要让Activity继承自FragmentActivity,这个类在support包中。。。
bugly
1.导入jar包
2.添加权限
3.添加混淆规则
-dontwarn com.tencent.bugly.**
-keep public class com.tencent.bugly.**{*;}
4.初始化
CrashReport.initCrashReport(getApplicationContext(), "注册时申请的APPID", false);
5.测试
CrashReport.testJavaCrash();
glide实现圆角图片
http://www.jianshu.com/p/7cd815b5da42
时间戳
要改为时间日期显示,必须是13位的时间戳,如果是10位只需乘以1000
动态申请权限
1.导包 permission-lib.jar
//2. 动态申请权限
MPermissions.requestPermissions(VIVOLauncherActivity.this, 0,
Manifest.permission.READ_CONTACTS,
Manifest.permission.WRITE_CONTACTS,
Manifest.permission.READ_CALL_LOG,
Manifest.permission.WRITE_CALL_LOG);
3.必须targetservion为23
Android VersionCode和VersionName的作用
http://blog.csdn.net/liranke/article/details/50748769
微信sdk
支付:
1.检查所有的配置信息,所有!
2.上平台检查所有的配置信息,所有!
3.检查返回的订单信息
4.微信的坑:第一次支付失败后,微信会记录调用他app的缓存信息,后面修改后重新打包同样会支付失败,需要登录另一个微信号,或者清楚微信所有缓存数据后,才能重新测试
分享
调不起微信:检查 mWxApi.sendReq(req)回调,如果返回true才能正常调起。
原因:1.配置信息错误(app_id,api_key,app_key,包名是否正确,签名是否正确)。
2.分享的图片不能超过32k(实验证明,万通通讯的图标20.4也是不行,现在用的18.1才行);
Android(安卓)时间戳和日期之间的转化
http://blog.csdn.net/xiaocheng2290/article/details/73616072
滚动字幕
4种方式:
1.
android:id="@+id/dialer_scroll_text_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#33000000"
android:ellipsize="marquee"
android:gravity="center"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:textColor="@color/white"
android:textSize="18sp" />
一开始就显示字幕,字数不超过范围就不会滚动,滚动速度中,不能修改
2.
android:id="@+id/tv_rolltext"
android:layout_width="250.dip"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:ellipsize="marquee"
android:gravity="center"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:text="@string/app_name"
android:textColor="@color/white"
android:textSize="20sp" />
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
public class MyDefineTextView extends TextView {
public MyDefineTextView(Context context) {
super(context);
}
public MyDefineTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyDefineTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean isFocused() {
return true;
}
}
一开始显示字幕,长度短于设定就不滚动,滚动速度中,不可修改
3.
android:id="@+id/home_rolltext"
android:layout_width="match_parent"
android:layout_height="40dip"
android:layout_gravity="center_vertical"
android:ellipsize="marquee"
android:singleLine="true"
android:text=""
android:textColor="@color/white"
android:textSize="25.0dip" />
package com.jiayin.utils;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.FontMetricsInt;
import android.graphics.Rect;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.widget.TextView;
public class MarqueeTextView extends TextView {
/** 是否停止滚动 */
private boolean mStopMarquee;
private String mText;
private float mCoordinateX;
private float mTextWidth;
private Rect targetRect;
private Paint paint;
private FontMetricsInt fontMetrics;
private float fFontHeight;
private float fLineHeight;
private float baseline;
public MarqueeTextView(Context context, AttributeSet attrs) {
super(context, attrs);
Paint paint = getPaint();
FontMetricsInt fontMetrics = paint.getFontMetricsInt();
fFontHeight = (float) Math.ceil(fontMetrics.descent
- fontMetrics.ascent);
fLineHeight = (float) Math.ceil(fontMetrics.bottom - fontMetrics.top);
/* 设置字体的位置,y轴位置 */
if (fLineHeight > fFontHeight) {
baseline = (fLineHeight - fFontHeight) / 2 + fFontHeight
- fontMetrics.bottom
+ (fontMetrics.ascent - fontMetrics.top);
} else {
baseline = 26;
}
}
public void setText(String text) {
// Rect targetRect = new Rect(50, 50, 1000, 200);
// Paint paint = getPaint();
// Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
// FontMetricsInt fontMetrics = paint.getFontMetricsInt();
// baseline = targetRect.top + (targetRect.bottom - targetRect.top -
// fontMetrics.bottom + fontMetrics.top) / 2 - fontMetrics.top;
// baseline = fontMetrics.e
this.mText = text;
mTextWidth = getPaint().measureText(mText);
if (mHandler.hasMessages(0))
mHandler.removeMessages(0);
mHandler.sendEmptyMessageDelayed(0, 2000);
}
@Override
protected void onAttachedToWindow() {
mStopMarquee = false;
if (null != mText)
mHandler.sendEmptyMessageDelayed(0, 2000);
super.onAttachedToWindow();
}
@Override
protected void onDetachedFromWindow() {
mStopMarquee = true;
if (mHandler.hasMessages(0))
mHandler.removeMessages(0);
super.onDetachedFromWindow();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (null != mText) {
canvas.drawText(mText, mCoordinateX, baseline, getPaint());
}
}
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 0:
if (Math.abs(mCoordinateX) > (mTextWidth + 5)) {
mCoordinateX = 50;
invalidate();
if (!mStopMarquee) {
sendEmptyMessageDelayed(0, 500);
}
} else {
// 调节速度
mCoordinateX -= 1.2;
invalidate();
if (!mStopMarquee) {
sendEmptyMessageDelayed(0, 30);
}
}
break;
}
super.handleMessage(msg);
}
};
}
自定义控件,暂时未清楚原理,速度能修改,一开始显示,是否滚动不能调
4.AutoScrollTextView
package com.jiayin.ui;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.Display;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.TextView;
import com.mimi7038.R;
public class AutoScrollTextView extends TextView implements OnClickListener {
public final static String TAG = AutoScrollTextView.class.getSimpleName();
private float textLength = 0f;// 文本长度
private float viewWidth = 0f;
private float step = 0f;// 文字的横坐标
private float y = 0f;// 文字的纵坐标
private float temp_view_plus_text_length = 0.0f;// 用于计算的临时变量
private float temp_view_plus_two_text_length = 0.0f;// 用于计算的临时变量
public boolean isStarting = false;// 是否开始滚动
private Paint paint = null;// 绘图样式
private String text = "";// 文本内容
private Context mContext;
private int textColor;
private float scrollSpeed;
private boolean clickable;
public AutoScrollTextView(Context context) {
super(context);
this.mContext = context;
initView();
}
public AutoScrollTextView(Context context, AttributeSet attrs) {
super(context, attrs);
this.mContext = context;
TypedArray attributes = context.obtainStyledAttributes(attrs,
R.styleable.AutoScrollTextView);
// 颜色属性
textColor = attributes.getColor(
R.styleable.AutoScrollTextView_text_color, 0XFFFFFFFF);
// 滚动速度
scrollSpeed = attributes.getFloat(
R.styleable.AutoScrollTextView_scroll_speed, 1);
clickable = attributes.getBoolean(
R.styleable.AutoScrollTextView_clickable, true);
initView();
}
public AutoScrollTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.mContext = context;
initView();
}
private void initView() {
if (clickable) {
setOnClickListener(this);
}
}
public void init(WindowManager windowManager) {
paint = getPaint();
// 修改文字颜色
paint.setColor(textColor);
text = getText().toString();
textLength = paint.measureText(text);
viewWidth = getWidth();
if (viewWidth == 0) {
if (windowManager != null) {
Display display = windowManager.getDefaultDisplay();
viewWidth = display.getWidth();
}
}
step = textLength;
temp_view_plus_text_length = viewWidth + textLength;
temp_view_plus_two_text_length = viewWidth + textLength * 2;
y = getTextSize() + getPaddingTop();
// 默认滚动
startScroll();
}
@Override
public Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState();
SavedState ss = new SavedState(superState);
ss.step = step;
ss.isStarting = isStarting;
return ss;
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (!(state instanceof SavedState)) {
super.onRestoreInstanceState(state);
return;
}
SavedState ss = (SavedState) state;
super.onRestoreInstanceState(ss.getSuperState());
step = ss.step;
isStarting = ss.isStarting;
}
public static class SavedState extends BaseSavedState {
public boolean isStarting = false;
public float step = 0.0f;
SavedState(Parcelable superState) {
super(superState);
}
@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeBooleanArray(new boolean[] { isStarting });
out.writeFloat(step);
}
public static final Parcelable.Creator
CREATOR = new Parcelable.Creator () {
public SavedState[] newArray(int size) {
return new SavedState[size];
}
@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}
};
private SavedState(Parcel in) {
super(in);
boolean[] b = null;
in.readBooleanArray(b);
if (b != null && b.length > 0)
isStarting = b[0];
step = in.readFloat();
}
}
public void startScroll() {
isStarting = true;
invalidate();
}
public void stopScroll() {
isStarting = false;
invalidate();
}
@Override
public void onDraw(Canvas canvas) {
canvas.drawText(text, temp_view_plus_text_length - step, y, paint);
if (!isStarting) {
return;
}
step += scrollSpeed;// 0.5为文字滚动速度。
if (step > temp_view_plus_two_text_length)
step = textLength;
invalidate();
}
@Override
public void onClick(View v) {
if (isStarting)
stopScroll();
else
startScroll();
}
}
attrs
使用
xml
android:id="@+id/TextViewNotice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:inputType="text"
android:text=""
android:textSize="20sp"
myview:clickable="false"
myview:scroll_speed="3"
myview:text_color="@color/white" >
java
autoScrollTextView.setText(rolltxt);
autoScrollTextView.init(getWindowManager());
http://blog.sina.com.cn/s/blog_821e2bb10100uoao.html
自定义控件,一开始不显示,速度可调,能停止滚动
自定义控件
http://blog.csdn.net/allen315410/article/details/39343401
base64解码
obj = new JSONObject(info.result);
System.out.println(info.result.toString());
String data = obj.getString("data");
byte[] bys = Base64.decode(data, Base64.DEFAULT);
System.out.println(data.toString());
String iv = obj.getString("iv");
System.out.println(iv.toString());
byte[] result = AppUtils.decode(Constants.des_key,
bys, iv);
String resultStr = new String(result);
版本更新,要考虑到用户更新后的缓存问题,不能只想着新用户
微信支付,支付宝支付
微信支付 1.发起网络请求,请求获取支付信息 requeseData(pay_way, good_id, address, user_id, number, iccid, mobile); 2.把支付信息发送给微信 private void sendToWeChat(String m_id, String p_id, String nonce_str) { if (AppUtils.checkAPP(Fenxiao2WebActivity.this, HttpClient.WEIXIN_PACKAGE_NAME)) { genPayReq(m_id, p_id, nonce_str); msgApi.registerApp(Common.APP_ID); msgApi.sendReq(req); } else { Toast.makeText(Fenxiao2WebActivity.this, "未安装微信", 2000).show(); } } 3. @SuppressLint("NewApi") private void genPayReq(String mch_id, String prepay_id, String nonce_str) { req.appId = Common.APP_ID; req.partnerId = mch_id; req.prepayId = prepay_id; req.packageValue = "Sign=WXPay"; req.nonceStr = nonce_str.isEmpty() ? genNonceStr() : nonce_str; req.timeStamp = String.valueOf(genTimeStamp()); ListsignParams = new LinkedList (); signParams.add(new BasicNameValuePair("appid", req.appId)); signParams.add(new BasicNameValuePair("noncestr", req.nonceStr)); signParams.add(new BasicNameValuePair("package", req.packageValue)); signParams.add(new BasicNameValuePair("partnerid", req.partnerId)); signParams.add(new BasicNameValuePair("prepayid", req.prepayId)); signParams.add(new BasicNameValuePair("timestamp", req.timeStamp)); req.sign = genAppSign(signParams); } 4. private String genAppSign(List params) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < params.size(); i++) { sb.append(params.get(i).getName()); sb.append('='); sb.append(params.get(i).getValue()); sb.append('&'); } sb.append("key="); sb.append(Common.API_KEY); Log.e("test", sb.toString()); String appSign = MD5.getMessageDigest(sb.toString().getBytes()) .toUpperCase(); Log.e("test", appSign); return appSign; } private String genNonceStr() { Random random = new Random(); return MD5.getMessageDigest(String.valueOf(random.nextInt(10000)) .getBytes()); } private long genTimeStamp() { return System.currentTimeMillis() / 1000; } 5.配置信息,配置wxapi包的两个activity
缓存问题
弹出虚拟键盘的时候出现黑底和影响布局
在配置文件里添加 android:windowSoftInputMode="stateHidden|adjustPan"
获取android手机mac地址
https://www.jianshu.com/p/92acd8d028aa
除去ScrollVIew拉到尽头时再拉的阴影效果
一、删除android ScrollView边界阴影方法方法 1) 在xml中添加:android:fadingEdge=”none” 2) 代码中添加:ScrollView.setHorizontalFadingEdgeEnabled(false); 二、删除ScrollView拉到尽头(顶部、底部),然后继续拉出现的阴影效果 适用于2.3及以上的 否则不用设置 android:overScrollMode="never"
获取蓝牙mac地址
http://blog.csdn.net/zgcqflqinhao/article/details/52527860
Android Dialog 点击对话框外部区域不关闭的设置
http://blog.sina.com.cn/s/blog_8f1c79dd0101a63u.html
不要过多地创建对象,可以考虑判断已经实例化的对象就不要重复实例化,直接使用,过过new对象可能会对内存有影响,可能会造成内存溢出
网址:
http://www.yuangongju.com/color rgb转16进制
http://android.lineten.net/layout.php findid
http://link.fobshanghai.com/rgbcolor.htm 网页取色器
https://www.ctolib.com/searchall/?https://www.ctolib.com/searchall/?term=%E9%80%9A%E8%AE%AF%E5%BD%95&sdomain=android 码库
http://tool.oschina.net/encode?type=3 在线编码转换
https://www.bejson.com/ 在线json校验
http://www.jsons.cn/json2java/ json生成java实体类工具
http://www.yuangongju.com/format?tab=xml 在线xml格式化