我下载了 zxing 项目,并用一个按钮创建了一个简单的活动。这个简单的活动应该在按下按钮时启动 zxing 项目。现在我的问题是:我希望这个带有按钮的简单活动成为开始活动,我在清单文件中创建了以下标签,如下所示:
开始活动:
并且下载的 zxing 项目有一个总是在开始时启动的活动,它有以下清单文件:
<activity android:name=".CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<!-- Allow web apps to launch Barcode Scanner by linking to http://zxing.appspot.com/scan. -->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="http" android:host="zxing.appspot.com" android:path="/scan"/>
</intent-filter>
<!-- We also support a Google Product Search URL. -->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="http" android:host="www.google.com" android:path="/m/products
/scan"/>
</intent-filter>
<!-- And the UK version. -->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="http" android:host="www.google.co.uk" android:path="/m
/products/scan"/>
</intent-filter>
</activity>
将我的活动更改为启动器后的 Logcat 输出:
09-20 12:39:57.527: E/AndroidRuntime(22519): FATAL EXCEPTION: main
09-20 12:39:57.527: E/AndroidRuntime(22519): java.lang.RuntimeException: Unable to
resume activity
{com.google.zxing.client.android/com.google.zxing.client.android.Test}:
java.lang.NullPointerException
09-20 12:39:57.527: E/AndroidRuntime(22519): at
android.app.ActivityThread.performResumeActivity(ActivityThread.java:2456)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2484)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1998)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
android.app.ActivityThread.access$600(ActivityThread.java:127)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
android.os.Looper.loop(Looper.java:137)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
android.app.ActivityThread.main(ActivityThread.java:4507)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
java.lang.reflect.Method.invokeNative(Native Method)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
java.lang.reflect.Method.invoke(Method.java:511)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
dalvik.system.NativeStart.main(Native Method)
09-20 12:39:57.527: E/AndroidRuntime(22519): Caused by: java.lang.NullPointerException
09-20 12:39:57.527: E/AndroidRuntime(22519): at
com.google.zxing.client.android.CaptureActivity.onResume(CaptureActivity.java:178)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1157)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
android.app.Activity.performResume(Activity.java:4539)
09-20 12:39:57.527: E/AndroidRuntime(22519): at
android.app.ActivityThread.performResumeActivity(ActivityThread.java:2446)
我只想知道如何使我创建的简单活动成为开始活动。也就是说,简单activity的标签在zxing项目的manifest文件中应该放在哪里呢?