继续'的应用程序的工作不在的机器人'调查:代码。任何人都可以看到任何明显的错误在这里?

StackOverflow https://stackoverflow.com/questions/1774750

  •  21-09-2019
  •  | 
  •  

在我的前一个问题我问 System.currentTimeMillis() 是越野车在机器人,答案是否定的。

我假设的问题,我有的是在其他地方。虽然我等待着我的机器人孤独的用户要报告,如果一个测试的应用程序适用于他的电话,我想以后的一些相关的代码这里。

请记住,我删除一切代码我认为将是不相关的(账代码,导致第一次可疑的线)。我可能已经删除了代码在哪里的问题是,但是我对此表示怀疑。它闻起来像个布局,不是代码,问题。我这样说是因为(见最后一行,那里的日志的)表面上为0。

最好的问候,Ari。

清单

<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>

布局

<?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>

代码

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

在另一类

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

结果日志(表面是不是有效的):

11-19 17:58:13.171 D/BeMeBB  ( 1404): BeMeBBService m_surface=Surface(native-token=0)
有帮助吗?

解决方案

现在,它的确认,我孤独的机器人用户发送回的2日志文件:

  1. 一个测试的应用程序的使用MediaRecorder.setPreviewDisplay(表面sv)。它需要用的getSurface,其崩溃API5月的机器人的手机。

  2. 一个测试的应用程序的使用照相机。setPreviewDisplay(SurfaceHolder sh)。它需要用的MediaRecorder.setCamera于预览,但setCamera显然是破碎的"已知的限制锁摄像机"在API3.

所以:我不能有一个预览媒体记录,适用于1.5和2.0。所以我唯一的选择是,(确认MediaRecorder.setCamera是不断在Android2.0-他们增加了一个解)是具有两个独立的版本,一个针对API3和一个一API5.

谢谢你commonsware指着我的方向是正确的。我会改变的状态到"回答"有一次,我再试一次与deviceanywhere,就是安全的。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top