http://stackoverflow.com/questions/3132021/android-listview-illegalstateexception-the-content-of-the-adapter-has-changed
根据路径找到registry.bin,删除,重启androidstudio即可。
in the leaked activity’s onDestroy(), set the AlertDialog’s ListView’s onItemClickListener() to null, which will release the reference to the listener an make whatever memory allocated within that listener to be eligible for GC. This way you won’t get OOM. It’s just a workaround and the real solution should actually be incorporated in the ListView.
Here’s a sample code for your onDestroy():
@Override protected void onDestroy() { super.onDestroy(); if(leakedDialog != null) { ListView lv = leakedDialog.getListView(); if(lv != null) lv.setOnItemClickListener(null); } }对于adapter同理 参考 http://stackoverflow.com/questions/7083441/android-alertdialog-causes-a-memory-leak
如果是想在动画执行完成之后,执行某些操作,可以通过如下方式
private class PageChangeListener implements OnPageChangeListener { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { isPageChanged = true; } @Override public void onPageScrollStateChanged(int state) { switch (state) { case ViewPager.SCROLL_STATE_IDLE: if (isPageChanged) { updateCurrentPage();//this will be called when animation ends isPageChanged = false; } break; case ViewPager.SCROLL_STATE_DRAGGING: break; case ViewPager.SCROLL_STATE_SETTLING: break; } } }参考Android viewpager animation
http://stackoverflow.com/questions/36516931/instant-run-disabled-for-multidexed-application
linkedlist 不是线程安全的,用ConcurrentLinkedQueue 参考 LinkedList多线程不安全的解决办法
使用sql 语句中,如果有字符串,必须加上 ‘ ‘单括号 括起来
You need to escape the filename parameter. The punctuation in the filename is confusing SQLite. You could do it by surrounding the filename in 'single quotes' in the string you pass in to SQLite, but it`s cleaner and safer to pass it as a separate argument, like this: sqliteDatabase.update(AndroidOpenDbHelper.TABLE_FILE, values, AndroidOpenDbHelper.COLUMN_NAME_FILE_NAME+"=?", new String[] {filename}); android.database.sqlite.SQLiteException: unrecognized token:当调用listItem.measure(0, 0);报空指针时问题: 检查Adapter适配时Item的根容器为RelativeLayout, 报错原因:
In platform version 17 and lower, RelativeLayout was affected by a measurement bug that could cause child views to be measured with incorrect MeasureSpec values. (See MeasureSpec.makeMeasureSpec for more details.) This was triggered when a RelativeLayout container was placed in a scrolling container, such as a ScrollView or HorizontalScrollView. If a custom view not equipped to properly measure with the MeasureSpec mode UNSPECIFIED was placed in a RelativeLayout, this would silently work anyway as RelativeLayout would pass a very large AT_MOST MeasureSpec instead. This behavior has been preserved for apps that set android:targetSdkVersion="17" or older in their manifest`s uses-sdktag for compatibility. Apps targeting SDK version 18 or newer will receive the correct behavior有三种解决方案:
一、升级版本到4.2.2 二、更改根容器为LinearLayout 三、在适配器里添加convertView.setLayoutParams(new LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); convertView为Item的view参考ScrollView嵌套ListView,listItem.measure(0,0);报空指针异常NullPointerException
参考 Android : Workaround for webview not loading https url Android WebView not loading an HTTPS URL How can load https url without use of ssl in android webview
[Android安全开发之安全使用HTTPS](https://www.easyaq.com/newsdetail/id/37169867.shtml) 这是一篇很好的文章!!!
目前很多应用都用webview加载H5页面,如果服务端采用的是可信CA颁发的证书,在webView.setWebViewClient(webviewClient)时重载WebViewClient的onReceivedSslError(),如果出现证书错误,直接调用handler.proceed()会忽略错误继续加载证书有问题的页面,如果调用handler.cancel()可以终止加载证书有问题的页面,证书出现问题了,可以提示用户风险,让用户选择加载与否,如果是需要安全级别比较高,可以直接终止页面加载,提示用户网络环境有风险:  不建议直接用handler.proceed(),聚安全的应用安全扫描器会扫出来直接调用handler.proceed()的情况。 如果webview加载https需要强校验服务端证书,可以在onPageStarted()中用HttpsURLConnection强校验证书的方式来校验服务端证书,如果校验不通过停止加载网页。当然这样会拖慢网页的加载速度,需要进一步优化,具体优化的办法不在本次讨论范围,这里也不详细讲解了。 需要在客户端中预埋证书文件,或者将证书硬编码写在代码中 正确使用HTTPS并非完全能够防住客户端的Hook分析修改,要想保证通信安全,也需要依靠其他方法,比如重要信息在交给HTTPS传输之前进行加密,另外实现客户端请求的签名处理,保证客户端与服务端通信请求不被伪造