这是我的Android清单,由于某些原因,我的MainActivity不会首先启动。每当我运行应用程序时首先启动的活动是RegisterActivity。任何人都可以帮我找出原因吗?
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.indigohate"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<permission
android:name="com.indigohate.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.indigohate.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<service android:name="com.indigohate.GCMIntentService" />
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.indigohate" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.indigohate" />
</intent-filter>
</receiver>
<activity
android:name="com.indigohate.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.indigohate.RegisterActivity"
android:launchMode="singleTop" />
<activity
android:name="com.indigohate.UserRegister"
android:launchMode="singleTop" />
<activity
android:name="com.indigohate.LoginActivity"
android:launchMode="singleTop" >
</activity>
<activity
android:name="com.indigohate.RideRequest"
android:label="@string/title_activity_ride_request" >
</activity>
<activity
android:name="com.indigohate.TimePickerFragment"
android:label="@string/title_activity_time_picker_fragment" >
</activity>
<activity
android:name="com.indigohate.SearchResultsListActivity"
android:launchMode="singleTop" />
<activity
android:name="com.indigohate.LoadingScreenActivity"
android:label="@string/title_activity_loading_screen" >
</activity>
<activity
android:name="com.indigohate.HomeActivity"
android:label="@string/title_activity_home" >
</activity>
<activity
android:name="com.indigohate.LostPasswordActivity"
android:label="@string/title_activity_lost_password" >
</activity>
<activity
android:name="com.indigohate.RideOfferActivity"
android:label="@string/title_activity_ride_offer" >
</activity>
<activity
android:name="com.indigohate.StartRideActivity"
android:label="@string/title_activity_start_ride" >
</activity>
<activity
android:name="com.indigohate.StopRideActivity"
android:label="@string/title_activity_stop_ride" >
</activity>
<activity
android:name="com.indigohate.CalendarActivity"
android:label="@string/title_activity_calendar" >
</activity>
<activity
android:name="com.indigohate.ProfileActivity"
android:label="@string/title_activity_profile" >
</activity>
<activity
android:name="com.indigohate.MakeCommentActivity"
android:label="@string/title_activity_make_comment" >
</activity>
<activity
android:name="com.indigohate.PaymentInformationActivity"
android:label="@string/title_activity_payment_information" >
</activity>
<activity
android:name="com.indigohate.RideHistoryActivity"
android:label="@string/title_activity_ride_history" >
</activity>
</application>
</manifest>
答案 0 :(得分:3)
这是因为您在RegisterActivity
android:launchMode="singleTop"
删除所有活动中的所有这些启动模式。只保留在MainActivity中:
<activity
android:name="com.indigohate.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
起始活动包含<category android:name="android.intent.category.LAUNCHER" />
,以确保在应用启动时它是launcher
活动。