Is activity same as Java Class in android? [duplicate] - java

This question already has answers here:
Classes vs Activities in Android
(2 answers)
Closed 4 years ago.
I have just started learning android and am not able to understand what an activity is. My question is, is creating an activity same as creating a new class? A class is just referred as an activity in android.
Also can't a UI screen have multiple java classes or one UI page will have only one java class?

From https://developer.android.com/reference/android/app/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)
We can say Activity is a Java class that the user can interact with.

Related

Is there any lifecycle method which will get called each time when a fragment is opened? [duplicate]

This question already has answers here:
ViewPager with fragments - onPause(), onResume()?
(10 answers)
Closed 4 years ago.
I tried to use onStart() but it doesn't invoke with ViewPager in some cases, especially when going to fragment from nearest tab on tablayout.
What can be problem?
Is there any other events that invoke explicitly?
Fragment#onResume() will be called when the fragment is visible to the user and actively running. This is generally tied to Activity.onResume of the containing Activity's lifecycle.

Where to fill out SQLite if user input isn't needed? (Beginner) [duplicate]

This question already has answers here:
Prepopulated database - Android application
(4 answers)
Closed 5 years ago.
I have done a lot of research about the SQLite database, and have already created a SQLite custom helper that extended SQLiteOpenHelper. However, I don't understand where to actually create the database and fill it out. I am trying to have the database be created immediately; I have all the information that needs to be inserted. In other words, no user input is required to fill it out.
Is the best practice to create an individual java class or activity that fills out the database, that can then be accessed by the activities?
Thanks - did a lot of research on creating the database and helper, just having trouble understanding this.
I am trying to have the database be created immediately; I have all the information that needs to be inserted.
Create the SQLite database on your development machine. Package it in assets/ and use SQLiteAssetHelper to ship it with your app. Then, you can query from that data (e.g., to display it to the user).

How to send an object from activity to fragment? [duplicate]

This question already has answers here:
Passing an Object from an Activity to a Fragment
(8 answers)
Closed 7 years ago.
I just want to use getActivity().data in my fragment to pull in the data object.
It's not working though. Eclipse says that data cannot be resolved.
It looks like there is plenty of information about how to use Bundle to do this.
However, I am wondering how to use getActivity in particular.
Although using Bundle is the preferred way and following way must be avoided but just to answer your question, try making the data variable static and access it by typecasting the activity ((YourActivity)getActivity()).data.

How to show the text at lock screen in Android [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I interact with the Lockscreen layout to display text into it, like this app:
I want to show some text to the Android lock screen same as like 'I Like It' android app has implemented. You can see the app on Google play from https://play.google.com/store/apps/details?id=com.ilikeit.main
Not documented, but this will work ;-)
String message = "This is a test";
Settings.System.putString(context.getContentResolver(),
Settings.System.NEXT_ALARM_FORMATTED, message);

How to make a rolling news banner on android? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
marquee text in android
in my app i want to have a news banner with the words moving to one side like tv .. i don't really know how to run that kind of animation .. and should the banner be a TextView ? i'm not really sure of anything .. so i just need the xml format of such thing, Thankss!
This is commonly referred to as a ticker or marquee. Here's a tutorial on how to make one.
Edit: Here's another tutorial.
Edit: Here's another stackoverflow question about the same thing.
Edit: And another.

Categories

Resources