注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

沉默蜂B4A安卓编程

国内资料最全的B4A资料库

 
 
 

日志

 
 

[类]空白闪屏(二)  

2015-09-30 12:22:08|  分类: B.图形 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
'类模块 SLBlankScreen.bas
'Class module
Sub Class_Globals
Dim WinMan As JavaObject

Dim BGPnl As Panel
End Sub
'Based on code found on StackOverflow
'http://stackoverflow.com/questions/9538331/android-turn-off-display-without-triggering-sleep-lock-screen-turn-on-with-t/16034100#16034100

'Initializes the object. Requires permission to be added to the manifest with:
'AddPermission("android.permission.SYSTEM_ALERT_WINDOW")
'Pas the activity and a panel for a splash screen or Null or none.
Public Sub Initialize(Act As Activity,Pnl As Object)
BGPnl.Initialize("")
If Pnl <> Null Then
Dim P As Panel = Pnl
P.RemoveView
BGPnl.AddView(P,(Act.Width-P.Width)/2,(Act.Height-P.Height)/2,P.Width,P.Height)
End If
End Sub
'Show the blank screen
Sub Show
'Get a Windows Manager instance
Dim R As Reflector
R.Target=R.GetContext
WinMan = R.RunMethod2("getSystemService","window","java.lang.String")

'And a LayoutParameters Insance
Dim LOParam As JavaObject
LOParam.InitializeNewInstance("android.view.WindowManager.LayoutParams",Null)
'Populate the Layout objects fields
LOParam.SetField("height",0xffffffff)
LOParam.SetField("width",0xffffffff)
LOParam.SetField("flags",280)
LOParam.SetField("format",0xfffffffd)
LOParam.SetField("windowAnimations",16973824) ' Base Animation
LOParam.SetField("type",2006)
LOParam.SetField("gravity",Gravity.BOTTOM)
LOParam.SetField("x",0)
LOParam.SetField("y",0)
LOParam.SetField("verticalWeight",1)
LOParam.SetField("horizontalWeight",1)
LOParam.SetField("verticalMargin",0)
LOParam.SetField("horizontalMargin",0)
'Set the panel color background
Dim CD As ColorDrawable
CD.Initialize(Colors.Black,0)
BGPnl.Background=CD
'Add it to Windows manager
WinMan.RunMethod("addView",Array As Object(BGPnl,LOParam))
End Sub
'Hide the blank Screen
Sub Hide
'Remove the panel from Windows manager
WinMan.RunMethod("removeView",Array As Object(BGPnl))
End Sub

  评论这张
 
阅读(94)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017