This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 请注意:这种继承Binder类的方式仅适用于Service与绑定的组件处于同一应用程序或进程的情况,当然这也是最普遍的情况。举例来说,在播放音乐应用程序中,可以使用这种方式将一个Activity与Service绑定,而Service用于在后台播放音乐。 | |
| 参考文章 http://mp.weixin.qq.com/s?__biz=MzA5MzI3NjE2MA==&mid=2650236008&idx=1&sn=c7a1f1de9ee92e6d7a2d00f04821a8c3&scene=0#wechat_redirect | |
| 1. Service 类代码============== | |
| public class LocalService extends Service | |
| // Binder given to clients | |
| private final IBinder mBinder = new LocalBinder(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 内部类不能被混淆,否则h5页面内找不到android中类 | |
| -keep class com.sohu.tv.activity.IndividualH5Activity$*{*;} | |
| webView.addJavascriptInterface(new HTMLHandler(), "handler"); | |
| webView.loadUrl(getJsOfFetchMeta()); | |
| class HTMLHandler { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void doubleClickDetect(View view){ | |
| Observable<Void> observable = RxView.clicks(view).share(); | |
| observable.buffer(observable.debounce(200, TimeUnit.MILLISECONDS)) | |
| .observeOn(AndroidSchedulers.mainThread()) | |
| .subscribe(new Action1<List<Void>>() { | |
| @Override | |
| public void call(List<Void> voids) { | |
| if(voids.size() >= 2){ | |
| //double click detected | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private WeakReference<ClassName> mActivityWeakReference = new WeakReference<ClassName>(this); | |
| private final Handler mHandler = new InnerHandler(mActivityWeakReference); | |
| private static class InnerHandler extends Handler { | |
| WeakReference<ClassName> activityWeakReference; | |
| InnerHandler(WeakReference<ClassName> activityWeakReference) { | |
| this.activityWeakReference = activityWeakReference; | |
| } | |
| public void handleMessage(android.os.Message msg) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 遍历HashMap中元素的最佳方法是什么? | |
| 解决方案 | |
| 这样遍历entrySet: | |
| public static void printMap(Map mp) { | |
| Iterator it = mp.entrySet().iterator(); | |
| while (it.hasNext()) { | |
| Map.Entry pair = (Map.Entry)it.next(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 我试着使用Java生成一个随机整数,但是随机被指定在一个范围里。例如,整数范围是5~10,就是说5是最小的随机值,10是最大的。5到10之间的书也可以是生成的随机数。 | |
| 解决方案 | |
| 标准的解决方式(Java1.7 之前)如下: | |
| import java.util.Random; | |
| public static int randInt(int min, int max) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| function zip_align() | |
| { | |
| TEMP="${1}" | |
| DEST="${2}" | |
| if [ ! -f "${TEMP}" ]; then | |
| echo "${TEMP} is NOT a file" | |
| return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Script adb+ | |
| # Run any command adb provides on all your currently connected devices, | |
| # Or prompt to select one device | |
| showHelp() { | |
| echo "Usage: adb+ [-a] <command>" | |
| echo " -h: show help" | |
| echo " -a: run command on all device" | |
| echo " command: normal adb commands" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1.debug false | |
| 2.sign true | |
| 3.test proguard | |
| 4.change version code | |
| 5.upload new apk to umeng and test update works | |
| 6.merge master to release branch | |
| 7.upload new apk to appstores |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # AS中注释掉内容 | |
| *.gradle | |
| gradle* | |
| build | |
| .idea | |
| *.iml | |
| local.properties |