قفل بخشی از صفحه نمایش در برنامه نویسی اندروید لطفا راهنمایی ام کنید

باسلام و عرض خسته نباشید و ممنون بابت راهنمایی های عالیتان

من یک کدی نوشتم که صفحه گوشی قفل میشه و در آن نمی توان هیچکاری کرد(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;
        }
    }
}

ممنون می شوم راهنمایی ام کنید

پاسخ ها

sokanacademy forum
کاربر سکان آکادمی 8 سال پیش

سلام،این قابلیت که بخشی از تاچ اسکرین را غیر فعال کنید،در اندروید این قابلیت

restricted profileنام دارد،برای ای او اس هم guided access نام داشت.

خوب به لینک های زیر رجوع شود

http://www.pcworld.com/article/2921718/2-easy-ways-to-child-proof-your-android-or-ios-device.html

http://www.wikihow.com/Use-Guided-Access-to-Disable-Parts-of-an-iPad-Screen

برای دسترسی به این چیزها در اپت باید ببنی داخل ای پی ای چگونه ودرچه حد این سرویس به شما دسترسی داده واستفاده کنید.

https://developer.android.com/about/versions/android-4.3.html#RestrictedProfiles

   
online-support-icon