I got a little problem with my app and I hope you could help me.
I developed an android app which contains an activity with fragment container which by default contains a pageviewer and through a navigation bar you can populate some more fragments.
In each of the fragments there are items, and when you click them they start a new activity.
Everything is working great until I drive my app into a state that the android OS kills its process for other apps, as described in the picture :
After I return to the app the listview is working fine, however when I click an item the new activity doesnt start, and the application just stays on the same page and for some reason OnResume() is called.
I check with debug messages and the OnClick function is working and the intent looks exactly like before the process kill.
Moreover, if I navigate to a new fragment everything is working fine.
Hope someone has the answer,
Thanks
Related
I am working in an Android project. I have 3 Activities (Home, Loading, Menu). The first activty (Home) calls in a background task (when the server answers) to "Menu Activity", but, meanwhile the "Loading" Activity is called for displaying feedback to user. My problem is that when I am in the Menu Activity and I press the back botton, the app shows the Loading activity, and it is wrong. I have been testing different flags, but I have not get the solution.
Can anyone help me, please ?
I am developing my first app now and I see that whenever I click on a new activity it opens up and everything is fine. I can also go back to the main activity and then open a different and it all works.
However once I open the task switcher, all the previous activities show up. They all show up as seperate apps and if I click on one of them that is not the main activity I cannot go back the to the main activity its like its very own up with just that activity.
This is very strange. Does this have to do with how I implement the onDestory method? Because to be quite frank I never used it.
Please help me!
Thank you!
I have created an app. which contains MainActivity->inside fragments class loading with some UI works..
After I have tried to pass some datas to new Library Activity (inside one fragment available with make some works and need to get back result.)
Problem: when i open new activity, its showing two separate apps like..
starting Activity Page and Library Activity.. But, after entered library activity, finish the work and get back result to MainActivity Successfully..
Note: Even, Library Activity showing as a seperate App. thats my problem.
Please help..Thanks for Advance
I am developing an app which has a FragmentActivity in which I have an ActionBar with 3 tabs at the top. In each tab I am loading a particular Fragment.
The thing I want to know is when my application is in foreground and suppose user was seeing the third tab and then he presses the home button, the application goes in background. When after some time when he taps on the application icon on the homescreen the application will come in foreground and at point of time I want the user to see a particular tab other than the third tab. (which is default behavior).
How can I achieve this ?
I tried using
actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(SectionIterator)).setTabListener(this), true);
in onCreate() method but this works only when app is started for the first time and not when app is brought to foreground from the background.
Any insight is appreciated.
The way i accomplished this is as suggested by #Omer using the onResume() method.
Inside the onResume() method I have written the following code
ViewPager pager = (ViewPager)findViewById(R.id.pager);
int DefaultTabToBeSelected = vGetValueForDefaultTab();
pager.setCurrentItem(DefaultTabToBeSelected);
Use the onResume() method. this method gets called whenever the user comes back into your application after leaving it (but not killing it entirly)
I'm experiencing kind of strange behavior of my application after hard Home button is pressed.
When you press Home, everything is OK - my app goes to the background, showing Home screen. But if you try to choose my app in the main menu or in the list of last tasks it behaves like it was not started before and does not show the last activity you were on - it just starts from scratch, namely, shows the splash screen and starts next corresponding activities. Moreover, old activities of this app remain on the activities stack, and previous instance of the app is not terminated - so if you press Back for a few times you'll just run into those activities which were undoubtedly started during the previous session of work with my app. Splash screen activity is filtered by "android.intent.action.MAIN" filter and "android.intent.category.LAUNCHER" category.
The strange thing is that all of that happens despite the fact that I do not intercept any Back key hits, or override any onPause or onResume methods. What's happening contradicts with my understanding of Android app lifecycle - I was sure that when you hit Home an app just goes to the background, and when you choose it in the menu later - it just unwinds and does not start anew. (Of course, unless stuff like that is stated in the app manifest or corresponding methods are overridden or something else).
I also checked it for some other lifecycle events - such as changing orientation or flipping hard keyboard out - and none of those led to such strange results. It appears that the problem occurs when you try to start the app from main menu or menu of last applications.
I hope you will be able to help me. Any advice on what to pay attention to or where to search for solution would be really great.
Regards, Alex
You need to set android:launchMode="singleTask" in your LAUNCHER activity in your manifest file.
For more info on the launchMode attribute see here
Note that:
The default mode is "standard".
and:
Every
time there's new intent for a
"standard" activity, a new instance of
the class is created to respond to
that intent.