List of usage examples for android.hardware SensorManager SENSOR_DELAY_UI
int SENSOR_DELAY_UI
To view the source code for android.hardware SensorManager SENSOR_DELAY_UI.
Click Source Link
From source file:com.sir_m2x.messenger.activities.ChatWindowPager.java
@Override protected void onResume() { isActive = true;// www . j ava 2 s .c om registerReceiver(this.listener, new IntentFilter(MessengerService.INTENT_IS_TYPING)); registerReceiver(this.listener, new IntentFilter(MessengerService.INTENT_NEW_IM)); registerReceiver(this.listener, new IntentFilter(MessengerService.INTENT_DESTROY)); registerReceiver(this.listener, new IntentFilter(MessengerService.INTENT_BUZZ)); this.sensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE); this.mAccel = 0.00f; this.mAccelCurrent = SensorManager.GRAVITY_EARTH; this.mAccelLast = SensorManager.GRAVITY_EARTH; if (Preferences.shake2Buzz) this.sensorMgr.registerListener(this, this.sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_UI); super.onResume(); }
From source file:com.coincide.alphafitness.ui.Fragment_Main.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { // final View v = inflater.inflate(R.layout.fragment_overview, null); View v = null;//from w ww.jav a 2 s .c o m v = inflater.inflate(R.layout.fragment_main, container, false); // stepsView = (TextView) v.findViewById(R.id.steps); // totalView = (TextView) v.findViewById(R.id.total); totalView = (TextView) v.findViewById(R.id.tv_distance); tv_avg = (TextView) v.findViewById(R.id.tv_avg); tv_max = (TextView) v.findViewById(R.id.tv_max); tv_min = (TextView) v.findViewById(R.id.tv_min); // averageView = (TextView) v.findViewById(R.id.average); /* pg = (PieChart) v.findViewById(R.id.graph); // slice for the steps taken today sliceCurrent = new PieModel("", 0, Color.parseColor("#99CC00")); pg.addPieSlice(sliceCurrent); // slice for the "missing" steps until reaching the goal sliceGoal = new PieModel("", Fragment_Settings.DEFAULT_GOAL, Color.parseColor("#CC0000")); pg.addPieSlice(sliceGoal); pg.setOnClickListener(new OnClickListener() { @Override public void onClick(final View view) { showSteps = !showSteps; stepsDistanceChanged(); } }); pg.setDrawValueInPie(false); pg.setUsePieRotation(true); pg.startAnimation(); */ /* * MainActivity * */ // Always cast your custom Toolbar here, and set it as the ActionBar. Toolbar tb = (Toolbar) v.findViewById(R.id.toolbar); ((AppCompatActivity) getActivity()).setSupportActionBar(tb); TextView tv_tb_center = (TextView) tb.findViewById(R.id.tv_tb_center); tv_tb_center.setText("ALPHA FITNESS"); /* ImageButton imgbtn_cart = (ImageButton) tb.findViewById(R.id.imgbtn_cart); imgbtn_cart.setVisibility(View.GONE);*/ tb.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().onBackPressed(); } }); // Get the ActionBar here to configure the way it behaves. final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar(); //ab.setHomeAsUpIndicator(R.drawable.ic_menu); // set a custom icon for the default home button ab.setDisplayShowHomeEnabled(false); // show or hide the default home button ab.setDisplayHomeAsUpEnabled(false); ab.setDisplayShowCustomEnabled(false); // enable overriding the default toolbar layout ab.setDisplayShowTitleEnabled(false); // disable the default title element here (for centered title) tv_duration = (TextView) v.findViewById(R.id.tv_duration); startButton = (Button) v.findViewById(R.id.btn_start); if (isButtonStartPressed) { startButton.setBackgroundResource(R.drawable.btn_stop_states); startButton.setText(R.string.btn_stop); try { SensorManager sm = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); sm.registerListener(this, sm.getDefaultSensor(Sensor.TYPE_STEP_COUNTER), SensorManager.SENSOR_DELAY_UI, 0); } catch (Exception e) { e.printStackTrace(); } } else { try { SensorManager sm = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); sm.unregisterListener(this); } catch (Exception e) { e.printStackTrace(); } } startButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { onSWatchStart(); } }); iv_profile = (ImageView) v.findViewById(R.id.iv_profile); iv_profile.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Database db = Database.getInstance(getActivity()); tot_workouts = db.getTotWorkouts(); tot_workTime = db.getWorkTime(); Log.e("Tot Work time", tot_workTime + ""); // int seconds = (int) (tot_workTime / 1000) % 60; // int minutes = (int) ((tot_workTime / (1000 * 60)) % 60); long millis = tot_workTime * 100; // obtained from StopWatch long hours = (millis / 1000) / 3600; long minutes = (millis / 1000) / 60; long seconds = (millis / 1000) % 60; db.close(); Intent i = new Intent(getActivity(), ProfileActivity.class); i.putExtra("avg_distance", avg_distance + ""); i.putExtra("all_distance", all_distance + ""); i.putExtra("avg_time", tv_duration.getText().toString()); i.putExtra("all_time", tv_duration.getText().toString()); i.putExtra("avg_calories", avg_calories + ""); i.putExtra("all_calories", all_calories + ""); i.putExtra("tot_workouts", tot_workouts + ""); i.putExtra("avg_workouts", tot_workouts + ""); i.putExtra("tot_workTime", hours + " hrs " + minutes + " min " + seconds + " sec"); startActivity(i); } }); // Getting Google Play availability status int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity().getBaseContext()); if (status != ConnectionResult.SUCCESS) { // Google Play Services are not available int requestCode = 10; Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, getActivity(), requestCode); dialog.show(); } else { // Google Play Services are available // Initializing mMarkerPoints = new ArrayList<LatLng>(); // Getting reference to SupportMapFragment of the activity_main // SupportMapFragment fm = (SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map); MapFragment fm = (MapFragment) getActivity().getFragmentManager().findFragmentById(R.id.map); // Getting Map for the SupportMapFragment mGoogleMap = fm.getMap(); // Enable MyLocation Button in the Map mGoogleMap.setMyLocationEnabled(true); // Getting LocationManager object from System Service LOCATION_SERVICE LocationManager locationManager = (LocationManager) getActivity().getSystemService(LOCATION_SERVICE); // Creating a criteria object to retrieve provider Criteria criteria = new Criteria(); // Getting the name of the best provider String provider = locationManager.getBestProvider(criteria, true); // Getting Current Location From GPS Location location; if (provider != null) { if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return null; } location = locationManager.getLastKnownLocation(provider); locationManager.requestLocationUpdates(provider, 20000, 0, this); } else { location = new Location(""); location.setLatitude(0.0d);//your coords of course location.setLongitude(0.0d); } if (location != null) { onLocationChanged(location); } // Setting onclick event listener for the map mGoogleMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng point) { // Already map contain destination location if (mMarkerPoints.size() > 1) { FragmentManager fm = getActivity().getSupportFragmentManager(); mMarkerPoints.clear(); mGoogleMap.clear(); LatLng startPoint = new LatLng(mLatitude, mLongitude); drawMarker(startPoint); } drawMarker(point); // Checks, whether start and end locations are captured if (mMarkerPoints.size() >= 2) { LatLng origin = mMarkerPoints.get(0); LatLng dest = mMarkerPoints.get(1); // Getting URL to the Google Directions API String url = getDirectionsUrl(origin, dest); DownloadTask downloadTask = new DownloadTask(); // Start downloading json data from Google Directions API downloadTask.execute(url); } } }); fixedCentreoption = new MarkerOptions(); mGoogleMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition position) { // TODO Auto-generated method stub // Get the center of the Map. mGoogleMap.clear(); LatLng centerOfMap = mGoogleMap.getCameraPosition().target; // Update your Marker's position to the center of the Map. fixedCentreoption.position(centerOfMap); // mGoogleMap.addMarker(fixedCentreoption); // drawMarker(centerOfMap); LatLng origin = new LatLng(0.0d, 0.0d); ; if (mMarkerPoints.size() > 0) { origin = mMarkerPoints.get(0); } // LatLng dest = mMarkerPoints.get(1); LatLng dest = centerOfMap; // Getting URL to the Google Directions API String url = getDirectionsUrl(origin, dest); DownloadTask downloadTask = new DownloadTask(); // Start downloading json data from Google Directions API downloadTask.execute(url); GPSTracker gpsTracker = new GPSTracker(getActivity().getApplicationContext()); // String Addrs = gpsTracker.location(); Addrs = gpsTracker.locationBasedOnLatlng(centerOfMap); // Toast.makeText(getApplicationContext(), Addrs, Toast.LENGTH_LONG).show(); } }); } SharedPreferences sharedpreferences = getActivity().getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE); mBodyWeight = Float.parseFloat(sharedpreferences.getString(sp_weight, "50")); return v; }
From source file:ngoc.com.pedometer.ui.Fragment_Overview.java
private void startCountOrPause() { SensorManager sm = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); if (getActivity().getSharedPreferences("pedometer", Context.MODE_PRIVATE).contains("pauseCount")) { // currently paused -> now resumed sm.registerListener(this, sm.getDefaultSensor(Sensor.TYPE_STEP_COUNTER), SensorManager.SENSOR_DELAY_UI, 0);//from w w w.j a va 2s . c o m } else { sm.unregisterListener(this); } getActivity().startService( new Intent(getActivity(), SensorListener.class).putExtra("action", SensorListener.ACTION_PAUSE)); }
From source file:com.example.haber.ui.activity.TabbedActivity.java
private void switchStatus() { if (currentStatus == COMMON_STATUS) { if (sensorManager != null) sensorManager.unregisterListener(sensorListener, sensor); if (tbDial.isChecked()) tbDial.setChecked(false);/*from w ww.j a va 2 s . c om*/ if (tbConsoleControl.isChecked()) tbConsoleControl.setChecked(false); if (layoutDial.getVisibility() != View.GONE) { Animation animation = new TranslateAnimation(0, 0, 0, 200 * metrics.density + 0.5f + displayHeight * 0.32f); animation.setDuration(200); layoutDial.startAnimation(animation); layoutDial.setVisibility(View.GONE); } if (containConsoleControl.getVisibility() != View.GONE) containConsoleControl.setVisibility(View.GONE); if (containViewPager.getVisibility() == View.GONE) containViewPager.setVisibility(View.VISIBLE); } else if (currentStatus == DIAL_STATUS) { if (!tbDial.isChecked()) tbDial.setChecked(true); if (tbConsoleControl.isChecked()) tbConsoleControl.setChecked(false); if (containConsoleControl.getVisibility() != View.GONE) containConsoleControl.setVisibility(View.GONE); if (containViewPager.getVisibility() != View.VISIBLE) containViewPager.setVisibility(View.VISIBLE); if (layoutDial.getVisibility() == View.GONE) { layoutDial.setVisibility(View.VISIBLE); Animation animation = new TranslateAnimation(0, 0, 200 * metrics.density + 0.5f + displayHeight * 0.32f, 0); animation.setDuration(300); layoutDial.startAnimation(animation); } sensorManager.unregisterListener(sensorListener, sensor); } else { sensorManager.registerListener(sensorListener, sensor, SensorManager.SENSOR_DELAY_UI); if (tbDial.isChecked()) tbDial.setChecked(false); if (!tbConsoleControl.isChecked()) tbConsoleControl.setChecked(true); if (layoutDial.getVisibility() != View.GONE) { Animation animation = new TranslateAnimation(0, 0, 0, 200 * metrics.density + 0.5f + displayHeight * 0.32f); animation.setDuration(200); layoutDial.startAnimation(animation); layoutDial.setVisibility(View.GONE); } if (containViewPager.getVisibility() != View.GONE) containViewPager.setVisibility(View.GONE); if (containConsoleControl.getVisibility() == View.GONE) containConsoleControl.setVisibility(View.VISIBLE); } }
From source file:net.nanocosmos.bintu.demo.encoder.activities.StreamActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Window window = getWindow();//from w w w . j a va 2s . co m window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_streamer); ViewGroup.LayoutParams param = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); surface = new StreamPreview(this); surface.setLayoutParams(param); MultiSurfaceTextureListenerImpl multiSurfaceTextureListener = new MultiSurfaceTextureListenerImpl(); multiSurfaceTextureListener.addListener(this); surface.setSurfaceTextureListener(multiSurfaceTextureListener); FrameLayout frameLayout = (FrameLayout) findViewById(R.id.surfaceFrame); frameLayout.addView(surface); isDefaultOrientationLandscape = (RotationHelper .getDeviceDefaultOrientation(this) == android.content.res.Configuration.ORIENTATION_LANDSCAPE); String[] lic_exp = Configuration.NANOSTREAM_LICENSE.split(":adr:"); if (lic_exp.length > 1) { lic_exp = lic_exp[1].split(":"); if (lic_exp.length > 1) { lic_exp = lic_exp[0].split(","); if (lic_exp.length > 1) { String year = lic_exp[1].substring(0, 4); String month = lic_exp[1].substring(4, 6); String day = lic_exp[1].substring(6, 8); Toast.makeText(getApplicationContext(), "Licence expires on: " + month + "/" + day + "/" + year, Toast.LENGTH_LONG).show(); } } } Intent intent = getIntent(); serverUrl = intent.getStringExtra(Constants.KEY_SERVER_URL); streamName = intent.getStringExtra(Constants.KEY_STREAM_NAME); webPlayoutUrl = intent.getStringExtra(Constants.KEY_WEB_PLAYOUT); videoBitrate = intent.getIntExtra(Constants.KEY_BITRATE, videoBitrate); streamVideo = intent.getBooleanExtra(Constants.KEY_VIDEO_ENABLED, true); streamAudio = intent.getBooleanExtra(Constants.KEY_AUDIO_ENABLED, true); logEnabled = intent.getBooleanExtra(Constants.KEY_LOG_ENABLED, true); if (null == webPlayoutUrl || webPlayoutUrl.isEmpty()) { webPlayoutUrl = "http://www.nanocosmos.net/nanostream/live.html?id=" + serverUrl + "/" + streamName; } qualityView = (LinearLayout) findViewById(R.id.qualityView); outputBitrate = (TextView) findViewById(R.id.outputBitrateText); bufferFillness = (TextView) findViewById(R.id.bufferfillnessText); bitrate = (TextView) findViewById(R.id.bitrateText); framerate = (TextView) findViewById(R.id.framerateText); streamToggle = (ImageButton) findViewById(R.id.btnToogleStream); orientation = new CustomOrientationEventListener(this, SensorManager.SENSOR_DELAY_UI); orientation.enable(); mHandler = new Handler(); sendStreamOrientationHandler = new Handler(); }
From source file:edu.sfsu.csc780.chathub.ui.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); DesignUtils.applyColorfulTheme(this); setContentView(R.layout.activity_main); final Context context = this; soundPreference = this.getString(R.string.play_sounds); mSentSound = MediaPlayer.create(context, R.raw.sentmessage); mStartRecordSound = MediaPlayer.create(context, R.raw.recording_beep); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); // Set default username is anonymous. mUsername = ANONYMOUS;// w w w . j a v a 2s .co m //Initialize Auth mAuth = FirebaseAuth.getInstance(); mUser = mAuth.getCurrentUser(); if (mUser == null) { startActivity(new Intent(this, SignInActivity.class)); finish(); return; } else { mUsername = mUser.getDisplayName(); if (mUser.getPhotoUrl() != null) { mPhotoUrl = mUser.getPhotoUrl().toString(); } } mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API).build(); // Initialize ProgressBar and RecyclerView. mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mMessageRecyclerView = (RecyclerView) findViewById(R.id.messageRecyclerView); mLinearLayoutManager = new LinearLayoutManager(this); mLinearLayoutManager.setStackFromEnd(true); mMessageRecyclerView.setLayoutManager(mLinearLayoutManager); mFirebaseAdapter = MessageUtil.getFirebaseAdapter(this, this, /* MessageLoadListener */ mLinearLayoutManager, mMessageRecyclerView, mImageClickListener); mMessageRecyclerView.setAdapter(mFirebaseAdapter); mProgressBar.setVisibility(ProgressBar.INVISIBLE); DesignUtils.setBackground(this); mMessageEditText = (EditText) findViewById(R.id.messageEditText); mMessageEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(MSG_LENGTH_LIMIT) }); mMessageEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { if (charSequence.toString().trim().length() > 0) { mSendButton.setEnabled(true); } else { mSendButton.setEnabled(false); } } @Override public void afterTextChanged(Editable editable) { } }); mSendButton = (FloatingActionButton) findViewById(R.id.sendButton); mSendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Send messages on click. //mMessageRecyclerView.scrollToPosition(0); ChatMessage chatMessage = new ChatMessage(mMessageEditText.getText().toString(), mUsername, mPhotoUrl); MessageUtil.send(chatMessage); if (mSharedPreferences.getBoolean(soundPreference, true)) { mSentSound.start(); } mMessageEditText.setText(""); } }); mImageButton = (ImageButton) findViewById(R.id.shareImageButton); mImageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pickImage(); } }); mLocationButton = (ImageButton) findViewById(R.id.locationButton); mLocationButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //mLocationButton.setEnabled(false); featureFlag = 1; loadMap(); } }); mCameraButton = (ImageButton) findViewById(R.id.cameraButton); mCameraButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dispatchTakePhotoIntent(); } }); mVideoButton = (ImageButton) findViewById(R.id.videoButton); mVideoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dispatchRecordVideoIntent(); } }); mVoiceMessageButton = (ImageButton) findViewById(R.id.shareVoiceMessage); mVoiceMessageButton.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: if (mSharedPreferences.getBoolean(soundPreference, true)) { mStartRecordSound.start(); } while (mStartRecordSound.isPlaying()) ; startRecording(); break; case MotionEvent.ACTION_UP: stopRecording(); if (mSharedPreferences.getBoolean(soundPreference, true)) { mSentSound.start(); } break; } return false; } }); //Initialize the Accelerometer for Shake function mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); // Use the accelerometer. mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mShakeDetector = new ShakeDetector(); shakePreference = this.getString(R.string.shake_change_background); if (mSharedPreferences.getBoolean(shakePreference, true)) { //Shake to change bg mSensorManager.registerListener(mShakeDetector, mAccelerometer, SensorManager.SENSOR_DELAY_UI); mShakeDetector.setOnShakeListener(new ShakeDetector.OnShakeListener() { @Override public void onShake(int count) { // if(count > 2) DesignUtils.setRandomBackground(context); } }); } }
From source file:edu.sfsu.csc780.chathub.ui.MainActivity.java
@Override public void onResume() { super.onResume(); LocationUtils.startLocationUpdates(this); if (mSharedPreferences.getBoolean(shakePreference, true)) { mSensorManager.registerListener(mShakeDetector, mAccelerometer, SensorManager.SENSOR_DELAY_UI); }/* w ww.j a v a 2 s . c om*/ }
From source file:ngoc.com.pedometer.ui.Fragment_Overview.java
@Override public void onResume() { super.onResume(); // getActivity().getActionBar().setDisplayHomeAsUpEnabled(false); Database db = Database.getInstance(getActivity()); if (BuildConfig.DEBUG) db.logState();/*from w w w. ja va2s .c o m*/ // read todays offset todayOffset = db.getSteps(Util.getToday()); SharedPreferences prefs = getActivity().getSharedPreferences("pedometer", Context.MODE_PRIVATE); goal = prefs.getInt("goal", Fragment_Settings.DEFAULT_GOAL); since_boot = db.getCurrentSteps(); // do not use the value from the sharedPreferences int pauseDifference = since_boot - prefs.getInt("pauseCount", since_boot); // register a sensorlistener to live update the UI if a step is taken if (!prefs.contains("pauseCount")) { SensorManager sm = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); Sensor sensor = sm.getDefaultSensor(Sensor.TYPE_STEP_COUNTER); if (sensor == null) { new AlertDialog.Builder(getActivity()).setTitle(R.string.no_sensor) .setMessage(R.string.no_sensor_explain) .setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(final DialogInterface dialogInterface) { getActivity().finish(); } }).setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }).create().show(); } else { sm.registerListener(this, sensor, SensorManager.SENSOR_DELAY_UI, 0); } } since_boot -= pauseDifference; total_start = db.getTotalWithoutToday(); total_days = db.getDays(); db.close(); stepsDistanceChanged(); }
From source file:com.flat20.fingerplay.FingerPlayActivity.java
public boolean startSensors() { boolean retval = true; for (int i = 0; i < sensors.size(); i++) { boolean res = sensorManager.registerListener(this, sensors.get(i), SensorManager.SENSOR_DELAY_UI); retval = retval && res;// w w w. j a v a2 s . c o m } return retval; }
From source file:com.example.administrator.myapplication2._2_exercise._2_Status_heart.fragments.LeftFragment.java
@Override public void onResume() { super.onResume(); //? ? ?? ? ? if (mCompassEnabled) { mSensorManager.registerListener(mListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_UI); }//from w w w . j a v a 2 s.c o m }