Skip to content

Commit

Permalink
begin work on a background camera using overlay from the service
Browse files Browse the repository at this point in the history
  • Loading branch information
n8fr8 committed Jul 3, 2018
1 parent ea7facf commit 13fd4c9
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ public void detect() {

});
}
else
{

}

}

Expand Down
43 changes: 43 additions & 0 deletions src/main/java/org/havenapp/main/service/BackgroundCamera.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.havenapp.main.service;

import android.content.Context;
import android.graphics.PixelFormat;
import android.view.Gravity;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.WindowManager;

public class BackgroundCamera {

private void startCamera (Context context)
{

// Create new SurfaceView, set its size to 1x1, move it to the top left corner and set this service as a callback
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
SurfaceView surfaceView = new SurfaceView(context);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
1, 1,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
PixelFormat.TRANSLUCENT
);
layoutParams.gravity = Gravity.LEFT | Gravity.TOP;
windowManager.addView(surfaceView, layoutParams);
surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {

}

@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {

}

@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {

}
});
}
}

0 comments on commit 13fd4c9

Please sign in to comment.