views:

406

answers:

1

Hello, and thanks for helping. In my previous question I asked if System.currentTimeMillis() was buggy in Droid, and the answer was no.

I assume the problem I'm having is somewhere else. While I wait for my Droid lone-user to report if a test app works on his phone, I would like to post some relevant code here.

Please keep in mind that I removed everything in the code I thought would be irrelevant (posting the code leading to the first suspicious line in the log). I might have removed the code where the problem is, but I doubt it. It smells like a layout, not code, problem. I say this because (see last line, where the log is) the surface is 0.

Best regards, Ari.

MANIFEST

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
 <activity android:name=".BeMeBB" android:label="@string/app_name"
  android:screenOrientation="landscape">
  <intent-filter>
   <action android:name="android.intent.action.MAIN" />
   <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
 </activity>
 <activity android:name="BeMeBBPref" android:label="@string/app_name">
 </activity>
</application>
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="5" />
<supports-screens>
</supports-screens>

LAYOUT

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:paddingTop="0pt" android:orientation="vertical"
 android:layout_width="fill_parent" android:layout_height="fill_parent"
 android:gravity="bottom" android:background="#00000001">

 <android.view.SurfaceView android:id="@+id/preview_LAND"
  android:layout_width="fill_parent" android:layout_height="fill_parent"
  android:keepScreenOn="true" android:layout_margin="0pt">
 </android.view.SurfaceView>

 <LinearLayout android:orientation="vertical"
  android:layout_width="fill_parent" android:layout_height="fill_parent"
  android:layout_weight="1">

  <TextView android:id="@+id/ACCELERATION_LINE" android:text="0  2  4  6  8  10 12 14 16 18 20  "
   android:layout_width="wrap_content" android:layout_height="wrap_content"
   android:typeface="monospace" android:layout_weight="0"
   android:textSize="20dp" android:textStyle="bold" android:textColor="@color/white"
   android:layout_gravity="center_horizontal" android:paddingTop="0dp"
   android:paddingLeft="0dp" android:background="#66000000" />

  <TextView android:id="@+id/ACCELERATION" android:text="@string/Accelerometers"
   android:layout_width="wrap_content" android:layout_height="wrap_content"
   android:typeface="monospace" android:textStyle="bold"
   android:layout_weight="0" android:textSize="20dp" android:textColor="@color/white"
   android:layout_gravity="center_horizontal|top" android:paddingLeft="0dp"
   android:background="#66000000" />

  <LinearLayout android:orientation="horizontal"
   android:layout_width="fill_parent" android:layout_height="wrap_content"
   android:gravity="bottom" android:layout_weight="1">

   <Button android:id="@+id/SAVE_LAND" android:text="@string/Save"
    android:layout_width="wrap_content" android:gravity="left|bottom"
    android:layout_height="wrap_content" android:layout_weight="0"
    android:textSize="26dp" android:textColor="@color/black"
    android:padding="20dp" />
  </LinearLayout>
 </LinearLayout>
</RelativeLayout>

CODE

public class BeMeBB extends Activity implements OnClickListener, android.content.DialogInterface.OnClickListener, SensorEventListener {
 private SurfaceView preview=null;
 private SurfaceHolder previewHolder=null;

 SurfaceHolder.Callback surfaceCallback = new SurfaceHolder.Callback() {
  public void surfaceCreated(SurfaceHolder holder) {
   DoRecording();  
  } 
 }; // End SurfaceHolder.Callback surfaceCallback

 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  setContentView(R.layout.main_land);
  preview=(SurfaceView)findViewById(R.id.preview_LAND);
  previewHolder=preview.getHolder();
  previewHolder.addCallback(surfaceCallback);
  previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
 } // End OnCreate

 private void DoRecording() {
  m_worker.setSurfaceHolder(previewHolder);
 } // End DoRecording
} // End class

IN ANOTHER CLASS

public void setSurfaceHolder(SurfaceHolder previewHolder) { 
 m_previewHolder = previewHolder;
 m_surface = m_previewHolder.getSurface(); 
 Log.d("BeMeBB", "BeMeBBWorker m_surface="  + m_surface);
} //End  setSurfaceHolder

AND THE RESULT IN LOG (SURFACE IS NOT VALID):

11-19 17:58:13.171 D/BeMeBB  ( 1404): BeMeBBService m_surface=Surface(native-token=0)
A: 

Now it's confirmed, my lone Droid user sent back the 2 log files from:

  1. A test app using MediaRecorder.setPreviewDisplay (Surface sv). It REQUIRES use of getSurface, which crashes in API 5 on Droid phone.

  2. A test app using Camera.setPreviewDisplay(SurfaceHolder sh). It REQUIRES use of MediaRecorder.setCamera for preview, but setCamera is apparently broken "Known limitation - locked camera" in API 3.

So: I Cannot have a previewed media recorder that works on 1.5 and 2.0. So my only option is, (confirmed MediaRecorder.setCamera is not broken in Android2.0 - they added an unlock) is to have two separate versions , one for API 3 and one for API 5.

Thank you commonsware for pointing me in the right direction. I will change the status to "answered" once I try again with deviceanywhere, just to be safe.

BeMeCollective