List of usage examples for android.content Context SENSOR_SERVICE
String SENSOR_SERVICE
To view the source code for android.content Context SENSOR_SERVICE.
Click Source Link
From source file:com.intel.xdk.accelerometer.Accelerometer.java
@Override public void initialize(CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView); //get convenience reference to activity activity = cordova.getActivity();//from w ww. j a v a 2 s . c o m sensorManager = (SensorManager) activity.getSystemService(Context.SENSOR_SERVICE); }
From source file:uk.ac.horizon.ubihelper.service.channel.SensorChannel.java
public SensorChannel(String name, Service service, int sensorType) { super(name);/*from w ww. j ava 2 s .c o m*/ mSensorManager = (SensorManager) service.getSystemService(Context.SENSOR_SERVICE); if (mSensorManager != null) { mSensor = mSensorManager.getDefaultSensor(sensorType); if (mSensor == null) Log.w(TAG, "No sensor found for " + name + " (type " + sensorType + ")"); } }
From source file:com.example.android.camera2basic.CameraActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_camera); checkPlayServices(this); mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION); Intent intent = new Intent(this.getApplicationContext(), LocationService.class); startService(intent);// ww w. j ava 2s.co m camerafragment = Camera2BasicFragment.newInstance(); if (null == savedInstanceState) { getFragmentManager().beginTransaction().replace(R.id.container, camerafragment).commit(); } }
From source file:com.example.android.pdfrendererbasic.PdfRendererFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // Retain view references. mPdfView = (PDFView) view.findViewById(R.id.pdfView); mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); accelerometerEventListener = new AccelerometerEventListener(mPdfView); mSensorManager.registerListener(accelerometerEventListener, mSensor, 20 * 1000);//20ms mPageIndex = 0;//from w ww . ja va2s .co m // If there is a savedInstanceState (screen orientations, etc.), we restore the page index. if (null != savedInstanceState) { mPageIndex = savedInstanceState.getInt(STATE_CURRENT_PAGE_INDEX, 0); } }
From source file:com.phonegap.AccelListener.java
/** * Sets the context of the Command. This can then be used to do things like * get file paths associated with the Activity. * /* w ww.j a v a 2 s .co m*/ * @param ctx The context of the main Activity. */ public void setContext(PhonegapActivity ctx) { super.setContext(ctx); this.sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE); }
From source file:com.tritop.androsense2.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ((AndrosensApp) this.getApplication()) .setSensorManager((SensorManager) getSystemService(Context.SENSOR_SERVICE)); ((AndrosensApp) getApplication())/*w w w. jav a 2s.c om*/ .setSensorList(((AndrosensApp) getApplication()).getSensorManager().getSensorList(Sensor.TYPE_ALL)); // Create the adapter that will return a fragment for each of the three // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(this); }
From source file:rus.cpuinfo.AndroidDepedentModel.SensorsInfo.java
public SensorsInfo(Context context) { super(context); mSensorManager = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE); }
From source file:org.zywx.wbpalmstar.plugin.uexaudio.EUExAudio.java
public static void onActivityPause(Context context) { BDebug.i(tag, "onActivityPause"); if (sensorEventListener != null) { SensorManager mSensorManager = (SensorManager) context.getApplicationContext() .getSystemService(Context.SENSOR_SERVICE); mSensorManager.unregisterListener(sensorEventListener); }/* ww w .j a v a 2 s.co m*/ }
From source file:org.sociotech.fishification.ui.fragments.FeedFishFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { m_view = inflater.inflate(R.layout.fragment_fish_feed, container, false); m_defaultBackground = m_view.getBackground(); // Init Gallery Gallery gallery = (Gallery) m_view.findViewById(R.id.fishBoxGallery); gallery.setAdapter(new FishFoodBoxAdapter(m_view.getContext())); // Init Sensor Context context = m_view.getContext(); m_sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); m_lastUpdate = System.currentTimeMillis(); return m_view; }
From source file:nl.endran.scrumpoker.fragments.cardselection.QuickSettingsFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_selection_background, container, false); ButterKnife.bind(this, rootView); App app = (App) rootView.getContext().getApplicationContext(); tracking = app.getTracking();//from www. j av a 2 s. c o m fab.setVisibility(View.INVISIBLE); shakeManager = new ShakeManager( (SensorManager) rootView.getContext().getSystemService(Context.SENSOR_SERVICE)); return rootView; }