实现教程代码时出错

时间:2016-06-04 18:17:15

标签: android android-canvas

我正在尝试实现这个 - http://www.divided-games.com/drawing-with-canvas-on-top-of-a-camera-preview/ - 代码。我正在使用eclipse。我有一些麻烦,因为这段代码使用旧的相机api,但我完成了。现在我的清单文件有一些错误:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="in.android.move"
      android:versionCode="666"
      android:versionName="BJP" >

<uses-sdk android:minSdkVersion="13" 
          android:targetSdkVersion="14"/>

<uses-permission android:name="android.permission.CAMERA"/>

<uses-feature android:name="android.hardware.camera" />

<application
    android:allowBackup="false"
    android:label="@string/app_name"
    android:icon="@drawable/ic_launcher"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >



    <activity android:name=".MainActivity"
              android:label="@string/app_name"

              android:configChanges="keyboardHidden|orientation">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

第1行和第8行用黄色下划线。我的其余代码没有警告错误。我将代码上传到手机中,我收到此logcat错误。手机中的弹出窗口说:不幸的是,移动已停止。

06-04 23:32:30.984: I/art(622): Late-enabling -Xcheck:jni
06-04 23:32:31.089: W/System(622): ClassLoader referenced unknown path: /data/app/in.android.move-2/lib/arm
06-04 23:32:31.221: D/AndroidRuntime(622): Shutting down VM
06-04 23:32:31.229: E/AndroidRuntime(622): FATAL EXCEPTION: main
06-04 23:32:31.229: E/AndroidRuntime(622): Process: in.android.move, PID: 622
06-04 23:32:31.229: E/AndroidRuntime(622): Theme: themes:{}
06-04 23:32:31.229: E/AndroidRuntime(622): java.lang.RuntimeException: Unable to start activity ComponentInfo{in.android.move/in.android.move.MainActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
06-04 23:32:31.229: E/AndroidRuntime(622):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2450)
06-04 23:32:31.229: E/AndroidRuntime(622):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
06-04 23:32:31.229: E/AndroidRuntime(622):  at android.app.ActivityThread.-wrap11(ActivityThread.java)
06-04 23:32:31.229: E/AndroidRuntime(622):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363)
06-04 23:32:31.229: E/AndroidRuntime(622):  at android.os.Handler.dispatchMessage(Handler.java:102)
06-04 23:32:31.229: E/AndroidRuntime(622):  at android.os.Looper.loop(Looper.java:148)
06-04 23:32:31.229: E/AndroidRuntime(622):  at android.app.ActivityThread.main(ActivityThread.java:5461)
06-04 23:32:31.229: E/AndroidRuntime(622):  at java.lang.reflect.Method.invoke(Native Method)
06-04 23:32:31.229: E/AndroidRuntime(622):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
06-04 23:32:31.229: E/AndroidRuntime(622):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-04 23:32:31.229: E/AndroidRuntime(622): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
06-04 23:32:31.229: E/AndroidRuntime(622):  at com.android.internal.policy.PhoneWindow.requestFeature(PhoneWindow.java:367)
06-04 23:32:31.229: E/AndroidRuntime(622):  at android.app.Activity.requestWindowFeature(Activity.java:3656)
06-04 23:32:31.229: E/AndroidRuntime(622):  at in.android.move.MainActivity.onCreate(MainActivity.java:28)
06-04 23:32:31.229: E/AndroidRuntime(622):  at android.app.Activity.performCreate(Activity.java:6251)
06-04 23:32:31.229: E/AndroidRuntime(622):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
06-04 23:32:31.229: E/AndroidRuntime(622):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2403)
06-04 23:32:31.229: E/AndroidRuntime(622):  ... 9 more

0 个答案:

没有答案