باسلام و عرض خسته نباشید و ممنون بابت راهنمایی های عالیتان
من یک کدی نوشتم که صفحه گوشی قفل میشه و در آن نمی توان هیچکاری کرد(lock screen) .حالا اگر بخواهم فقط یک بخش معین از صفحه قفل شود باید چه کار کنم.
زمانی که قفل می شود لمس صفحه کار نمی کند.
public class VirusService extends Service {
private static boolean viewAdded;
private long upTime;
private long downTime;
private long ellapseTime;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
addToWindow();
return super.onStartCommand(intent, flags, startId);
}
@Override
public IBinder onBind(Intent intent) {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
private void addToWindow() {
if (!viewAdded) {
final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams paramsNotification = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,// | WindowManager.LayoutParams.TYPE_PRIORITY_PHONE ,// this will intersect with the status bar but also needed to handle the click on the notification view!!!
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.OPAQUE);
paramsNotification.gravity = Gravity.LEFT | Gravity.TOP;
paramsNotification.windowAnimations = android.R.style.Animation_Dialog;
paramsNotification.setTitle("��� �� ���");
LayoutInflater inflator = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View view = inflator.inflate(R.layout.main, null, false);
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
downTime = System.currentTimeMillis();
return true;
}
if (event.getAction() == MotionEvent.ACTION_UP) {
upTime = System.currentTimeMillis();
ellapseTime = upTime - downTime;
if (ellapseTime > 4000) {
Log.d("XXX", "Removed successfully");
Toast.makeText(VirusService.this, getString(R.string.veil_lifted), 10).show();
wm.removeView(v);
viewAdded = false;
stopSelf();
}
}
return false; //To change body of implemented methods use File | Settings | File Templates.
}
});
wm.addView(view, paramsNotification);
Log.d("XXX", "Added successfully");
viewAdded = true;
}
}
}
ممنون می شوم راهنمایی ام کنید
پاسخ ها