无法将我的窗口管理器屏幕放在android锁定屏幕上方(无需解锁设备))

时间:2015-12-31 06:52:45

标签: android android-windowmanager

这里是我已经调用以显示锁定屏幕上方视图的服务。我不想解锁锁定屏幕我想要一些whatsapp和skype用于他们的调用屏幕。这样屏幕没有解锁。

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() {
}

}

但屏幕出现在锁定屏幕下方。

1 个答案:

答案 0 :(得分:-1)

eamil-1@example.com
email-temp@example.com
exple@email.com
//... Can contain n number of email address...

为我工作,但我无法触及它,所以仍然不成功