1

就像标题一样,我在我的 android Galaxy Ace S5830i 上运行这个应用程序时遇到问题。

  1. 我刚刚在 Eclipse 中创建了一个新的 android 应用程序。
  2. 在 First-->src-->com.example.first-->Splash.java 中添加 Splash.java
  3. 添加了布局 res-->layout-->splash.xml (它基本上只是eclipse设置的activity_fullscreen.xml的副本已经只是按钮已被删除)
  4. 在清单中添加了一些代码

每当我在设备上启动应用程序时,它就会崩溃,说“应用程序优先(进程 com.example.first)已意外停止。请再试一次。”

我可以告诉你,启动活动已启动,但在尝试启动其他活动时崩溃。

飞溅.java

    package com.example.first;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

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(5000);
            }catch(InterruptedException e){
                e.printStackTrace();
            }finally{
                Intent start = new Intent("com.example.first.FullscreenActivity");
                startActivity(start);
            }
        }
    };
    timer.start();
}

}

飞溅.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0099cc"
tools:context=".FullscreenActivity" >

<!--
     The primary full-screen view. This can be replaced with whatever view
     is needed to present your content, e.g. VideoView, SurfaceView,
     TextureView, etc.
-->

<TextView
    android:id="@+id/fullscreen_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:keepScreenOn="true"
    android:text="@string/dummy_content"
    android:textColor="#33b5e5"
    android:textSize="50sp"
    android:textStyle="bold" />

<!--
     This FrameLayout insets its children based on system windows using
     android:fitsSystemWindows.
-->

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true" >

    <LinearLayout
        android:id="@+id/fullscreen_content_controls"
        style="?buttonBarStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center_horizontal"
        android:background="@color/black_overlay"
        android:orientation="horizontal"
        tools:ignore="UselessParent" >

    </LinearLayout>
</FrameLayout>

</FrameLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.first"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.first.FullscreenActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name"
        android:theme="@style/FullscreenTheme" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.first.Splash"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name"
        android:theme="@style/FullscreenTheme" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

</application>

</manifest>
4

1 回答 1

2

在 splash.class 上,更改

Intent start = new Intent("com.example.first.FullscreenActivity");

Intent start = new Intent(Splash.this,com.example.first.FullscreenActivity.class);

你 manifest.xml 更改为以下

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.first"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.first.Splash"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name"
        android:theme="@style/FullscreenTheme" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.first.FullscreenActivity"
        android:configChanges="orientation|keyboardHidden|screenSize">
    </activity>

</application>

</manifest>
于 2013-09-15T09:55:07.983 回答