应用启动画面后应用程序崩溃

时间:2014-12-06 18:10:41

标签: android xml

在堆栈上的答案后实现启动画面后,我打开应用程序时崩溃了。当应用程序打开时,错误会显示在我的logcat中。     
这是我的代码:
Android Manifest.xml:

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

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

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <permission android:protectionLevel="signature"
        android:name="se.welovecode.tismatapp.permission.C2D_MESSAGE" />
    <uses-permission android:name="se.welovecode.tismatapp.permission.C2D_MESSAGE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        android:name=".ParsePushApplication">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/splashScreenTheme" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:name="com.parse.PushService" />
        <receiver android:name="com.parse.ParseBroadcastReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.USER_PRESENT" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.parse.ParsePushBroadcastReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="com.parse.push.intent.RECEIVE" />
                <action android:name="com.parse.push.intent.DELETE" />
                <action android:name="com.parse.push.intent.OPEN" />
            </intent-filter>
        </receiver>

        <!-- PARSE PUSH NOTIFICATION -->
        <receiver android:name="com.parse.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <!--
                  IMPORTANT: Change "com.parse.starter" to match your app's package name.
                -->
                <category android:name="se.welovecode.tismatapp" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

activity_main.xml中

<RelativeLayout 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"
tools:context="se.welovecode.tismatapp.MainActivity" >

<WebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentEnd="false"
    android:layout_alignParentRight="true"
    android:layout_alignParentStart="false"
    android:layout_alignParentTop="true" />

<activity
    android:name="MainActivity"
    android:label="@string/app_name"
    android:theme="@style/splashScreenTheme"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>

style.xml

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

<style name="splashScreenTheme" parent="AppTheme">
    <item name="android:windowBackground">@drawable/splash_screen</item>
</style>

Logcat:Drive document

1 个答案:

答案 0 :(得分:1)

您的布局XML中有一个活动标记。这不是它的工作原理。活动标记仅适用于您的清单。布局XML文件应该只有视图和片段。活动通常是全屏。

您可以在此处详细了解清单中的内容: http://developer.android.com/guide/topics/manifest/manifest-intro.html

您可以在这里阅读布局XML中的内容: http://developer.android.com/guide/topics/ui/declaring-layout.html