实施初始屏幕后应用程序崩溃
在堆栈上执行此处的回答后启动屏幕后,打开应用程序时出现崩溃。在应用程序打开时,错误显示在我的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
在布局XML中有一个活动标签。这不是它的工作原理。活动标签仅用于您的清单。布局XML文件应该只有视图和片段。活动通常是全屏。
你可以阅读更多关于在您的清单这里有云: http://developer.android.com/guide/topics/manifest/manifest-intro.html
而且你可以读到这里布局XML发生的事情: http://developer.android.com/guide/topics/ui/declaring-layout.html
修复它,但有一些错误,没有任何崩溃的应用程序!非常感谢! – 2014-12-06 18:31:56
不,活动标签仅用于告诉Android您在代码中有活动。布局XML用于定义屏幕的外观,并用视图来定义。添加链接到我的答案... – Bruce 2014-12-06 18:32:55
所以这不应该修复它?因为它呢? – 2014-12-06 18:38:22
始终张贴logcat的。 – Totoro 2014-12-06 18:18:04
请勿创建启动画面。他们没有什么好处,用户也讨厌他们。他们反Android。 http://cyrilmottier.com/2012/05/03/splash-screens-are-evil-dont-use-them/ – Simon 2014-12-06 18:30:27