question about sensor, orientationListener and light sensor

by birdy » Tue, 31 Mar 2009 03:10:52 GMT


Sponsored Links
 Hi all:

I studying set rotation by sensor now. I modify
mCurrentAppOrientation from SCREEN_ORIENTATION_UNSPECIFIED to
SCREEN_ORIENTATION_SENSOR. So OrientationListenerwill be enabled
at initial time. When enable mOrientationListener, sensorManager
should register a listener by registerListener and retuen true. But it
return false. I traced the code in SensorManager.java and found I do
not have a sensorList.
There are some questions:
1.How can I build up a sensor list (or I should ask : How can I init
SensorManager or SensorService)?
2.When enable mOrientationListener, there is a parameter :
SENSOR_ACCELEROMETER , is this parameter used for rotation detector?
What functin is SENSOR_ORIENTATION used for?.
3.Does android support SENSOR_LIGHT? If I want add light sensor, how
should I do?

Thanks a lot
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Confusion about using Camera to take pictures from my application

I'm trying to do this too, except I want a full-sized picture.  I have
it working.  I'm using your code, but without all the extras (maybe
those extras are causing your error?)  My code:

File tmpFile = new File(Environment.getExternalStorageDirectory(),
                        "tmp_" + String.valueOf(System.currentTimeMillis()) + 
".jpg");
Intent imgCapture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
imgCapture.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tmpFile));

// in the activity result:
if (resultCode == Activity.RESULT_CANCELED) {
        return;
}
try {
        imageView.setImageBitmap(BitmapFactory.decodeStream(new
FileInputStream(tmpFile)));
} catch (Exception e) {
        Log.e(Constants.LOG_TAG, "Unable to load image content", e);
}
tmpFile.delete();

One problem with this is that my app doesn't have permission to delete
the temp file.  I can't point the camera to my app's files/ directory
because the Camera activity doesn't have access to my files.  Do you
know how to provide a content provider URI that both activities would
have read/write access to?  I haven't had the chance to read much
about content providers yet...

The other problem is, this will only return a 512x384 image.  Without
the EXTRA_OUTPUT the image returned is even smaller (192x256).  For
you, this might be okay.  You can probably scale the image down to
64x64 using some Bitmap or Matrix methods (not sure how to do that).

For me, this is unacceptable, and from what I can tell the only way to
get a full size image is to use the Camera API and ditch the Camera
activity altogether :-(.  See the comments here:
http://code.google.com/p/android/issues/detail?id=1480

Btw, if you are using the external storage to store the picture, you
may want to check that it exists first:

String storageState = Environment.getExternalStorageState();
if (!Environment.MEDIA_MOUNTED.equals(storageState)) {
        // If there's no storage media, our intents won't work.
        return;
}

Let me know if you find anything more!  I'm going to keep looking...

To everyone else reading this:
Is there a way to get a full sized picture from the Camera activity?
Or do I have to roll my own?  That would be SUPER lame.  If I do have
to make my own activity, can someone point me to some example code?
Thanks in advance!


-- Neil



>  Ray

2. XML Layout ... proving difficult to make work

I have this little excerpt nestled within another Linear Layout.
I simply want to have a progress wheel with text to its right,
situated near each other and centered within a dark band spanning the
length of the display.

However, when this is set visible, the little wheel is shown but the
text is not.

What is wrong?

<LinearLayout
                        android:id="@+id/main_status_layout"
                        android:padding="15dip"
                        android:orientation="vertical"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:background="@android:drawable/alert_dark_frame">

                          <ProgressBar
                                android:id="@+id/main_progress"
                                android:textSize="6pt"
                                style="?android:attr/progressBarStyleSmall"
                                android:textColor="#000000"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"/>

                           <TextView
                                  android:id="@+id/main_status_text"
                                  android:layout_gravity="center_vertical"
                                  android:textSize="8pt"
                                  android:textColor="#ffffff"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  />
          </LinearLayout>

tone

3. RPC in Android

4. Custom extensions

5. Generating Entropy (Kernel level)

6. findViewById doesnt work directly after inflate() !! Why?

7. ATTENTION ANDROID TEAM: Take back control of Android.