Malik Kawee Malik Kawee - 9 days ago 4
Android Question

I want to create e view which has gesture overlay in it and this view can be called any where outside of an app.

I have created chathead that floats on the screen but how to call the view from it. Have been searching for this from long time.
want to make a view like this

this is the view I have been trying to make. it has gesture Overlay in itGesture Magic this app is using this view

Answer

I found the answer and thought to share with you guys hope it will help

        final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            900,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,


            PixelFormat.TRANSLUCENT);
    params.x=0;
    if (FloatDirections.y>700){
    params.y=FloatDirections.y-700;}
    else {
        params.y=0;
    }
    params.gravity= Gravity.TOP|Gravity.CENTER;
    serviceRunning=true;
    Toast.makeText(getApplicationContext(),String.valueOf(FloatDirections.x)+"  "+String.valueOf(FloatDirections.y),Toast.LENGTH_SHORT).show();
    wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    myView = inflater.inflate(R.layout.gesture_recognition, null);
    b11=(Button)myView.findViewById(R.id.newbtn);
    GestureOverlayView ov = (GestureOverlayView)myView.findViewById(R.id.gestures_overlay_float);
    ov.addOnGesturePerformedListener(this);

and then use OnGesturePerformed

   @Override
public void onGesturePerformed(GestureOverlayView gestureOverlayView, Gesture gesture) {
  //  Toast.makeText(getApplicationContext(),"hi",Toast.LENGTH_SHORT).show();
    mydatabase.execSQL("CREATE TABLE IF NOT EXISTS PackageName(GestureName VARCHAR,PackName VARCHAR,Action VARCHAR);");
    cursor=mydatabase.rawQuery("select * from PackageName",null);

    ArrayList<Prediction> predictions = store.recognize(gesture);
Comments