Android Question Activity always on top

F.Campanella

Member
Licensed User
Longtime User
Hi,
I'm building an watchface application for Android (not wear).

I need that every time the screen turns on, the activity that contains the watchface must overlap all the others.
I've tried using a service where when PhoneEvents_ScreenOn event is raised call StartActivity(Main) but don't work.

Are ther other solutions?
Can you help me?

Thanks for your time!!!
F.
 

F.Campanella

Member
Licensed User
Longtime User
I've resolved!!!!
I used this code:

Dim jo As JavaObject = Activity
Dim Window As JavaObject = jo.RunMethodJO("getContext", Null).RunMethod("getWindow", Null)
Window.RunMethod("addFlags", Array As Object(524288)) 'FLAG_SHOW_WHEN_LOCKED
Window.RunMethod("addFlags", Array As Object(128)) 'FLAG_KEEP_SCREEN_ON

F.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

TOCC

Member
Licensed User
Longtime User
Just out of curiosity as i am waiting for my smartwatch to be delivered.
Is a watchface for android wear just a normal app or is it a special kind of app or service?
 
Upvote 0

F.Campanella

Member
Licensed User
Longtime User
Is just a normal app. Naturally you need to set a few things for your project.
1) the watchface works only when there is no lock screen set
2) you have to create a service that is loaded when the smartwatch power on, in this service you have to check when the display turns on. In this event you have to start the activity that contain watchface.
3) all activities must be full screen and no activity title set. like:
#FullScreen: True
#IncludeTitle: False
 
Upvote 0
Top