{"action":"opened","issue":{"url":"https://api.github.com/repos/lion-liu/The-First-Line-Of-Code/issues/9","repository_url":"https://api.github.com/repos/lion-liu/The-First-Line-Of-Code","labels_url":"https://api.github.com/repos/lion-liu/The-First-Line-Of-Code/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/lion-liu/The-First-Line-Of-Code/issues/9/comments","events_url":"https://api.github.com/repos/lion-liu/The-First-Line-Of-Code/issues/9/events","html_url":"https://github.com/lion-liu/The-First-Line-Of-Code/issues/9","id":161878803,"number":9,"title":"unresolved:even i  access permission ,the AlertManager Builder created AlertDialog also can't be show ","user":{"login":"lion-liu","id":1003345,"avatar_url":"https://avatars.githubusercontent.com/u/1003345?v=3","gravatar_id":"","url":"https://api.github.com/users/lion-liu","html_url":"https://github.com/lion-liu","followers_url":"https://api.github.com/users/lion-liu/followers","following_url":"https://api.github.com/users/lion-liu/following{/other_user}","gists_url":"https://api.github.com/users/lion-liu/gists{/gist_id}","starred_url":"https://api.github.com/users/lion-liu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lion-liu/subscriptions","organizations_url":"https://api.github.com/users/lion-liu/orgs","repos_url":"https://api.github.com/users/lion-liu/repos","events_url":"https://api.github.com/users/lion-liu/events{/privacy}","received_events_url":"https://api.github.com/users/lion-liu/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/lion-liu/The-First-Line-Of-Code/labels/bug","name":"bug","color":"ee0701"},{"url":"https://api.github.com/repos/lion-liu/The-First-Line-Of-Code/labels/help%20wanted","name":"help wanted","color":"128A0C"},{"url":"https://api.github.com/repos/lion-liu/The-First-Line-Of-Code/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-23T09:32:07Z","updated_at":"2016-06-23T09:32:07Z","closed_at":null,"body":"\r\n  android api 23\r\n\r\n> \r\n`<uses-permission android:name=\"android.permission.SYSTEM_ALERT_WINDOW\" />`\r\n\r\n> \r\n`@Override\r\n    public void onReceive(final Context context, Intent intent) {\r\n        AlertDialog.Builder alBuilder = new AlertDialog.Builder(context);\r\n        alBuilder.setTitle(\"Warning\");\r\n        alBuilder.setMessage(\"You are forced to be offline. Please try\\n\" +\r\n                \"to login again.\");\r\n        alBuilder.setCancelable(false);\r\n        alBuilder.setPositiveButton(\"OK\", new DialogInterface.OnClickListener() {\r\n            @Override\r\n            public void onClick(DialogInterface dialog, int which) {\r\n                ActivityCollector.FinishAll(); //finish all\r\n                Intent intent1 = new Intent(context, LoginActivity.class);\r\n                intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\r\n                context.startActivity(intent1);\r\n            }\r\n        });\r\n        AlertDialog alertdialog=alBuilder.create();\r\n        alertdialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);\r\n        alertdialog.show();\r\n    }`\r\n\r\n> \r\n java.lang.RuntimeException: Unable to start receiver com.android.liuxsa.broadcastbestpractice.ForceOfflineReceiver: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@5542275 -- permission denied for this window type\r\n\r\n> ` E/AndroidRuntime: FATAL EXCEPTION: main\r\n                                                                                          Process: com.android.liuxsa.broadcastbestpractice, PID: 16031\r\n                                                                                          java.lang.RuntimeException: Unable to start receiver com.android.liuxsa.broadcastbestpractice.ForceOfflineReceiver: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@5542275 -- permission denied for this window type\r\n                                                                                              at android.app.ActivityThread.handleReceiver(ActivityThread.java:2732)\r\n                                                                                              at android.app.ActivityThread.-wrap14(ActivityThread.java)\r\n                                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421)\r\n                                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)\r\n                                                                                              at android.os.Looper.loop(Looper.java:148)\r\n                                                                                              at android.app.ActivityThread.main(ActivityThread.java:5417)\r\n                                                                                              at java.lang.reflect.Method.invoke(Native Method)\r\n                                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)\r\n                                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)\r\n                                                                                           Caused by: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@5542275 -- permission denied for this window type\r\n                                                                                              at android.view.ViewRootImpl.setView(ViewRootImpl.java:591)\r\n                                                                                              at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:310)\r\n                                                                                              at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)\r\n                                                                                              at android.app.Dialog.show(Dialog.java:319)\r\n                                                                                              at com.android.liuxsa.broadcastbestpractice.ForceOfflineReceiver.onReceive(ForceOfflineReceiver.java:32)\r\n                                                                                              at android.app.ActivityThread.handleReceiver(ActivityThread.java:2725)\r\n                                                                                              at android.app.ActivityThread.-wrap14(ActivityThread.java) \r\n                                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421) \r\n                                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) \r\n                                                                                              at android.os.Looper.loop(Looper.java:148) \r\n                                                                                              at android.app.ActivityThread.main(ActivityThread.java:5417) \r\n                                                                                              at java.lang.reflect.Method.invoke(Native Method) \r\n                                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) \r\n                                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) `\r\n\r\n> ``\r\n\r\n![image](https://cloud.githubusercontent.com/assets/1003345/16298378/be8ac82e-3967-11e6-97c7-9fab2913bd4d.png)\r\n\r\n![image](https://cloud.githubusercontent.com/assets/1003345/16298375/b9835710-3967-11e6-9769-824b8d7548b3.png)\r\n![image](https://cloud.githubusercontent.com/assets/1003345/16298393/cfa2b57c-3967-11e6-9da6-85e8454f4f8c.png)"}}
{"actor":{"display_login":"lion-liu"}}