I am setting a background Image in my first activity which fits the complete screen in XML code only.
From the first activity user navigates to another activity which does something from an image selected by a user.
Now, my point is since the app loads an image for the user , is it feasible to remove the background image from first activity. And are there chances of app getting crashed if I don't remove the background image while migrating to the second activity.
Related
In my Android app, I have second activity (a Unity game) that I launch from a button click. The problem is that there is a significant loading time that it needs to go through before opening up. Once I press the button I would like it to launch in the background but have the first app still open while the second one finishes loading.
Does anybody know how to do this?
Many thanks.
Based on your comments, you should first create a Loading Scene inside Unity and launch it as first scene when starting the second Activity and than inside your Loading scene start loading in the background the level you want to show. There is no way to load the Activity in the background and then show it once it's ready.
And another thing, keep in mind that Unity is loading native libraries and there is no way to open it as fast as a normal Android Activity.
The main activity is a login page. I have included a splash screen as well. What I want is to apply animation to the splash screen. For that, I am trying to put it in a separate fragment. How can I do this?
I have created a theme and everything that is needed to implement a basic splash screen.
Most of the apps(youtube, facebook etc) don't have an animated splash screen because, all the code initialization drops a lot of frames in your app. These frame drops will be clearly visible if you try to animate the screen.
For your animations to be smooth, a frame has to be drawn every 16ms. Even if one frame is not drawn, users can see the change... what this means is, if you are jumping a ball on ur splash screens.. the easing function you apply to the animation will not work as expected.
Solution:
In your launcher activity, just have a simple ui. As minimal as possible. This will give the user a feeling that app launched quickly. Once your initializations are over, you can attach your fragment which can have the same UI as activity and then make any transition.
In practice:
Launch activity A(launcher) -> UI can be a simple white screen with your logo in the center of the screen.
Once your initialization(all the libraries that load in your Application class like firebase, ORM, analytics tools ect) is over, attach your fragment with a screen containing the same white screen and logo.
This way the user will not know transition from activity to ur fragment as the UI is same. Now you can do any kind of animation in your screen. The initialization time varies from application to application and phone to phone.
I want to show a splash screen between my first and second activity. Both the activities make use of AsyncTask. First being a simple login screen retrieving data for the whole app and second loads the activity specific data. Currently, both the activities have their own ProgressDialogs which is quite naive but they were developed individually and then I wasn’t planning to put them one after the other.
I tried to implement the splash screen only replace a loading process from one activity. But, in order to place a splash screen in between them do I have to transfer all the loading process to a single activity? Which activity should contain the code for the splash screen? I basically want to replace two ProgressDialogs by a single splash screen. What should I do?
I think the simplest way would just make a transitional activity that displays a splash screen, preloads the data for the next activity, then launches the next activity.
Activity A loads Activity B which shows the splash screen while simultaneously running the AsyncTask. Once the AsyncTask completes load Activity C.
I hope I understand your question correctly :-)
I use a Gallery view to display set of images in the header part of my application's main page. Now I need to make the Gallery full screen when user click on any gallery image. In the full screen mode it should have the Gallery functionality (Should be able to move between images...). Finally, in the full screen mode, when user click the image, it should go back to normal screen.
It this possible with Android? Please help me.
Unfortunately you haven't told us what you've tried or haven't and thus it's hard to pick a starting point...
How I would do it, might be a little over kill using an added activity but I prefer the organization, but launch a new activity on view click and pass the strings of the paths in a bundle and the index of the one selected. Then create a bitmap or imageview, however you want to do it but make sure it can have a setOnTouchListener. This way you can use the MotionEvent to see if they swiped left or right and navigate through the list of images you passed to the activity as strings.
If you don't feel like doing bundles, you can make a static class that holds all the image information..
In my app, I am letting the user to select a background image(from a gallery of images using Gallery), i.e., on clicking a button, lets say, 'theme', 3-4 images are shown, and the user gets to select one of the images.
Now as soon as he does that, the image should appear at the background of the activity..I am trying to save this choice, by the user, in my database..
but I really have no idea how to proceed, that is, when the 'theme' button is selected, a 'themepick' activity starts, and a gallery of 3-4 images appear...when the user selects an image, this themepick activity is 'finished' and we go back to the initial activity..now in this activity, I am letting the user enter some data(through text fields) . After the user clicks save, the data is going into the database, and is being retrieved well. But i also want to save the path to the selected image(from the themepick activity), to the database, and when I am retrieving all the data and displaying the data(in a separate activity, lets say), the image should come in the background as well.
I tried to elaborate as much as possible.
I urgently need a solution as my submission is due in 2 days.
Thank you!
Use a SharedPreference.
You question doesn't seems to be specific on your problem . If I understood correctly your trying to set a background of an layout on runtime.
You need to find the layout Id and set background as below
View layout= findViewById( R.id.layout);
Bitmap bitmap = BitmapFactory.decodeStream(stream); // your image file stream from a path
BitmapDrawable bg = new BitmapDrawable(bitmap);
layout.setBackgroundDrawable(bg);
Let me know if it helps u.. :)