7

当我启动应用程序时,Android 正在启动错误的活动。

清单.xml:

<activity
    android:name="com.company.app.activities.RS_SplashScreenActivity"
    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.company.app.activities.RS_PreviousLauncherActivity"
    android:label="@string/app_name"
    android:theme="@style/myTheme" >
</activity> 

我添加了一个新活动RS_SplashScreenActivity并将其设置为启动器活动。它仍然尝试RS_PreviousLauncherActivity在添加之前启动曾经是启动器活动的启动RS_SplashScreenActivity

我确信android会根据控制台的以下日志选择错误的启动器活动。

安慰 :

[2013-10-10 12:03:58 - app] Android Launch!
[2013-10-10 12:03:58 - app] adb is running normally.
[2013-10-10 12:03:58 - app] Performing com.company.app.activities.RS_PreviousLauncherActivity activity launch
[2013-10-10 12:04:01 - app] Uploading app.apk onto device '5C78E6332221CD6A1'
[2013-10-10 12:04:05 - app] Installing app.apk...
[2013-10-10 12:04:12 - app] Success!
[2013-10-10 12:04:12 - app] Starting activity com.company.app.activities.RS_PreviousLauncherActivity on device 5C78E6332221CD6A1
[2013-10-10 12:04:12 - app] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.company.app/.activities.RS_PreviousLauncherActivity }
[2013-10-10 12:04:13 - app] ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.company.app/.activities.RS_PreviousLauncherActivity } from null (pid=4530, uid=2000) not exported from uid 10084
[2013-10-10 12:04:13 - app] ActivityManager: at android.os.Parcel.readException(Parcel.java:1425)
[2013-10-10 12:04:13 - app] ActivityManager: at android.os.Parcel.readException(Parcel.java:1379)
[2013-10-10 12:04:13 - app] ActivityManager: at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1783)
[2013-10-10 12:04:13 - app] ActivityManager: at com.android.commands.am.Am.runStart(Am.java:463)
[2013-10-10 12:04:13 - app] ActivityManager: at com.android.commands.am.Am.run(Am.java:108)
[2013-10-10 12:04:13 - app] ActivityManager: at com.android.commands.am.Am.main(Am.java:81)
[2013-10-10 12:04:13 - app] ActivityManager: at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
[2013-10-10 12:04:13 - app] ActivityManager: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
[2013-10-10 12:04:13 - app] ActivityManager: at dalvik.system.NativeStart.main(Native Method)

知道为什么会这样吗?

编辑 :

public class RS_SplashScreenActivity extends Activity {

    // Splash screen timer
    private static int SPLASH_TIME_OUT = 3000;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash_screen);

        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                // This method will be executed once the timer is over
                // Start your app main activity
                Intent i = new Intent(RS_SplashScreenActivity.this, RS_PreviousLauncherActivity.class);
                RS_SplashScreenActivity.this.startActivity(i);

                // close this activity
                RS_SplashScreenActivity.this.finish();
            }
        }, SPLASH_TIME_OUT);
    }

编辑: 当我删除活动标签时RS_PreviousLauncherActivity,它会检测到正确的活动作为启动器,但是当我再次添加活动标签时,它会开始选择错误的活动。

编辑: 我在控制台中得到以下日志。可能这与我的问题有关。

[2013-10-09 10:27:04 - app] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.james.mime4j.message.Header$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

还有一件事,同样的项目可以在其他机器上运行。

4

7 回答 7

24

右键单击您的项目并选择“运行方式”>“运行配置... ”。检查弹出的对话框中是否在Android选项卡中选择了“启动默认活动” :

运行配置对话框

很可能在继续启动旧活动的机器上,它被设置为意外启动该特定活动(第二个单选按钮)。

于 2013-10-11T06:50:42.790 回答
0

卸载应用程序,然后重新安装,有时启动器中的 appLauncher 包含旧参考,我的图标有类似问题,我更改了应用程序图标,但它显示为旧图标。

于 2013-10-08T11:00:51.557 回答
0

从 Eclipse 中清理项目。

  1. 菜单->项目->清理->选择你的项目->确定

它将清理项目并再次生成二进制文件。之后安装应用程序并检查。

于 2013-10-08T11:03:23.557 回答
0

试试这个:

<application
      ..... 
     android:theme="@style/myTheme" 
>

<activity
    android:name="com.company.app.activities.RS_SplashScreenActivity"
    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.company.app.activities.RS_PreviousLauncherActivity"
    >
</activity> 
于 2013-10-08T11:26:37.890 回答
0

也许您可能想以传统方式制作启动画面......这样您就知道它会起作用,请参阅链接: 如何制作启动画面

于 2013-10-08T11:33:53.860 回答
0

清理您的项目或卸载您的应用程序。仍然没有工作,然后删除“gen”文件夹,然后清理您的项目并运行。

于 2013-10-10T06:46:25.683 回答
-2

检查您的RS_SplashScreenActivity的代码。检查所有时间间隔重定向到 RS_PreviousLauncherActivity。

如果它不能解决你的问题,那就做一件事

1:右键单击eclipse中的项目

2:点击来源

3:然后点击清理..

4:点击完成

5:从您的设备上卸载应用程序后重新安装Atlast。

它可能会解决您的问题。

已编辑

试试这个:

<application
      ..... 
     android:theme="@style/myTheme" 
>

<activity
    android:name="com.company.app.activities.RS_SplashScreenActivity"
    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.company.app.activities.RS_PreviousLauncherActivity"     
       >
        <intent-filter>
            <action android:name="com.company.app.activities.RS_PreviousLauncherActivity" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
于 2013-10-08T11:11:18.973 回答