Toast does not appear on HTC Sense 3.0 lock screen

I created a program that displays a toast every time I receive an incoming call. It works great on all the phones I've tried - toasts displayed on the incoming call screen.

Yesterday I upgraded my HTC Desire S to Sense 3.0 (Android 2.3.5) and apparently it has a new lock screen that displays incoming calls. Opening the lock screen will lead me to the "original" screen of incoming calls and answer the call. I can also see my toast on the initial call screen for just a second, before answering the call.

The toast I am showing uses a custom layout and it displays from the service. The service receives the intent from the broadcast receiver on an incoming call.

I use the following code to show my toast:

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.popup_toast, null); toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0); toast.setDuration(Toast.LENGTH_SHORT); toast.setView(layout); toast.show(); 

Is there a way to set the toast to appear on top of the new Sense 3.0 lock screen?

+6
source share
2 answers

I think the problem is a little wider. In my case, the HTC sense 3.0 lock screen does not allow the activity dialog to be displayed (like the Toast message). When the screen is unlocked, the dialog (an action launched from the background service) is displayed just fine. The only way to display a message on the HTC Touch screen lock is to use a notification - and many will agree that this is the recommended approach (for example, do not disturb the user with tooltips). The flaw in the notification order is that it will disappear after a second or two. Thus, for applications such as "Caller ID", the user must quickly pull HTC out of his pocket if he wants to see who is calling and what is not suitable for sure.

Perhaps the OpenSense SDK contains an API that allows you to display a message on the lock screen for a longer period. In my first glance, I found only "semantic" tabs ...

Someone suggested unlocking the phone “programmatically” and then displaying Toast or Dialog. This is not a “happy” decision - and not even sure if this is possible.

I know that my post is not a complete answer, but I hope that it will give more information about the problem of showing messages on the HTC 3.0 lock screen.

+2
source

use below code

 LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.listitems, null); Toast toastView = new Toast(getApplicationContext()); toastView.setView(layout); toastView.setDuration(Toast.LENGTH_LONG); toastView.setGravity(Gravity.CENTER, 0,0); toastView.show(); it working fine for me 
0
source

Source: https://habr.com/ru/post/902738/


All Articles