{"action":"created","issue":{"url":"https://api.github.com/repos/maoruibin/TranslateApp/issues/12","repository_url":"https://api.github.com/repos/maoruibin/TranslateApp","labels_url":"https://api.github.com/repos/maoruibin/TranslateApp/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/maoruibin/TranslateApp/issues/12/comments","events_url":"https://api.github.com/repos/maoruibin/TranslateApp/issues/12/events","html_url":"https://github.com/maoruibin/TranslateApp/issues/12","id":143862110,"number":12,"title":"app外悬浮窗如何覆盖状态栏讨论","user":{"login":"leizhiyuan","id":2684384,"avatar_url":"https://avatars.githubusercontent.com/u/2684384?v=3","gravatar_id":"","url":"https://api.github.com/users/leizhiyuan","html_url":"https://github.com/leizhiyuan","followers_url":"https://api.github.com/users/leizhiyuan/followers","following_url":"https://api.github.com/users/leizhiyuan/following{/other_user}","gists_url":"https://api.github.com/users/leizhiyuan/gists{/gist_id}","starred_url":"https://api.github.com/users/leizhiyuan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leizhiyuan/subscriptions","organizations_url":"https://api.github.com/users/leizhiyuan/orgs","repos_url":"https://api.github.com/users/leizhiyuan/repos","events_url":"https://api.github.com/users/leizhiyuan/events{/privacy}","received_events_url":"https://api.github.com/users/leizhiyuan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-28T00:02:45Z","updated_at":"2016-03-30T00:01:11Z","closed_at":null,"body":"\r\n从[参考1](http://www.jianshu.com/p/167fd5f47d5c)里的尝试情况\r\n\r\n>TYPE_SEARCH_BAR：未知\r\n>TYPE_ACCESSIBILITY_OVERLAY：拒绝使用\r\n>TYPE_APPLICATION：只能配合Activity在当前APP使用\r\n>TYPE_APPLICATION_ATTACHED_DIALOG：只能配合Activity在当前APP使用\r\n>TYPE_APPLICATION_MEDIA：无法使用（什么也不显示）\r\n>TYPE_APPLICATION_PANEL：只能配合Activity在当前APP使用（PopupWindow默认就是这个>Type）\r\n>TYPE_APPLICATION_STARTING：无法使用（什么也不显示）\r\n>TYPE_APPLICATION_SUB_PANEL：只能配合Activity在当前APP使用\r\n>TYPE_BASE_APPLICATION：无法使用（什么也不显示）\r\n>TYPE_CHANGED：只能配合Activity在当前APP使用\r\n>TYPE_INPUT_METHOD：无法使用（直接崩溃）\r\n>TYPE_INPUT_METHOD_DIALOG：无法使用（直接崩溃）\r\n>TYPE_KEYGUARD_DIALOG：拒绝使用\r\n>TYPE_PHONE：属于悬浮窗（并且给一个Activity的话按下HOME键会出现看不到桌面上的图标异常情况）\r\n>TYPE_TOAST：不属于悬浮窗，但有悬浮窗的功能，缺点是在Android2.3上无法接收点击事件\r\n>TYPE_SYSTEM_ALERT：属于悬浮窗，但是会被禁止\r\n\r\n可以看到这个TOAST的type是不能改的.要改申请权限,如果申请权限,就不用通过这种方式绕过了,\r\n根据官方说明\r\n\r\ntype: 值低的窗口在值高的下层,相同的 type值,后创建的窗口显示在先创建的窗口上面.\r\n\r\n但是状态栏是2000\r\n````\r\nWindow type: the status bar. There can be only one status bar window; it is placed at the top of the screen, and all other windows are shifted down so they are below it. In multiuser systems shows on all users' windows.\r\n````\r\nTYPE_TOAST 是 2005\r\n然后就是可能修改FLAG了.\r\n\r\n我自己根据[官方文档](http://developer.android.com/intl/zh-cn/reference/android/view/WindowManager.LayoutParams.html).测试了几个比较可能的.比如\r\nFLAG_FULLSCREEN 等.当时这个值的时候,会被状态栏遮挡部分,但是无法显示在状态栏之上.( ,说法好像有冲突..按理说应该是在上面的.因为值更高.也可能是因为这个值只能在本app内使用.)\r\n\r\n暂无思路.."},"comment":{"url":"https://api.github.com/repos/maoruibin/TranslateApp/issues/comments/203163125","html_url":"https://github.com/maoruibin/TranslateApp/issues/12#issuecomment-203163125","issue_url":"https://api.github.com/repos/maoruibin/TranslateApp/issues/12","id":203163125,"user":{"login":"leizhiyuan","id":2684384,"avatar_url":"https://avatars.githubusercontent.com/u/2684384?v=3","gravatar_id":"","url":"https://api.github.com/users/leizhiyuan","html_url":"https://github.com/leizhiyuan","followers_url":"https://api.github.com/users/leizhiyuan/followers","following_url":"https://api.github.com/users/leizhiyuan/following{/other_user}","gists_url":"https://api.github.com/users/leizhiyuan/gists{/gist_id}","starred_url":"https://api.github.com/users/leizhiyuan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leizhiyuan/subscriptions","organizations_url":"https://api.github.com/users/leizhiyuan/orgs","repos_url":"https://api.github.com/users/leizhiyuan/repos","events_url":"https://api.github.com/users/leizhiyuan/events{/privacy}","received_events_url":"https://api.github.com/users/leizhiyuan/received_events","type":"User","site_admin":false},"created_at":"2016-03-30T00:01:11Z","updated_at":"2016-03-30T00:01:11Z","body":"看了一下这个项目,基本原理就是使用Notification\r\n\r\n在`TipViewController`中的show方法中,先简(hen)单(cuo)的demo测试一下,.\r\n\r\n````\r\n  Intent openintent = new Intent();\r\n        PendingIntent contentIntent = PendingIntent.getActivity(GDApplication.get(), 0, openintent, 0);\r\n        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(\r\n                GDApplication.get()).setSmallIcon(android.R.drawable.ic_lock_power_off).setPriority(2)\r\n                .setContentTitle(result.getQuery())\r\n                .setContentText(result.getExplains().get(0))\r\n                .setFullScreenIntent(contentIntent,true);\r\n        NotificationManager mNotifyManager = (NotificationManager) GDApplication.get().getSystemService(Context.NOTIFICATION_SERVICE);\r\n\r\n        int id=NOTIFY_ID++;\r\n\r\n        mNotifyManager.notify(id, mBuilder.build());\r\n        try {\r\n            Thread.sleep(2000);\r\n        } catch (InterruptedException e) {\r\n            e.printStackTrace();\r\n        }\r\n\r\n        mNotifyManager.cancel(id);\r\n````\r\n\r\n实现的效果是,app外可以显示,2s后自动取消.\r\n![demo](https://cloud.githubusercontent.com/assets/2684384/14127702/9f5c7a78-f64c-11e5-9162-4184e25a97ea.jpg)\r\n取消后通知栏干净\r\n![demo2](https://cloud.githubusercontent.com/assets/2684384/14127703/9f63de58-f64c-11e5-9e9b-a7ccbd9c83e5.jpg)\r\n\r\n剩下的问题是\r\n1. 添加并响应收藏按钮,\r\n2. 兼容问题,是否直接使用HeadsUp这个项目.\r\n\r\n"}}