Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
james正哥儿
testforfloatingwindow
提交
5e4633f3
T
testforfloatingwindow
项目概览
james正哥儿
/
testforfloatingwindow
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
testforfloatingwindow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5e4633f3
编写于
5月 30, 2018
作者:
董
董重
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新建FloatingImageDisplayService
上级
b05018e1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
45 addition
and
7 deletion
+45
-7
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+2
-1
app/src/main/java/dongzhong/testforfloatingwindow/FloatingButtonService.java
...ongzhong/testforfloatingwindow/FloatingButtonService.java
+1
-1
app/src/main/java/dongzhong/testforfloatingwindow/FloatingImageDisplayService.java
...ng/testforfloatingwindow/FloatingImageDisplayService.java
+22
-0
app/src/main/java/dongzhong/testforfloatingwindow/MainActivity.java
...in/java/dongzhong/testforfloatingwindow/MainActivity.java
+12
-3
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_main.xml
+8
-2
未找到文件。
app/src/main/AndroidManifest.xml
浏览文件 @
5e4633f3
...
...
@@ -18,7 +18,8 @@
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<service
android:name=
".FloatingWindowService"
></service>
<service
android:name=
".FloatingButtonService"
></service>
<service
android:name=
".FloatingImageDisplayService"
></service>
</application>
</manifest>
\ No newline at end of file
app/src/main/java/dongzhong/testforfloatingwindow/Floating
Window
Service.java
→
app/src/main/java/dongzhong/testforfloatingwindow/Floating
Button
Service.java
浏览文件 @
5e4633f3
...
...
@@ -19,7 +19,7 @@ import android.widget.Button;
* Created by dongzhong on 2018/5/30.
*/
public
class
Floating
Window
Service
extends
Service
{
public
class
Floating
Button
Service
extends
Service
{
private
WindowManager
windowManager
;
private
WindowManager
.
LayoutParams
layoutParams
;
...
...
app/src/main/java/dongzhong/testforfloatingwindow/FloatingImageDisplayService.java
0 → 100644
浏览文件 @
5e4633f3
package
dongzhong.testforfloatingwindow
;
import
android.app.Service
;
import
android.content.Intent
;
import
android.os.IBinder
;
import
android.support.annotation.Nullable
;
import
android.view.WindowManager
;
/**
* Created by dongzhong on 2018/5/30.
*/
public
class
FloatingImageDisplayService
extends
Service
{
private
WindowManager
windowManager
;
private
WindowManager
.
LayoutParams
layoutParams
;
@Nullable
@Override
public
IBinder
onBind
(
Intent
intent
)
{
return
null
;
}
}
app/src/main/java/dongzhong/testforfloatingwindow/MainActivity.java
浏览文件 @
5e4633f3
...
...
@@ -23,17 +23,26 @@ public class MainActivity extends AppCompatActivity {
Toast
.
makeText
(
this
,
"授权失败"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
Toast
.
makeText
(
this
,
"授权成功"
,
Toast
.
LENGTH_SHORT
).
show
();
startService
(
new
Intent
(
MainActivity
.
this
,
Floating
Window
Service
.
class
));
startService
(
new
Intent
(
MainActivity
.
this
,
Floating
Button
Service
.
class
));
}
}
}
public
void
startFloatingService
(
View
view
)
{
public
void
startFloating
Button
Service
(
View
view
)
{
if
(!
Settings
.
canDrawOverlays
(
this
))
{
Toast
.
makeText
(
this
,
"当前无权限,请授权"
,
Toast
.
LENGTH_SHORT
);
startActivityForResult
(
new
Intent
(
Settings
.
ACTION_MANAGE_OVERLAY_PERMISSION
,
Uri
.
parse
(
"package:"
+
getPackageName
())),
1111
);
}
else
{
startService
(
new
Intent
(
MainActivity
.
this
,
FloatingWindowService
.
class
));
startService
(
new
Intent
(
MainActivity
.
this
,
FloatingButtonService
.
class
));
}
}
public
void
startFloatingLayoutService
(
View
view
)
{
if
(!
Settings
.
canDrawOverlays
(
this
))
{
Toast
.
makeText
(
this
,
"当前无权限,请授权"
,
Toast
.
LENGTH_SHORT
);
startActivityForResult
(
new
Intent
(
Settings
.
ACTION_MANAGE_OVERLAY_PERMISSION
,
Uri
.
parse
(
"package:"
+
getPackageName
())),
1111
);
}
else
{
startService
(
new
Intent
(
MainActivity
.
this
,
FloatingButtonService
.
class
));
}
}
}
app/src/main/res/layout/activity_main.xml
浏览文件 @
5e4633f3
...
...
@@ -8,7 +8,13 @@
<Button
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"start floating service"
android:onClick=
"startFloatingService"
/>
android:text=
"start floating button"
android:onClick=
"startFloatingButtonService"
/>
<Button
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"start floating layout"
android:onClick=
"startFloatingLayoutService"
/>
</LinearLayout>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录