[android-developers] Re: android design pattern
Actually, you only need one line of code. But for clarity(?) you could add a helper method either as a static method or extend Activity as Kumar suggested. fromActivity.startActivity(new Intent().setClass(fromActivity, Main_Form.class)); -- 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
Re: [android-developers] Re: android design pattern
Correction: ...with exisiting *activities* such as MapActivity, TabActivity, ListActivity. -- 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
Re: [android-developers] Re: android design pattern
Three lines of boiler plate. Not sure if I'd bother refactoring that! But anyways... You might have issues using the Activity subclass pattern becasue you can't do that with existing patterns. Here's another approach. In your home activity, or in a Global class, add a static method: public static void startHomeActivity(Activity fromActivity) { Intent i = new Intent(); i.setClass(fromActivity, Main_Form.class); fromActivity.startActivity(i); } In the other activiities, you then simply call Main_Form.startHomeActivity(this); -- 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: android design pattern
I see. thank you Kumar. On Sep 6, 3:25 pm, Kumar Bibek wrote: > There can be many ways of doing this. What I regularly use, is to have > my own Activity class, say, MyActivity which extends the Activity > class. > > All the other activities in my application extend MyActivity instead > of Activity. In Activities, I have a few methods, which I think would > be used by almost all my activities, like firing intents, showing > toasts, dialogs, etc. > > So, in MyActivity, you can have a method, startIntent(Class class), > and write these three lines of code here. > > Now whenever you need to trigger an intent, just call this method with > the target activity class. > > -Kumar Bibekhttp://techdroid.kbeanie.com > > On Sep 6, 12:13 pm, xc s wrote: > > > > > Actually I also do this. -- 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: android design pattern
There can be many ways of doing this. What I regularly use, is to have my own Activity class, say, MyActivity which extends the Activity class. All the other activities in my application extend MyActivity instead of Activity. In Activities, I have a few methods, which I think would be used by almost all my activities, like firing intents, showing toasts, dialogs, etc. So, in MyActivity, you can have a method, startIntent(Class class), and write these three lines of code here. Now whenever you need to trigger an intent, just call this method with the target activity class. -Kumar Bibek http://techdroid.kbeanie.com On Sep 6, 12:13 pm, xc s wrote: > Actually I also do this. -- 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