Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fragments vs. Deprecated TabActivity on a pre 3.0 device

So now that the TabActivity is officially deprecated as of 3.0, I'm going through and switching all of my TabActivities to Fragments. But first I decided to research a little about Fragments

I'm reading the design philosophy and one of the lines is:

Android introduced fragments in Android 3.0 (API Level "Honeycomb"), primarily to support more dynamic and flexible UI designs on large screens, such as tablets.

Now, I'm not developing for a tablet, nor will my app ever see a tablet. Barring the bad idea of using deprecated code, what do I have to gain if I'm not going to use a big screens or animations, which seems to be the main thing they are touting?

like image 636
Otra Avatar asked Jul 21 '11 18:07

Otra


1 Answers

Now, I'm not developing for a tablet, nor will my app ever see a tablet.

That may only be the case if you're not shipping the app. Just because you are writing it for a phone does not prevent tablet owners from installing it. It may be that you are using hardware capabilities that tend to be used by phones and not tablets (e.g., telephony), but there's nothing stopping a hardware manufacturer from offering those capabilities in a tablet.

Barring the bad idea of using deprecated code, what do I have to gain if I'm not going to use a big screens or animations, which seems to be the main thing they are touting?

Fragments offer some benefits, such as simpler management of configuration changes, that are more annoying than they need to be without fragments.

More importantly, an increasing percentage of the Android UI will require fragments going forward. For example, as you note, tabs (particularly activities-in-tabs) are going away, being replaced by tabs in the action bar controlling fragments. Now, you may think that this is only for tablets, but it is likely that when Ice Cream Sandwich (ICS) ships later this year, the action bar and tabs will be extended to phones as well. While old-style tabs should still function on ICS phones, they will look odd by comparison. Whether or not "odd" is a problem is up to you, of course.

like image 167
CommonsWare Avatar answered Nov 10 '22 11:11

CommonsWare