How can I interact with the Lockscreen layout to display text in it, for example this application:

I just opened this application: https://market.android.com/details?id=de.j4velin.lockscreenCalendar

It seems that now you can write the text inside the lock screen in the place where the alarm is usually recorded.

I would like to display custom text in this place, but I don't know how to achieve this.

This guy manages to record calendar events in this place.

Thanks so much for any key / snippet that will help me.

enter image description here

+8
android textview alarm lockscreen
source share
6 answers

This is surprisingly easy to achieve and amazingly poorly documented. All you have to do is set the alarm line in the system settings as follows:

String message = "This is a test"; Settings.System.putString(context.getContentResolver(), Settings.System.NEXT_ALARM_FORMATTED, message); 
+9
source share

This is not what you requested, but the code for the custom lockscreen can be found here. It might help you.

http://code.google.com/p/contactowner/

+1
source share

I have never come across any legal way in the Android public APIs to affect the lock screen. Without playing with this application, I would not know for sure, but I think he created this activity that allows him to display any text he wants. Then it uses the receiver to listen for SCREEN_OFF or SCREEN_ON events and begins its "blocking" of activity at this time.

It is worth noting: if you decide to do something similar to achieve the effect that you need, it will not behave exactly like a lock screen. The differences can be quite small and can be perfect for your purposes, but keep in mind that they are. In addition, if you go along this route, this will not work if the user has a โ€œtemplateโ€ lock, because KeyguardManager cannot programmatically disable this screen.

+1
source share

you also need to add

  <uses-permission android:name="android.permission.WRITE_SETTINGS"/> 

in androidmanifest.xml

+1
source share

Voted answer will work only if no one else uses it to display their message. If two receivers are registered for the SCREEN_ON / OFF action, the last message of the recipient will be displayed.

0
source share

There are 2 problems with the solution of marc1s, 1. it does not look very good, and you cannot change its appearance and filling, for example. text font or color etc. 2. any other application can replace it

Therefore, it is better if you show the view using the window manager from the service. That way you can show any view you want to show.

eg. my code is below in onStartCommand my service

 WindowManager mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE); View mView = mInflater.inflate(R.layout.score, null); WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON /* | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON */, PixelFormat.RGBA_8888); mWindowManager.addView(mView, mLayoutParams); 
0
source share

All Articles