查看源码当我们调用System.gc()的时候,其实并不会马上进行垃圾回收,甚至不一定会执行垃圾回收,查看系统源码可以看到
/**
* Indicates to the VM that it would be a good time to run the
* garbage collector. Note that this is a hint only. There is no guarantee
* that the garbage collector will actually be run.
*/
public static void gc() {
boolean shouldRunGC;
synchronized(lock) {
shouldRunGC = justRanFinalization;
if (shouldRunGC) {
justRanFinalization = false;
} else {
runGC = true;
}
}
if (shouldRunGC) {
Runtime.getRuntime().gc();
}
}
也就是justRanFinalization=true的时候才会执行
继续阅读
|
最近项目用到一个需求,当收到透传消息后不管在哪个界面都要弹出一个dialog,当时觉得这还不简单嘛,new一个呀 ,于是我就在receiver里面new了一个
然后就报了如下的错
android.view.WindowManager$BadTokenException: Unable to add window – token null is not for an applicationandroid.view.ViewRootImpl.setView(ViewRootImpl.java:567) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:269) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) at android.app.Dialog.show(Dialog.java:323) at com.yipwey.dialogactivity.PushReceiver.onReceive(PushReceiver.java:16) at android.app.ActivityThread.handleReceiver(ActivityThread.java:2508) at android.app.ActivityThread.access$2000(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1323)
继续阅读
|
最近因为项目需求 ,需要播放网络视频 ,于是乎 研究了一番 ,说说我遇到的那些坑
现在市面上有几个比较主流好用的第三方框架
Vitamio ( 体积比较大,有商业化风险 github:https://github.com/yixia/VitamioBundle/)
ijkplayer(B站下开源的框架 体积大 配置环境比较麻烦 github:https://github.com/Bilibili/ijkplayer )
PLDroidPlayer(七牛根据ijkplayer二次开发的 定制简单 github:https://github.com/pili-engineering/PLDroidPlayer)
继续阅读
|
在做项目中,遇到一个很奇怪的问题 ,当调用fragmentTransaction.commit的时候 fragment的生命周期并没有立即执行,下面是我的代码
manager = getSupportFragmentManager();
FragmentTransaction ft = manager.beginTransaction();
MainFragment fragment = new MainFragment();
ft.add(R.id.fl_content, fragment);
ft.commit();
fragment.setInfo();
继续阅读
|
项目原本只加入高德sdk的时候,获取map,添加marker一切正常 ,可是只要我加入个推sdk后 编译运行 居然报高德地图的错 ,当时了就懵了- -这个是错误日志
java.lang.UnsatisfiedLinkError: No implementation found for long com.autonavi.amap.mapcore.MapCore.nativeNewInstance(java.lang.String, java.lang.String) (tried Java_com_autonavi_amap_mapcore_MapCore_nativeNewInstance and Java_com_autonavi_amap_mapcore_MapCore_nativeNewInstance__Ljava_lang_String_2Ljava_lang_String_2)
at com.autonavi.amap.mapcore.MapCore.nativeNewInstance(Native Method)
at com.autonavi.amap.mapcore.MapCore.newMap(MapCore.java:83
继续阅读
|
今天做项目遇到个比较头疼的问题,adapter.notifyDataSetChanged没有反应,要触摸屏幕才可以改变数据,上网查资料有人说是给list集合赋值的时候地址改变了(要用list.addAll()),可是我并没有改变地址 ,只是手动改了一个item的数据而已,后来发现只要延迟刷新就可以了
继续阅读
|
今天做项目遇到一个问题 ,
主界面用5个fragment组成,其中一个fragment里面 用了个ViewPager ,然后再这个ViewPager里面又嵌套了2个Fragment,第一次加载没有 但是第二次加载的时候 ,就变成空白
继续阅读
|