3

我正在开发我的第一个 Android 增强现实应用程序。ARActivity如果作为文件中的第一个类 ( android.intent.category.LAUNCHER)运行,则应用程序运行良好manifest。但是,当我添加一个启动画面时,这意味着ARActivity将是第二个run(android.intent.category.DEFAULT),相机似乎没有检测到标记。我相信问题都在manifest文件中。

这是 manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ar.armarkers"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

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

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

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".Splash"
            android:screenOrientation="landscape"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.ar.armarkers.MainActivity"
            android:clearTaskOnLaunch="true"
            android:label="@string/title_activity_main"
            android:noHistory="true"
            android:screenOrientation="landscape" >
            <intent-filter>
                <action android:name="com.ar.armarkers.MAINACTIVITY" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>

</manifest>

MainActivity.java

import edu.dhbw.andar.ARObject;
import edu.dhbw.andar.ARToolkit;
import edu.dhbw.andar.AndARActivity;
import edu.dhbw.andar.exceptions.AndARException;

import edu.dhbw.andar.pub.CustomRenderer;
import android.os.Bundle;

import android.util.Log;

public class MainActivity extends AndARActivity {

    private ARObject someObject;
    private ARToolkit artoolkit;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CustomRenderer renderer = new CustomRenderer();
        setNonARRenderer(renderer);

        try {
            artoolkit = getArtoolkit();

            someObject = new CustomObject1("test", "marker16.pat", 80.0,
                    new double[] { 0, 0 });
            artoolkit.registerARObject(someObject);

            someObject = new CustomObject2
                    ("test", "marker17.patt", 80.0, new
                    double[]{0,0});
                    artoolkit.registerARObject(someObject);

        } catch (AndARException ex) {
            System.out.println("");
        }
        startPreview();
    }

    public void uncaughtException(Thread thread, Throwable ex) {
        // TODO Auto-generated method stub

        Log.e("AndAR EXCEPTION", ex.getMessage());
        finish();
    }

}

飞溅.java

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;

public class Splash extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);

        Thread timer = new Thread() {
            public void run() {
                try {
                    sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } finally {
                    Intent i = new Intent(getApplicationContext(),
                            MainActivity.class);
                    startActivity(i);
                }
            }
        };
        timer.start();
    }

}
4

0 回答 0