Android SDK creates FragmentActivity instead of Activity - android

I came across this article but this article suggests replacing the FragmentActivity's code with that of the old Activity code. I can do that but would like to know if there's a way to just create Activity instead. I updated to ADT v22.6 today. Could that be the problem?
Another problem is that this requires a min-SDK of 7 while right now I want a min-SDK of 3.
Also, I am using Eclipse and not Android Studio.
Thanks in advance!

The new ADT 22.6 has new feature added that it will automatically create the any new activity as FragmentActivity not an single activity. So if you wish to create an Activity you can create it by explicitly creating separate class and extends Activity.

I'm afraid that google is enforcing us to use fragments activities instead of plain activities now. You either can go back to an SDK previous to 22.6 or just create the activities by just extending the class, adding a layout and adding the activity reference to the manifest.

Related

Create new android project with out Fragment activity in eclipse

After the ADT update in eclipse whenever I create a new project for android a default fragment activity is created. How to get to create simple activity always?
I don't want to downgrade the ADT.
Is this possible? any work around?
The latest ADT plugins are made in such a way that if you create any simple project you will always get the FragmentActivity not a simple Activity. And you can not change it.
In new ADT itself there is Blank Activity that is defined with an actionbar and optional navigational elements such as tabs or horizontal swipe.
If you want to create simple activity in your project then you can simply create class and extends Activity into it, this is the only way now. Or you can change the Fragment with Activity simply by changing code only.
As an Activity is simply a Java class, just accept the defaults the ADT gives you during the initial creation of your project. Create your project, then manually:
1. Delete all the class and layout files in your project.
2. Create your Java class files extending Activity (in your desired packages).
3. Create XML layout files (in the res/layout folder).
4. 'Wire-up' your Java class files and XML layout files using setContentView(R.layout.YOUR_LAYOUT_ID) in the onCreate() methods.
5. Done!
EDIT
Remember to Register your Activities in the Manifest manually as well.

Fragment Layout Name

I have been using Android ADT for a few weeks now and i used to normally create new activities by going to:File>New>Other>Android>Android_Activity>Blank_Activity. However after updating my 'Android SDK Tools' & 'Android SDK Platform Tools' today , its now showing a new option when I'm trying to create an activity.
When I select new blank activity and click next , its then showing a new form that i have to fill in which is titled as 'Fragment Layout Name'. Why has this suddenly appeared and does anyone know why I'm being forced to create a fragment layout as i don't want to even use this. I also remember one of my friends saying that he updated his SDK about a week ago and he stated that he had the same problem. Shall i just remove the fragment in the XML document once its loaded or is there a way to disable this so i wont have to go through this every-time.
The templates of files produced by "New ..." wizard have changed lately. Now you are enforced to create a new Activity with a Fragment placeholder attached. Guess that's the way the developers enforce people to build UI based on Fragments :)
There are a few workarounds for your problem:
1) Just delete fragment layout in your resources; delete the placeholder fragment in your Activity code and all the relevant code (FragmentManager etc); change activity layout from FrameLayout to anything you like.
2) Follow the recipe proposed in this answer
3) Don't. Ever. Use. Wizards. It is much better to create a new class and write extends Activity (or Fragment, Service, etc), than to create a template and waste your precious time changing it to your needs. And it helps to understand the lifecycle of components, too.

How to call a new activity without calling a new "window"

I am trying to call a new activity using an intent, but every time I call it, I can see a new "window" open on my android device. Can I call a new activity that will be in the same window? What I mean is calling new activity without visually seeing that it has been opened.
Hope you understand my question :) Thank you!
I think what you are looking for is Fragments
Start reading Here
Fragments actually use the "same" window (Activity) and just replaces layouts and views - I think exactly like you want.
If you want to run something like a unix-demon code(this mean a program that is only executed in the background without no visual components) you are looking for a android Service.
http://developer.android.com/guide/components/services.html
Otherwise if you are looking for a visual component that don't create new windows but refresh the old one, you could use the Fragment class if your android version is 3.0 or higher.
http://developer.android.com/guide/components/fragments.html
In an Activity content view, create an empty relativeLayout.
As mentioned in previous answers, create fragments and replace this relativeLayout with the newly created fragment using FragmentManager.
FOr reference use this.
Its really easy. try this.

android adt bundle automatically extending ActionBarActivity and adding fragments and more stuff?

I just want to make a simple Hello world app that extends Activity but when I create a new android project it add all this extra stuff. It didn't use to do it before,but now everytime I create a project it extends ActionBarActivity and creates a fragment layout and has code for fragments and its no longer the simple project I used to be able to create.
How do I fix this?
I too had the same problem and this is how I fixed it.
When you create new Android Application Project, select Minimum Required SDK as API 14 or above.
If you want to support API level < 14 you can change the "minSdkVersion" in AndroidManifest.xml manually after creating the project.

What is difference between FragmentActivity and Activity?

I have used it in my basic code replace activity by fragment activity,but i have not got any kind of error.Application has working.
As seen in the documentation:
FragmentActivity
Base class for activities that want to use the support-based Fragment
and Loader APIs.
Activity
An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with setContentView(View). While activities are often presented to the user as full-screen windows, they can also be used in other ways: as floating windows (via a theme with windowIsFloating set) or embedded inside of another activity (using ActivityGroup)
Can see more at : http://developer.android.com/reference/android/support/v4/app/FragmentActivity.html
A fragment activity can contain fragments (as it's name implies). It's the support version of activities for older APIs, which want to use fragments.
A Fragment , introduced in Android 3.0 HoneyComb is a portion of a user interface inside an activity. You can have many fragments in you UI.
FragmentActivity is the base class you must extend in order to use fragments with the support library.
The nuance here is that an Activity can use Fragments from the native SDK (as long as you are targeting API 11+), while a FragmentActivity can use Fragments from the support library.
So, assuming API 11+, if you are using android.app.Fragments in your app, you can use Activity, but if you are using android.support.v4.app.Fragments in your app, then you must use FragmentActivity.

Categories

Resources