0
그래서 저는 삼성의 태블릿에서 전화 장치로 테스트 한 앱을 테스트했습니다. accelermoter 데이터를 기반으로방향 태블릿 대 전화
응용 프로그램 업데이트 그래픽과 내가 태블릿에 세로로 가로 치료되는 것으로 나타났습니다 .. 자연스럽게 세로 모드 장치의 미세 ..
내가 그래서이 ajust 수있는 방법 어떤 아이디어 모두에서 작동합니다
public class ARLaunch extends Activity {
/** Open Camera View **/
private CamLayer camPreview;
/** Open Camera View **/
private GLLayer glView;
private WakeLock mWakeLock;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// requesting to turn the title OFF
requestWindowFeature(Window.FEATURE_NO_TITLE);
// making it full screen
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
//Set Screen Orientation
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
try{
final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
this.mWakeLock = pm.newWakeLock(
PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "My Tag");
//Create Intance of Camera
camPreview = new CamLayer(this.getApplicationContext());
//Create Instance of OpenGL
glView = new GLLayer(this);
//FrameLayOut for holding everything
FrameLayout frame = new FrameLayout(this);
// set as main view
setContentView(frame);
// add Camera to view
frame.addView(camPreview, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
frame.addView(glView);
} catch(Exception e){}
}
/** Remember to resume the glSurface */
@Override
protected void onResume() {
super.onResume();
try{
this.mWakeLock.acquire();
} catch (Exception ex){}
glView.onResume();
glView.setZOrderOnTop(true);
}
/** Also pause the glSurface */
@Override
protected void onPause() {
super.onPause();
try{
this.mWakeLock.release();
} catch (Exception ex){}
glView.onPause();
}
public void displayOri(float acc, float ori){
}
}
public class PhoneOrientation {
private SensorManager sensorMan;
private Sensor sensorAcce;
private Sensor sensorMagn;
private SensorEventListener listener;
private float matrix[]=new float[16];
private Context ctx;
public PhoneOrientation(Context context) {
ctx = context;
}
public void start(Context context) {
listener = new SensorEventListener() {
private float orientation[]=new float[3];
private float acceleration[]=new float[3];
public void onAccuracyChanged(Sensor arg0, int arg1){}
public void onSensorChanged(SensorEvent evt) {
int type=evt.sensor.getType();
//Smoothing the sensor data a bit seems like a good idea.
if (type == Sensor.TYPE_MAGNETIC_FIELD) {
orientation[0]=(orientation[0]*1+evt.values[0])*0.5f;
orientation[1]=(orientation[1]*1+evt.values[1])*0.5f;
orientation[2]=(orientation[2]*1+evt.values[2])*0.5f;
} else if (type == Sensor.TYPE_ACCELEROMETER) {
acceleration[0]=(acceleration[0]*2+evt.values[0])*0.33334f;
acceleration[1]=(acceleration[1]*2+evt.values[1])*0.33334f;
acceleration[2]=(acceleration[2]*2+evt.values[2])*0.33334f;
}
if ((type==Sensor.TYPE_MAGNETIC_FIELD) || (type==Sensor.TYPE_ACCELEROMETER)) {
float newMat[]=new float[16];
//Toast toast = Toast.makeText(ctx.getApplicationContext(), "accel", Toast.LENGTH_SHORT);
//toast.show();
SensorManager.getRotationMatrix(newMat, null, acceleration, orientation);
SensorManager.remapCoordinateSystem(newMat,
SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X,
newMat);
matrix=newMat;
}
}
};
sensorMan = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
sensorAcce = sensorMan.getSensorList(Sensor.TYPE_ACCELEROMETER).get(0);
sensorMagn = sensorMan.getSensorList(Sensor.TYPE_MAGNETIC_FIELD).get(0);
sensorMan.registerListener(listener, sensorAcce, SensorManager.SENSOR_DELAY_GAME);
sensorMan.registerListener(listener, sensorMagn, SensorManager.SENSOR_DELAY_GAME);
}
public float[] getMatrix() {
return matrix;
}
public void finish() {
sensorMan.unregisterListener(listener);
}
}
흠, 그 기사가 정말로 나를 돕는 지 모르겠다. 내 전화 오리엔테이션 수업을 보여주기 위해 위의 코드를 편집했다. – erik
실제로 감사하고있다 !! – erik
및 웨이크 잠금 장치는 절대로 작동하지 않습니다.하지만 솔루션은 .. 감사합니다. – erik