1

in my app, there is two activity and i want to make activity1 to the starting activity after installation. But now the RUN button (is showed right after packgae installing) is disabled.

below is the manifest file. thanks.

<activity ...1>
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>
<activity ...2>
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
  <intent-filter>
    <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
    <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
  </intent-filter>
</activity>
kemi.
  • 11
  • 2

2 Answers2

1

android) can i set a default activity that runs right after installing

No activity "runs right after installing". The user has to launch it from the launcher.

below is the manifest file

No, it is not. That is not even valid XML.

Also, note that your third <intent-filter> is invalid. Not only are you missing any category (you need at least DEFAULT for activities), but ACTION_POWER_CONNECTED and ACTION_POWER_DISCONNECTED are not activity actions.

I am going to take a guess that you really mean to ask: "I have two activities, both described as ACTION_MAIN/CATEGORY_LAUNCHER, and now the Run button does not work -- what can I do?" The answer would be "either remove the ACTION_MAIN/CATEGORY_LAUNCHER <intent-filter> from one of them, or mark one of the two as disabled (android:enabled="false") and enable it later on using PackageManager."

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
1

I think the problem is the second:

<intent-filter>
   <action android:name="android.intent.action.MAIN" />
   <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

You shouldn't have 2 activities flagged as the MAIN and LAUNCHER activity.

Try removing it within activity2.

Check out: http://developer.android.com/reference/android/content/Intent.html the intentfilter s are discussed.

Darwind
  • 7,284
  • 3
  • 49
  • 48
  • Really stupid answer, for example, i need to have two icons in my android dashboard, and i have the same problem with installation process, so what should I do? – Orest Jan 19 '12 at 13:52
  • What a stupid comment as well. Doesn't help to be polite even though you disagree ;-) Alas you're right. Look at this SO question - this seems to answer your question: http://stackoverflow.com/questions/3270409/how-do-i-get-multiple-icons-to-launch-different-activities-in-one-application I don't suppose you need 2 different icons to launch the same activity? – Darwind Jan 24 '12 at 20:39