0

here is the service that i have called to display view above locked screen.i dont want to unlock lock screen i want something that whatsapp and skype use for their calling screen.such that screen is not unlocked.

public class Display extends Service {

private static WindowManager wm;
private static RelativeLayout ly;
private WindowManager.LayoutParams params;

@Override
public void onCreate() {/
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    LayoutInflater vi;
    vi = LayoutInflater.from(this);
    ly = (RelativeLayout) vi.inflate(R.layout.display, null);
    wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
    params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_ALERT |
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,

/*ALSO TRIED USING WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
 | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON*/

            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.RGBA_8888);

    params.gravity = Gravity.TOP | Gravity.LEFT;
    params.x = 0;
    params.y = 300;
    ly.setLayoutParams(params);
    TextView tv = (TextView) ly.findViewById(R.id.annotationTextView); 
    tv.setText("check");


    wm.addView(ly, params);

    return START_NOT_STICKY;
}
@Override
public IBinder onBind(Intent intent) {

    return null;
}
@Override
public void onDestroy() {
}

}

but the screen was appearing below locked screen.

atul
  • 56
  • 9

1 Answers1

-1
 params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
//          WindowManager.LayoutParams.TYPE_SYSTEM_ALERT |
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
            | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED,
            PixelFormat.RGBA_8888);

worked for me but i was not able to touch on it so still unsuccessful

atul
  • 56
  • 9