-
-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
begin work on a background camera using overlay from the service
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,6 +157,10 @@ public void detect() { | |
|
||
}); | ||
} | ||
else | ||
{ | ||
|
||
} | ||
|
||
} | ||
|
||
|
43 changes: 43 additions & 0 deletions
43
src/main/java/org/havenapp/main/service/BackgroundCamera.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
|
||
} | ||
}); | ||
} | ||
} |