[android-developers] Re: Is it possible to have 2 launcher Activity in a single apk?
WOW it took me _forever_ to figure out exactlly what you meant... Here is the manifest section needed for anyone needing help here. application android:icon=@drawable/icon android:label=@string/ app_name activity android:taskAffinity=org.appname.act1 android:label=@string/act1_label android:name=.act1 android:theme=@android:style/Theme.Dialog intent-filter action android:name=android.intent.action.MAIN / category android:name=android.intent.category.LAUNCHER / /intent-filter /activity activity android:taskAffinity=org.appname.act2 android:name=.act2 android:label=@string/act2_label android:theme=@android:style/Theme.Light intent-filter action android:name=android.intent.action.MAIN / category android:name=android.intent.category.LAUNCHER / /intent-filter /activity /application On Feb 5, 2:31 pm, tauntz tau...@gmail.com wrote: Thanks Dianne. Just for the record (if someone else needs the solution and finds this thread): If you want to have two different applications in one .apk then you need to have both launcher Activities with the LAUNCHER category as Romain said. You also need to add different task affinities to these activities. Otherwise you might bump into the problems that I described (and as far as I understand, this is designed to behave like that :) ) One more note - don't believehttp://code.google.com/android/intro/appmodel.htmlentirely - you can't have task affinities in the form append your .apk's package name with a colon separated string - colons are not supported characters there. Also replace the words you will probably want to with you have to in your head when reading this :) Tauno On Thu, Feb 5, 2009 at 8:02 PM, Dianne Hackborn hack...@android.com wrote: If you want two fully distinct apps, you need to give them different task affinities. Please read this before you go farther: http://code.google.com/android/intro/appmodel.html On Thu, Feb 5, 2009 at 7:56 AM, tauntz tau...@gmail.com wrote: On Tue, Feb 3, 2009 at 10:37 AM, Romain Guy romain...@google.com wrote: Yes :) Just put two activities in your manifest, both with the LAUNCHER category. I tried that but it seems I'm still doing something wrong (see code at the end of the message). The results I get are: * Two launcher entries (Ativity A and Activity B) are placed in the activity list in Home * Clicking first on Activity A will start Activity A. * Going back and clicking on Activity B will start Activity A again. * If I click on Activity B the first time after install, B is started and going back - clicking on A, starts B again Any hints on what I'm doing wrong? LogCat: INFO/ActivityManager(55): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} flags=0x1020 comp={test.activity/test.activity.ActivityA} } INFO/ActivityManager(55): Start proc test.activity for activity test.activity/.ActivityA: pid=13716 uid=10036 gids={} INFO/jdwp(13716): received file descriptor 10 from ADB INFO/ActivityManager(55): Displayed activity test.activity/.ActivityA: 872 ms INFO/ActivityManager(55): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.HOME} flags=0x1020 comp={com.android.launcher/com.android.launcher.Launcher} } INFO/ActivityManager(55): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} flags=0x1020 comp={test.activity/test.activity.ActivityB} } Code: ?xml version=1.0 encoding=utf-8? manifest xmlns:android=http://schemas.android.com/apk/res/android; package=test.activity android:versionCode=1 android:versionName=1.0.0 application activity android:name=.ActivityA android:label=Activity A intent-filter action android:name=android.intent.action.MAIN / category android:name=android.intent.category.LAUNCHER / /intent-filter /activity activity android:name=.ActivityB android:label=Activity B intent-filter action android:name=android.intent.action.MAIN / category android:name=android.intent.category.LAUNCHER / /intent-filter /activity /application /manifest public class ActivityA extends Activity { �...@override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this);
[android-developers] Re: Is it possible to have 2 launcher Activity in a single apk?
On Tue, Feb 3, 2009 at 10:37 AM, Romain Guy romain...@google.com wrote: Yes :) Just put two activities in your manifest, both with the LAUNCHER category. I tried that but it seems I'm still doing something wrong (see code at the end of the message). The results I get are: * Two launcher entries (Ativity A and Activity B) are placed in the activity list in Home * Clicking first on Activity A will start Activity A. * Going back and clicking on Activity B will start Activity A again. * If I click on Activity B the first time after install, B is started and going back - clicking on A, starts B again Any hints on what I'm doing wrong? LogCat: INFO/ActivityManager(55): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} flags=0x1020 comp={test.activity/test.activity.ActivityA} } INFO/ActivityManager(55): Start proc test.activity for activity test.activity/.ActivityA: pid=13716 uid=10036 gids={} INFO/jdwp(13716): received file descriptor 10 from ADB INFO/ActivityManager(55): Displayed activity test.activity/.ActivityA: 872 ms INFO/ActivityManager(55): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.HOME} flags=0x1020 comp={com.android.launcher/com.android.launcher.Launcher} } INFO/ActivityManager(55): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} flags=0x1020 comp={test.activity/test.activity.ActivityB} } Code: ?xml version=1.0 encoding=utf-8? manifest xmlns:android=http://schemas.android.com/apk/res/android; package=test.activity android:versionCode=1 android:versionName=1.0.0 application activity android:name=.ActivityA android:label=Activity A intent-filter action android:name=android.intent.action.MAIN / category android:name=android.intent.category.LAUNCHER / /intent-filter /activity activity android:name=.ActivityB android:label=Activity B intent-filter action android:name=android.intent.action.MAIN / category android:name=android.intent.category.LAUNCHER / /intent-filter /activity /application /manifest public class ActivityA extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText(ActivityA); setContentView(tv); } } public class ActivityB extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText(ActivityB); setContentView(tv); } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Is it possible to have 2 launcher Activity in a single apk?
If you want two fully distinct apps, you need to give them different task affinities. Please read this before you go farther: http://code.google.com/android/intro/appmodel.html On Thu, Feb 5, 2009 at 7:56 AM, tauntz tau...@gmail.com wrote: On Tue, Feb 3, 2009 at 10:37 AM, Romain Guy romain...@google.com wrote: Yes :) Just put two activities in your manifest, both with the LAUNCHER category. I tried that but it seems I'm still doing something wrong (see code at the end of the message). The results I get are: * Two launcher entries (Ativity A and Activity B) are placed in the activity list in Home * Clicking first on Activity A will start Activity A. * Going back and clicking on Activity B will start Activity A again. * If I click on Activity B the first time after install, B is started and going back - clicking on A, starts B again Any hints on what I'm doing wrong? LogCat: INFO/ActivityManager(55): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} flags=0x1020 comp={test.activity/test.activity.ActivityA} } INFO/ActivityManager(55): Start proc test.activity for activity test.activity/.ActivityA: pid=13716 uid=10036 gids={} INFO/jdwp(13716): received file descriptor 10 from ADB INFO/ActivityManager(55): Displayed activity test.activity/.ActivityA: 872 ms INFO/ActivityManager(55): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.HOME} flags=0x1020 comp={com.android.launcher/com.android.launcher.Launcher} } INFO/ActivityManager(55): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} flags=0x1020 comp={test.activity/test.activity.ActivityB} } Code: ?xml version=1.0 encoding=utf-8? manifest xmlns:android=http://schemas.android.com/apk/res/android; package=test.activity android:versionCode=1 android:versionName=1.0.0 application activity android:name=.ActivityA android:label=Activity A intent-filter action android:name=android.intent.action.MAIN / category android:name=android.intent.category.LAUNCHER / /intent-filter /activity activity android:name=.ActivityB android:label=Activity B intent-filter action android:name=android.intent.action.MAIN / category android:name=android.intent.category.LAUNCHER / /intent-filter /activity /application /manifest public class ActivityA extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText(ActivityA); setContentView(tv); } } public class ActivityB extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText(ActivityB); setContentView(tv); } } -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Is it possible to have 2 launcher Activity in a single apk?
Thanks Dianne. Just for the record (if someone else needs the solution and finds this thread): If you want to have two different applications in one .apk then you need to have both launcher Activities with the LAUNCHER category as Romain said. You also need to add different task affinities to these activities. Otherwise you might bump into the problems that I described (and as far as I understand, this is designed to behave like that :) ) One more note - don't believe http://code.google.com/android/intro/appmodel.html entirely - you can't have task affinities in the form append your .apk's package name with a colon separated string - colons are not supported characters there. Also replace the words you will probably want to with you have to in your head when reading this :) Tauno On Thu, Feb 5, 2009 at 8:02 PM, Dianne Hackborn hack...@android.com wrote: If you want two fully distinct apps, you need to give them different task affinities. Please read this before you go farther: http://code.google.com/android/intro/appmodel.html On Thu, Feb 5, 2009 at 7:56 AM, tauntz tau...@gmail.com wrote: On Tue, Feb 3, 2009 at 10:37 AM, Romain Guy romain...@google.com wrote: Yes :) Just put two activities in your manifest, both with the LAUNCHER category. I tried that but it seems I'm still doing something wrong (see code at the end of the message). The results I get are: * Two launcher entries (Ativity A and Activity B) are placed in the activity list in Home * Clicking first on Activity A will start Activity A. * Going back and clicking on Activity B will start Activity A again. * If I click on Activity B the first time after install, B is started and going back - clicking on A, starts B again Any hints on what I'm doing wrong? LogCat: INFO/ActivityManager(55): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} flags=0x1020 comp={test.activity/test.activity.ActivityA} } INFO/ActivityManager(55): Start proc test.activity for activity test.activity/.ActivityA: pid=13716 uid=10036 gids={} INFO/jdwp(13716): received file descriptor 10 from ADB INFO/ActivityManager(55): Displayed activity test.activity/.ActivityA: 872 ms INFO/ActivityManager(55): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.HOME} flags=0x1020 comp={com.android.launcher/com.android.launcher.Launcher} } INFO/ActivityManager(55): Starting activity: Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} flags=0x1020 comp={test.activity/test.activity.ActivityB} } Code: ?xml version=1.0 encoding=utf-8? manifest xmlns:android=http://schemas.android.com/apk/res/android; package=test.activity android:versionCode=1 android:versionName=1.0.0 application activity android:name=.ActivityA android:label=Activity A intent-filter action android:name=android.intent.action.MAIN / category android:name=android.intent.category.LAUNCHER / /intent-filter /activity activity android:name=.ActivityB android:label=Activity B intent-filter action android:name=android.intent.action.MAIN / category android:name=android.intent.category.LAUNCHER / /intent-filter /activity /application /manifest public class ActivityA extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText(ActivityA); setContentView(tv); } } public class ActivityB extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText(ActivityB); setContentView(tv); } } -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Is it possible to have 2 launcher Activity in a single apk?
Yes :) Just put two activities in your manifest, both with the LAUNCHER category. On Mon, Feb 2, 2009 at 10:45 PM, j jac...@gmail.com wrote: I need to have 2 launcher activities (i.e. 2 icons on the home screen). Each launch icon would launch a separate activity. Essentially, I need a single apk which contains a suite of 2 apps which I don't want to distribute separately. Is this possible? -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---