Reputation: 145
Firstly, I'm new to Android (so I apologize if this question is ignorant) but have some experience in Java. I have been reading a book on Android and remain slightly confused about the basic components (activities, intent, content providers, and broadcast receivers).
I have a few java classes that I'm wanting to convert over to Android but I'm not sure what type of components they should be.
If a class does simple conversions, should that be an intent? Or, if a class draws, should it be an activity?
I'm just looking for someone who can explain the components a bit better than the references at android and perhaps give some good examples of each component.
Upvotes: 3
Views: 131
Reputation: 1626
I think you're confused about some of the terminology. An activity is what the user interacts with (displays the content, contains the listeners for buttons, etc.) So when you launch an app and see something on the screen, an Activity is what draws all the buttons/components on screen and contains the code for user interaction. An intent is kind of a way to tell activity to launch something else. For example, if you were on your main activity, and wanted to change the Activity when the user clicked something, you would create and start an intent specifying that:
Intent intent = new Intent(CurrentActivity.this, NextActivity.class);
startActivity(intent);
Read this basic tutorial. It should be somewhat clearer than the official docs. http://androiddevelopertips.com/activity/understanding-activities-in-android.html
Upvotes: 3