Example usage for android.view WindowManager addView

List of usage examples for android.view WindowManager addView

Introduction

In this page you can find the example usage for android.view WindowManager addView.

Prototype

public void addView(View view, ViewGroup.LayoutParams params);

Source Link

Document

Assign the passed LayoutParams to the passed View and add the view to the window.

Usage

From source file:saschpe.android.textoverlay.service.TextOverlayService.java

@Override
public void onCreate() {
    Log.d(TAG, "onCreate: Starting service");
    super.onCreate();

    int colorId = getResources().getIdentifier("red", "color", getPackageName());

    textView = new TextView(this);
    textView.setTextColor(ContextCompat.getColor(this, colorId));
    textView.setText(lastUsedOverlayText);

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
            PixelFormat.TRANSLUCENT);/* w  w w  . jav a  2  s.co m*/
    params.gravity = Gravity.CENTER | Gravity.BOTTOM;
    params.setTitle("Text Overlay");
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    wm.addView(textView, params);

    LocalBroadcastManager.getInstance(this).registerReceiver(messageReceiver,
            new IntentFilter(ACTION_SET_TEXT));
}

From source file:uk.co.alt236.floatinginfo.provider.generalinfo.GeneralInfoProvider.java

private void createSystemWindow() {
    final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, 0,
            PixelFormat.TRANSLUCENT);//from   ww  w .  j av a2 s.  c  o  m
    final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    wm.addView(mUiManager.getView(), lp);
}

From source file:jp.morihirosoft.twwb.TwwbService.java

private void blockScreen() {
    if (DEBUG)//www .  j  a v a 2 s  .  c  o  m
        Log.d(TAG, "blockScreen");
    if (mBlockScreen == null) {
        if (mIsCalling) {
            return;
        }
        if (SystemClock.uptimeMillis() - mStartTime < mSettings.getPending() * 1000) {
            return;
        }
        mBlockScreen = LayoutInflater.from(this).inflate(R.layout.view_block, null);
        int alpha = 255 * mSettings.getAlpha() / 100;
        mBlockScreen.setBackgroundColor(Color.argb(alpha, 0, 0, 0));
        ((ImageView) mBlockScreen.findViewById(R.id.img_logo)).setAlpha(alpha);
        ((Button) mBlockScreen.findViewById(R.id.btn_unblock)).setOnClickListener(this);

        WindowManager.LayoutParams params = new WindowManager.LayoutParams();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        params.height = WindowManager.LayoutParams.MATCH_PARENT;
        params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
        params.flags = 0;
        params.format = PixelFormat.TRANSLUCENT;

        WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
        wm.addView(mBlockScreen, params);
    }
}

From source file:de.localtoast.launchit.BackgroundService.java

@Override
public void onCreate() {
    super.onCreate();
    // initialize joda time library
    ResourceZoneInfoProvider.init(this);

    appListUpdater = new AppListUpdater();
    timer.scheduleAtFixedRate(appListUpdater, 0, 60000);

    initSidebar();//from   w  w  w. j  a va  2  s  . c  o  m
    initTouchArea();
    WindowManager.LayoutParams params = getTouchAreaLayoutParams();
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    wm.addView(touchArea, params);

    addNotificationIcon();
}

From source file:com.autoparts.buyers.activity.InquiryModelActivity.java

private void initOverlay() {
    letterListView = (MyLetterListView) findViewById(R.id.MyLetterListView);
    letterListView.setOnTouchingLetterChangedListener(new LetterListViewListener());
    overlayThread = new OverlayThread();
    handler = new Handler();

    LayoutInflater inflater = LayoutInflater.from(this);
    overlayView = inflater.inflate(R.layout.contact_overlay, null);
    overlay = (TextView) overlayView.findViewById(R.id.mTextView);
    overlayView.setVisibility(View.INVISIBLE);
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_APPLICATION,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
            PixelFormat.TRANSLUCENT);//from  w w  w.j ava 2s  .  com
    WindowManager windowManager = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
    windowManager.addView(overlayView, lp);
}

From source file:de.localtoast.launchit.BackgroundService.java

private void switchToTouchAreaPostAnimation() {
    WindowManager.LayoutParams params = getTouchAreaLayoutParams();
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    touchArea.setBackgroundColor(touchAreaColor);
    removeView();//from   w  ww. j a  v a  2  s. com
    wm.addView(touchArea, params);
}

From source file:de.localtoast.launchit.BackgroundService.java

private void refreshTouchArea() {
    WindowManager.LayoutParams params = getTouchAreaLayoutParams();
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    touchArea.setBackgroundColor(touchAreaColor);
    removeView();//from www.ja  v a 2s . com
    wm.addView(touchArea, params);
}

From source file:org.easyaccess.SwipingUtils.java

@Override
public void onResume() {
    super.onResume();
    // check if keyboard is connected or accessibility services are enabled
    if (Utils.isAccessibilityEnabled(getApplicationContext())
            || getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS) {
        TTS.speak(getResources().getString(R.string.appNameTalkBackFriendly));
    }/*from w w w  .ja  v a  2 s .com*/
    WindowManager windowManager = getWindowManager();
    LayoutInflater inflater = getLayoutInflater();
    LayoutParamsAndViewUtils layoutParamsAndView = ScreenCurtainFunctions.prepareForCurtainCheck(inflater);

    ScreenCurtainFunctions appState = ((ScreenCurtainFunctions) getApplicationContext());
    if (appState.getState() && !curtainSet) {
        curtainView = layoutParamsAndView.getView();
        windowManager.addView(curtainView, layoutParamsAndView.getLayoutParams());
        curtainSet = true;
    } else if (!appState.getState() && curtainSet) {
        windowManager.removeView(curtainView);
        curtainSet = false;
    }
}

From source file:com.cn21.speedtest.service.LogService.java

private void createSystemWindow() {
    final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            //WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
            0, PixelFormat.TRANSLUCENT);
    final LayoutInflater inflator = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    mLogListView = (ListView) inflator.inflate(R.layout.window_log, null);
    mLogBuffer = new LinkedList<LogLine>();
    mLogBufferFiltered = new LinkedList<LogLine>();
    mAdapter = new LogAdapter(this, mLogBufferFiltered);
    mLogListView.setAdapter(mAdapter);//from  ww  w. j  av a 2s .  c om
    wm.addView(mLogListView, lp);
}

From source file:com.readystatesoftware.ghostlog.LogService.java

private void createSystemWindow() {
    final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            //WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
            0, PixelFormat.TRANSLUCENT);

    final LayoutInflater inflator = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    mLogListView = (ListView) inflator.inflate(R.layout.window_log, null);
    setSystemViewBackground();//from   ww w.j a  va 2 s.c om
    mLogBuffer = new LinkedList<LogLine>();
    mLogBufferFiltered = new LinkedList<LogLine>();
    mAdapter = new LogAdapter(this, mLogBufferFiltered);
    mLogListView.setAdapter(mAdapter);
    wm.addView(mLogListView, lp);
}