小编Har*_*thi的帖子

停止服务正在进行持续垃圾收集

我正在开发一个有很多服务的应用程序.当我停止intent服务时,应该停止所有线程和服务,但是UI挂起并且logcat中存在以下错误:

2014-12-01 12: 37: 92I/art     (32099): Background partial concurrent mark sweep GC freed 419756(33MB) AllocSpace objects, 15(4MB) LOS objects, 38% free, 25MB/41MB, paused 1.617ms total 451.976ms
2014-12-01 12: 37: 40I/art     (32099): Background sticky concurrent mark sweep GC freed 290680(16MB) AllocSpace objects, 0(0B) LOS objects, 23% free, 25MB/33MB, paused 23.287ms total 229.513ms
2014-12-01 12: 37: 29I/art     (32099): Background partial concurrent mark sweep GC freed 165880(9MB) AllocSpace objects, 0(0B) LOS objects, 39% free, 23MB/39MB, paused 1.648ms total 203.601ms
2014-12-01 12: 37: 54I/art …
Run Code Online (Sandbox Code Playgroud)

android garbage-collection

24
推荐指数
1
解决办法
3万
查看次数

Android地理围栏API BroadcastReceiver未触发

我正在尝试使用Google Play服务中的geofencing api,但我无法设法让我的广播接收器触发其onReceive()方法.

看起来我尊重使其工作所需的一切,但我没有过渡事件.

  • 我在我的依赖项中包含了google play服务
  • 我请求ACCESS_FINE_LOCATION许可
  • BroadcastReceiver在我的Manifest中注册了我的导出值设置为"true"(有人说它是必需的)
  • 我想补充的地方,我(我与谷歌地图验证它放在我的手机)的确切位置一个大地理围栏与两个过渡类型,并没有过期
  • 我在地理围栏的中间尝试了一个精确的模拟位置,并在10秒后尝试了另一个地理围栏(我确保ACCESS_MOCK_LOCATION存在延迟)
  • 我确认我的手机位置已打开,其模式设置为高精度
  • 我验证了互联网连接
  • 添加地理围栏后,我尝试使用和不连接LocationClient

但是,我仍然获得了成功的onAddGeofencesResult()回调,但没有onReceive()回调.我尝试使用Nexus 5和Nexus 7,两者都无法触发地理围栏过渡.

我还尝试了https://developer.android.com/training/location/geofencing.html上的示例,但其行为完全相同.

这是我的BroadcastReceiver班级:

public class GeofencesReceiver extends BroadcastReceiver implements ConnectionCallbacks, OnConnectionFailedListener, OnAddGeofencesResultListener {
    private final static String TAG = "GeofencesReceiver";

    private Context context = null;
    private LocationClient locationClient = null;

    /**
     * An empty constructor is needed by the manifest.
     */
    @SuppressWarnings("unused")
    public GeofencesReceiver(){}

    public GeofencesReceiver(Context context){
        this.context = …
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver geofencing google-play-services location-client

11
推荐指数
1
解决办法
3940
查看次数

任何应用程序中的弹出窗口

我想在任何应用程序中的特定时间弹出对话框我的代码:

 public class testPOPDialog extends Activity {
/** Called when the activity is first created. */
private Handler mHandler = new Handler();
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


    mHandler.postDelayed(mUpdateTimeTask, 1000);



}
private Runnable mUpdateTimeTask = new Runnable() {
       public void run() {
           AlertDialog d = new AlertDialog.Builder(testPOPDialog.this)
            .setTitle("tanchulai")
            .setMessage("bucuo de tanchulai")

            .create();

        d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        d.show();     
       }
    };

}
Run Code Online (Sandbox Code Playgroud)

它给了我

12-03 10:12:18.162: ERROR/AndroidRuntime(571): android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRoot$W@43dd71c0 -- permission denied for this window type
Run Code Online (Sandbox Code Playgroud)

如果我删除d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);我的应用程序是正确的,这是什么权限.....

android android-widget

7
推荐指数
1
解决办法
1万
查看次数

如何仅从DCIM目录获取映像

我从SD卡获取所有图像,但现在我只想显示用相机拍摄的照片(在DCIM文件夹中).

有可能吗?

android

6
推荐指数
2
解决办法
1万
查看次数