2014-12-06 108 views
-3

在堆棧上執行此處的回答後啓動屏幕後,打開應用程序時出現崩潰。在應用程序打開時,錯誤顯示在我的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

+0

始終張貼logcat的。 – Totoro 2014-12-06 18:18:04

+1

請勿創建啓動畫面。他們沒有什麼好處,用戶也討厭他們。他們反Android。 http://cyrilmottier.com/2012/05/03/splash-screens-are-evil-dont-use-them/ – Simon 2014-12-06 18:30:27

回答

1

在佈局XML中有一個活動標籤。這不是它的工作原理。活動標籤僅用於您的清單。佈局XML文件應該只有視圖和片段。活動通常是全屏。

你可以閱讀更多關於在您的清單這裏有雲: http://developer.android.com/guide/topics/manifest/manifest-intro.html

而且你可以讀到這裏佈局XML發生的事情: http://developer.android.com/guide/topics/ui/declaring-layout.html

+0

修復它,但有一些錯誤,沒有任何崩潰的應用程序!非常感謝! – 2014-12-06 18:31:56

+0

不,活動標籤僅用於告訴Android您在代碼中有活動。佈局XML用於定義屏幕的外觀,並用視圖來定義。添加鏈接到我的答案... – Bruce 2014-12-06 18:32:55

+0

所以這不應該修復它?因爲它呢? – 2014-12-06 18:38:22

相關問題