Why Group Activity is Deprecated - android

I am Searching for the answer of my questions
Why Group Activity is deprecated?
I did not find any proper answer. My second question is
Why we have to use Fragment instead of Group Activity?
I need answer of these question in detail.

You can get your detailed answer by reading The Android 3.0 Fragments API blog. One of the relevant point is:
Embedded Activities via ActivityGroup were a nice idea, but have always been difficult to deal with since Activity is designed to be an independent self-contained component instead of closely interacting with other activities. The Fragment API is a much better solution for this, and should be considered as a replacement for embedded activities.
You can also look at Is it advised to build all apps using fragments? question. Hope it helped.

Related

How to convert Activities to Fragments?

I'm new to android programming pls help. It's just that I have this application modules created in Activities form. Now that I wanted to use the Android navigation bar to navigate between them, I can't do so, it seems that theres alot of things I would have to change such as the imports, the declarations, and omit certain methods etc. Is there a comprehensive manual for such task?. I just can't seem to find one. If there is, it's just limited to a few things. BTW, I just want to know how I would be able to do such task. If there is a for Dummies of it,would be the best.
Be better if it would also include the AppCompatActivity thing, I can't seem to combine it too with Fragments and Activities, :(.
You need to understand your app's architecture first. You need to analyse the flow of UI screens and the underlying logic they perform. If you want to navigate through your activities using Navigation Drawer, well, then converting all of them them into fragments isn't a solution! First find out which screens can perform flawlessly if you replace them with fragments and then go ahead with it. If you are new to android programming then visit Udacity online and watch all of their android tutorial videos! They have a bunch of comprehensive ones and the best part - it's free.

Which one to use with tabhost: FragmentActivity or TabActivity?

I'm beginner in android development. When searching the web I have found that it is possible to make tabs by having the separate activities for each tab or have fragments instead. I would like to know more about theory so, my question is where it will be appropriate to use fragments and where activities? I'm curious because there might be some considerable differences for example in memory, performance or UI. Hope that I'm clear and will appreciate any help.
After reading articles on developer site, particularly page below, I have found that TabActivity is deprecated. They advice to use FragmentActivity and with the help of v4 support library it can be implemented in older version of android.
https://developer.android.com/reference/android/app/TabActivity.html

Android Migrating from phone app to tablet

I've developed an android phone app in which the navigation is mostly activities and starting activities for results. I've read that in order to make the tablet layout look like 2 screens of my phone app one next to the other I should have made it with fragments. Is there another way to migrate my functionality to the tablet app? Meaning to keep the start activity for result but just concatenate two activities on screen? (it may sound stupid, I know). Thanks
In order to keep the software design simple and modular, fragments come in really handy. You can use the same fragment's UI design + working code in multiple places without changing much functionality.
Since you have the code built and running in terms of activities, it won't take much time to migrate/port it to a Fragment since the life cycle methods are pretty similar. All you need to do is study the life cycle of a Fragment and move code chunks from the Activity to the Fragment class.
You can study all about Fragments here - http://developer.android.com/guide/components/fragments.html
or maybe a training session here will help you more -
http://developer.android.com/training/basics/fragments/index.html
You will learn a lot and once you have tried it you will be able to comprehend the advantages in a much better way. In future always make it a point to design in terms of Fragments to have a much modular design.
Along with that I think you will also need to learn to design layout for multiple screen sizes. This link over here will help you understand how to support multiple screen sizes -
http://developer.android.com/guide/practices/screens_support.html
If a tutorial to do this very quickly is what you seek then this should help -
http://www.101apps.co.za/index.php/articles/converting-android-activities-to-fragments.html
All the best :)
It very depends on your app GUI structure. Sometimes, you even not need to adapt your GUI for tablet (if you build interface dynamically basing on screen dimension). As rule, if you have two screens where one screen is advanced or logical extension of other then you can union it into one screen on tablets for better informativeness. Secondary way, as rule, based on fragments.
You can achieve it with help of Activity group but it is deprecated in Api level 13, for more details please visit http://developer.android.com/reference/android/app/ActivityGroup.html, but I will suggest to go with Fragment as Fragment having nearly similar life cycle like as Activity with extra methods and features. Please refer link for more details http://developer.android.com/guide/components/fragments.html

Why we Choosing Fragment over Activity?

My doubt is why we choosing fragment over activity even i too read that it is reusable i has its own life cycle etc etc. But as a beginner its quite difficult to work on it . Then i Have an another doubt to so far what i did in my project is i have only two activity one is for login and another one is for navigation drawer and action bar rest of things are all fragment which comes under activity 2 is it right way to do with or am making mistake . Many fragments are coming under activity 2 like multiple fragment inside a fragment is it right way it may be dumb question as a beginner is quiet difficult to understand for me can anyone clarify my doubt
Fragments were invented for tablets in order to combine several fragments on one screen. Most commonly they are used in master detail relationships. Look at this question from this point of view. Does it make sense to put two fragments on one screen? Are they connected?
Read this article one more time to clarify when fragments are needed. http://developer.android.com/guide/components/fragments.html
1) You don't have to use fragments if you don't feel they are necessary for your application.
2) Having multiple activities is fine. Most applications do.
3) Having fragments inside fragments is permissible, but you should just be aware that it can cause odd behavior in your application if you are not familiar with the lifecycle events.
4) In the Android Dev Summit (2015), a great overview of a sample Android architecture was presented, I encourage you to view it: here
Hope this helps to clarify things some.

Android clean code: Fragment use?

My doubt here is how to achieve a clean and easy code to maintain over time in an Android app?, I'm trying to apply Uncle bob - clean code rules but as I keep going with development sometimes some rules must be broken, and I end with an Activity of 700 lines (I'm not using Fragment, and 700 lines seems to be a Class that "does too much things") so I want to know if someone has try an Android app with proper use of Fragment and could answer these questions:
1- does it really impact on Activity lines length (at least less than 300-500 [not strictly this numbers but a "reasonable" Class length] lines)?
2- does code keep clean and easy over the time?, not necessary with Uncle bob rules but considering best practice in OO while coding.
3- does it have a considerable impact in terms of "Performance"?
4- does Fragment help to support in a more simple way a wide fan of Screens?"
5- ignoring developer skills, what "should" be the way to go non-Fragment activities or activities with rich Fragment use?
Note: this is not an attemp of Duplication to Android - Activity vs FragmentActivity? since the topic here is not about tab format but best practice for android development.
sorry for my english ;).
You are conflating the use of fragments with the use of FragmentActivity.
FragmentActivity is a subclass of Activity designed for use with the backport of fragments from the Android Support package. You usually only use FragmentActivity if you are using the backport. If you are using fragments, but your android:minSdkVersion is set to 11 or higher, you can usually skip FragmentActivity.
With that in mind:
does it really impact on Activity lines length (at least less than 300 lines)?
That is impossible to say. It is equivalent to asking whether a Restaurant that subclasses Business will be longer or shorter than a Restaurant that subclasses FoodSupplier. It all depends on your code.
That being said, it is certainly possible that the use of fragments will reduce the lines of code in the activity. IMHO, that's not a good reason to use fragments.
does code keep clean and easy over the time?, not necessary with Uncle bob rules but considering best practice in OO while coding.
That is impossible to say. It is equivalent to asking whether a Restaurant that subclasses Business will be "clean and easy" compared to a Restaurant that subclasses FoodSupplier. It all depends on your code.
does it have a considerable impact in terms of "Performance"?
Not usually.
does Fragment help to support in a more simple way a wide fan of Screens?"
If by "wide fan of screens", you mean "a wide range of screen sizes", then yes, fragments can help with that. In fact, that's the #1 reason for using fragments, IMHO. However, fragments alone do not magically help with screen sizes, any more than having capital letters in method names magically helps with screen sizes.
ignoring developer skills, what "should" be the way to go FragmentActivity or Activity?
As stated previously, you usually only use FragmentActivity if you are using the backport of fragments. If you are using fragments, but your android:minSdkVersion is set to 11 or higher, you can usually skip FragmentActivity.
If your question really is "should I be using fragments in my app?", the answer is "probably, but it depends upon the app".
Yes, fragments are the way to go. They help spread your code around in a logical way so you don't have a 700 line activity, they keep your code easy because each fragment will have its own class usually, and they do, to answer your 4th question, make it easy to have "A wide fan of Screens".
I recommend this video to help get you started. For any beginners, this video is a great explanation of how to use fragments ( I know because I had a hard time figuring out how to use them until I watched this video). It is called "Programming Android with Fragments" by Andrew Ruffolo:
http://www.youtube.com/watch?v=KyXvq_kwfzg
This video demonstrates the power of fragments. You still need a main activity of some kind, but this main activity acts kind of like a container for the fragments, and most of the functionality of your app is handled by the fragments and their corresponding classes.
I have never used activities because I started app development after fragments were added to android, but it seems like fragments help break down your app in the same way that methods and inner classes help break down your classes, and the same way that classes help break down a project or program. I am not sure if this was possible or as simple using only activities before fragments were added.

Categories

Resources