Screen Stream Over HTTP.
The link for the same is https://apkpure.com/screen-stream-over-http/info.dvkr.screenstream
package com.example.idk;
import android.content.Context;
import android.graphics.Color;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.support.constraint.ConstraintLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
private SensorManager sensorManager;
private final float[] accelerometerReading = new float[3];
private final float[] magnetometerReading = new float[3];
float pitchMin = 180;
float pitchMax = 0;
float rollMin = 180;
float rollMax = 0;
float currentPitch = 0;
float currentRoll = 0;
private Sensor sensor;
private final float[] rotationMatrix = new float[9];
private final float[] orientationAngles = new float[3];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn = findViewById(R.id.button2);
final ConstraintLayout myscreen = findViewById(R.id.myscreen);
sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
sensor = sensorManager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateOrientationAngles();
}
});
Button btn2=findViewById(R.id.button3);
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateOrientationAnglesCurrent();
if(pitchMin <= currentPitch && currentPitch <= pitchMax && rollMax <= currentRoll && currentRoll <= rollMax)
myscreen.setBackgroundColor(Color.RED);
}
});
}
public void updateOrientationAngles() {
// Update rotation matrix, which is needed to update orientation angles.
SensorManager.getRotationMatrix(rotationMatrix, null,
accelerometerReading, magnetometerReading);
// "mRotationMatrix" now has up-to-date information.
SensorManager.getOrientation(rotationMatrix, orientationAngles);
if(pitchMin > orientationAngles[1])
pitchMin = orientationAngles[1];
if(pitchMax < orientationAngles[1])
pitchMax = orientationAngles[1];
if(rollMin > orientationAngles[2])
rollMin = orientationAngles[2];
if(rollMax < orientationAngles[2])
rollMax = orientationAngles[2];
// "mOrientationAngles" now has up-to-date information.
}
public void updateOrientationAnglesCurrent() {
// Update rotation matrix, which is needed to update orientation angles.
SensorManager.getRotationMatrix(rotationMatrix, null,
accelerometerReading, magnetometerReading);
// "mRotationMatrix" now has up-to-date information.
SensorManager.getOrientation(rotationMatrix, orientationAngles);
currentPitch = orientationAngles[1];
currentRoll = orientationAngles[2];
// "mOrientationAngles" now has up-to-date information.
}
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tap to calibrate"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Calibrate"
tools:layout_editor_absoluteX="161dp"
tools:layout_editor_absoluteY="435dp" />
</android.support.constraint.ConstraintLayout>