#Region Code to disable access to the StatusBar
'Code translated by Erel:
'http://www.b4x.com/android/forum/threads/overlay-over-the-status_bar.49221/#post-309833
'Original source code:
'http://stackoverflow.com/questions/9815901/display-view-above-status-bar/25384365#25384365
Sub AddOverlay
Dim mView As Label
mView.Initialize("")
mView.Text = Sentence
Dim mlp As JavaObject
Dim vtype As Int = -1, pixelFormat As Int = -3
mlp.InitializeNewInstance("android.view.WindowManager$LayoutParams", Array(vtype, 100, 2010,296, pixelFormat))
mlp.SetField("gravity", Bit.OR(Gravity.TOP, Gravity.CENTER))
Dim windowManager As JavaObject = GetContext.RunMethod("getSystemService", Array("window"))
windowManager.RunMethod("addView", Array(mView, mlp))
End Sub
Sub GetContext As JavaObject
Return GetBA.GetField("context")
End Sub
Sub GetBA As JavaObject
Dim jo As JavaObject
Dim cls As String = Me
cls = cls.SubString("class ".Length)
jo.InitializeStatic(cls)
Return jo.GetFieldJO("processBA")
End Sub
#End Region
در اندروید جدیدا خطای پایین میاد
Error occurred on line: 66 (lockstatus)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
at b4a.test.lockstatus._addoverlay(lockstatus.java:263)
at b4a.test.lockstatus._service_start(lockstatus.java:390)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at b4a.test.lockstatus.handleStart(lockstatus.java:100)
at b4a.test.lockstatus.access$000(lockstatus.java:8)
at b4a.test.lockstatus$1.run(lockstatus.java:71)
at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand(ServiceHelper.java:237)
at b4a.test.lockstatus.onStartCommand(lockstatus.java:69)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3885)
at android.app.ActivityThread.access$1700(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.Loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7045)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
Caused by: android.view.WindowManager$BadTokenException: Unable To add window android.view.ViewRootImpl$W@d8ef02f -- permission denied For window Type 2010
at android.view.ViewRootImpl.setView(ViewRootImpl.java:1064)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:381)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
... 25 more
سوال
salmana 174
قبلنا با لینک پایین راحت استاسو رو قفل میکردیم
https://www.b4x.com/android/forum/threads/disable-access-to-the-statusbar-notification-bar.49701/
در این لینک بالا کدهایی بصورت پایین قرار داده شده
#Region Code to disable access to the StatusBar 'Code translated by Erel: 'http://www.b4x.com/android/forum/threads/overlay-over-the-status_bar.49221/#post-309833 'Original source code: 'http://stackoverflow.com/questions/9815901/display-view-above-status-bar/25384365#25384365 Sub AddOverlay Dim mView As Label mView.Initialize("") mView.Text = Sentence Dim mlp As JavaObject Dim vtype As Int = -1, pixelFormat As Int = -3 mlp.InitializeNewInstance("android.view.WindowManager$LayoutParams", Array(vtype, 100, 2010,296, pixelFormat)) mlp.SetField("gravity", Bit.OR(Gravity.TOP, Gravity.CENTER)) Dim windowManager As JavaObject = GetContext.RunMethod("getSystemService", Array("window")) windowManager.RunMethod("addView", Array(mView, mlp)) End Sub Sub GetContext As JavaObject Return GetBA.GetField("context") End Sub Sub GetBA As JavaObject Dim jo As JavaObject Dim cls As String = Me cls = cls.SubString("class ".Length) jo.InitializeStatic(cls) Return jo.GetFieldJO("processBA") End Sub #End Region
در اندروید جدیدا خطای پایین میاد
Error occurred on line: 66 (lockstatus) java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131) at b4a.test.lockstatus._addoverlay(lockstatus.java:263) at b4a.test.lockstatus._service_start(lockstatus.java:390) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144) at anywheresoftware.b4a.BA.raiseEvent(BA.java:176) at b4a.test.lockstatus.handleStart(lockstatus.java:100) at b4a.test.lockstatus.access$000(lockstatus.java:8) at b4a.test.lockstatus$1.run(lockstatus.java:71) at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand(ServiceHelper.java:237) at b4a.test.lockstatus.onStartCommand(lockstatus.java:69) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3885) at android.app.ActivityThread.access$1700(ActivityThread.java:237) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.Loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7045) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964) Caused by: android.view.WindowManager$BadTokenException: Unable To add window android.view.ViewRootImpl$W@d8ef02f -- permission denied For window Type 2010 at android.view.ViewRootImpl.setView(ViewRootImpl.java:1064) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:381) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93) ... 25 more
لاین 66 هم اینه :
windowManager.RunMethod("addView", Array(mView, mlp))
با تشکر
لینک ارسال
به اشتراک گذاری در سایت های دیگر
5 پاسخ به این سوال تاکنون داده شده است
ارسالهای توصیه شده
بایگانی شده
این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.