我正在开发一个有很多服务的应用程序.当我停止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) 我正在尝试使用Google Play服务中的geofencing api,但我无法设法让我的广播接收器触发其onReceive()方法.
看起来我尊重使其工作所需的一切,但我没有过渡事件.
ACCESS_FINE_LOCATION许可BroadcastReceiver在我的Manifest中注册了我的导出值设置为"true"(有人说它是必需的)ACCESS_MOCK_LOCATION存在延迟)但是,我仍然获得了成功的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
我想在任何应用程序中的特定时间弹出对话框我的代码:
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);我的应用程序是正确的,这是什么权限.....