改变发射活动

时间:2011-03-31 14:41:19

标签: android android-manifest launching-application

我想改变我的启动活动。目前我的清单是这样的:          

<application android:icon="@drawable/iconbj" android:label="@string/app_name"
    android:debuggable="true">
    <activity android:name=".Main" android:label="@string/app_name" android:screenOrientation="landscape">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:label="DemoPlayActivity" android:name="DemoPlayActivity" android:screenOrientation="landscape"></activity>

</application>

现在我创建了另一个活动,它是一个启动画面,我想启动它而不是Main,所以我尝试了这样:          

<application android:icon="@drawable/iconbj" android:label="@string/app_name"
    android:debuggable="true">
    <activity android:name=".Splash" android:label="@string/app_name"
        android:screenOrientation="landscape">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="Main" android:label="Main"
        android:screenOrientation="landscape">
    </activity>
    <activity android:label="DemoPlayActivity" android:name="DemoPlayActivity"
        android:screenOrientation="landscape"></activity>

</application>

但我得到了这个问题的许可:

  

[2011-03-31 16:32:44 - BlackJackNuovo]   ActivityManager:   java.lang.SecurityException异常:   权限拒绝:启动Intent {   ACT = android.intent.action.MAIN   猫= [android.intent.category.LAUNCHER]   FLG = 0x10000000的   CMP = com.phinet.android.blackjack /。主要   来自null(pid = -1,uid = -1)需要   空。

请帮帮我:)。

更新

没有办法。我这样做了:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.phinet.android.blackjack" android:versionCode="1"
    android:versionName="1.0">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.VIBRATE" />

    <application android:icon="@drawable/iconbj" android:label="@string/app_name"
        android:debuggable="true">
        <activity android:name="com.phinet.android.blackjack.Splash" android:label="Splash"
            android:screenOrientation="landscape">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.phinet.android.blackjack.Main" android:label="Main"
            android:screenOrientation="landscape">
        </activity>
        <activity android:label="com.phinet.android.blackjack.DemoPlayActivity" android:name="DemoPlayActivity"
            android:screenOrientation="landscape"></activity>

    </application>
</manifest>

但似乎午餐总是主要的活动,这是concole日志:

[2011-04-01 10:57:10 - BlackJackNuovo] Uploading BlackJackNuovo.apk onto device '9000d365e767'
[2011-04-01 10:57:16 - BlackJackNuovo] Installing BlackJackNuovo.apk...
[2011-04-01 10:57:32 - BlackJackNuovo] Success!
[2011-04-01 10:57:32 - BlackJackNuovo] Starting activity com.phinet.android.blackjack.Main on device 9000d365e767
[2011-04-01 10:57:32 - BlackJackNuovo] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.phinet.android.blackjack/.Main }
[2011-04-01 10:57:35 - BlackJackNuovo] ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.phinet.android.blackjack/.Main } from null (pid=-1, uid=-1) requires null

为什么?

1 个答案:

答案 0 :(得分:1)

<activity android:name="Main" android:label="Main"
    android:screenOrientation="landscape">
</activity>
<activity android:label="DemoPlayActivity" android:name="DemoPlayActivity"
    android:screenOrientation="landscape"></activity>

仍然应该有领先的

<activity android:name=".Main" android:label="Main" android:screenOrientation="landscape">
</activity>
<activity android:label=".DemoPlayActivity" android:name="DemoPlayActivity"android:screenOrientation="landscape">
</activity>

这说明它有一个相对路径到您的类。如果您愿意,您可以进行绝对引用,即"com.your.app.Main"