How to maintain state of android activity - android-widget

I am new to android.I created an activity in which i add text view dynamically on button click event.After adding text view i click home button of my phone.When i start the application after 1 or 2 hour the added text view is disappeared.Kindly help me out to solve this issue.
Thanks in advance.

That probably means that your application has been terminated at some point by Android.
Even if you press the Home button leaving the app running in background, it can be killed by the system if it needs to free resources.
Here's how to use SharedPreferences to save the application status and restore it once the app is restarted: http://developer.android.com/guide/topics/data/data-storage.html#pref

Related

How to detect hardware key taps?

I am at a point where I need to detect if any of the hardware buttons was presses when the flutter app is in foreground or when it is open.*
For example, when someone presses a volume or another button (even if it is the power off one) I want to perform some action in my app.
I know that when a flutter app is open and I am looking at the app logs and I tap any hardware button is tapped the lops related to that tap is printed in the logs.
Like when I press Vol down Key Down Tap Detected related logs are printed in logs.
How do can I perform a function when any of the above specified action is performed?
New plugin called Hardware Buttons was released just a few days ago.
It supports volume button events and power button events, which seems like fits your need.
Maybe have a go with this?
You will need find the proper flutter packages to do so.
Any system level call needs to use the platform channel api
https://flutter.io/platform-channels/
Here is the repository
https://pub.dartlang.org/flutter/
Here is an example of a method channel.
https://github.com/flutter/plugins/blob/master/packages/device_info/lib/device_info.dart
Here is an example of a stream listener.
https://github.com/flutter/plugins/tree/master/packages/sensors
The stream listener wasn't really well documented when I tried to grab mic fragments.

SAPUI5 Fiori app warning Can't remove control from a non-managed category id: _POPOVER_?

While Navigating to home from Fiori Header and also reloading the page it's taking more time to reload and navigating to Home.
in the console, I have seen many warnings repeatedly like
Can't remove control from a non-managed category id: POPOVER .
all these making my app navigation to home and reloading makes slow.
Can anyone please help me on this.
Thanks,
G Srinu
Presumably, the app has a popover which has not been destroyed when the user selects home (on the launchpad). The popover should be destroyed when the app is exited.

Suspend app option

I have an app that i have and I have it set to NOT run in background but a number people want to option to have it resume from where they left off and a number of people just want it to start from the beginning when they tap the home button and restart to app. How do I add an on/off switch to give the user the option? My app is a educational / reference app with flashcards and pdfs.
Thanks
J
Create a settings bundle as described here.
Add your setting as a boolean value. Have it default to the way most people will use your app.
Now at launch read the value of the setting and act accordingly. The setting will appear in the System Preferences app under your app's name.

how to load aplication from start up page each time in iphone

I have application for iphone i want to open it from start up page always but when i load first time app on ipad it loads from startup page but when i close app and second time run on ipad then it opens from the same screen from where i left i want that again it should open from startup page also.I have start up page with enter button when i click to button i move to calulations screen where i perform calculations .If i close on calculation screen the app when i again open it it opens from calculation screens not from the startup screen
In plist file add one more field
Application does not run in background : make it true
This is your perfect ans.
Second time app will be in Background thats why it is not starting with start app page. Dont allow application to run in background. Set Key "" in info.plist file
You should add in your plist that property :
UIApplicationExitsOnSuspend
This will allow your application to "restart" instead of saving its state. This will allow you to load the start up page each time.
(documentation)
Well it is discouraged by apple , according to it's documentation:-
There is no API provided for gracefully terminating an iOS application.
In iOS,user presses the Home button to close applications. Should your application have conditions in which it cannot provide its intended function, the recommended approach is to display an alert for the user that indicates the nature of the problem and possible actions the user could take — turning on WiFi, enabling Location Services, etc. Allow the user to terminate the application at their own discretion.
Warning Do not call the exit function. Applications calling exit will appear to the user to have crashed, rather than performing a graceful termination and animating back to the Home screen.
Here's the link to it.Anyway nobody stops you from using
exit(0) , but is discouraged.
Another way to do is is simply change your application's pList property "Application does not run in background" to true.

Prevent cached iPhone webapp from reloading (scrolling to top)

I have an iPhone webapp that uses a cache manifest to work offline. I add the webapp to my home screen, use it (say scroll to a certain location on a page), then go back to homescreen.
When I open the app again, for a brief moment I see where I used to be (at that scrolled location on that page), but then the app "reloads" and I get scrolled to the top of the mainpage. Is there a way to prevent this "reloading"? This happens even in airplane mode (ie everything is working off the cache).
You're just seeing the default startup image, which is just a screenshot of the last place you were at. It's not "reloading"; the app wasn't loaded to begin with.
Search for "apple-touch-startup-image" to set a real loading image.
What I'm struggling with here is that the app actually seems to stay "in memory" longer if I use regular Safari as opposed to running in "apple-mobile-web-app-capable" mode. In the later case something as simple as pressing the home button, then task-switching back to the app causes a reload. Doing the same thing just in Safari often does not reload. So I'm worse off by using "apple-mobile-web-app-capable".
I don't believe there is a real 'reload' event. onload and onunload are all we get.
the onload handler starts up as if it is your first time coming to the page.
the onunload handler is the key to clearing out old content.
I like to provide alternate content for people who are coming back to my web app.
window.onunload=function(){
document.getElementsByTagName('body')[0].className+=' unloading'
}
And let the CSS do the dirty work to hide most of the body and show alternate content.
(this answer does not rely on jQuery or other frameworks)
// on load
window.scroll(0,0);
To ensure no old content is displayed while launching I use this in my page:
window.addEventListener('unload', function() { $('body').hide(); } );
Thus the last state of the page is empty and is what is shown to the user when the page is opened again.