I am developing an Android application, and I want to show some tips (few slides) for user when applicationis started first time.
I can make an activity and start it in OnCreate method of main activity, or make dialog window.
I want to ask: how to make it in the right way? Can experienced developers advise something, maybe with example?
You have to first make sure that these tips are launched only on first launch of app. I have seen this done by displaying a Dialog, and saving a value to shared preferences (or in sqlite for that matter). On next app launch this value is checked, if it is set, then you don't display the Dialogs.
This seems to be the simplest way. Note that when the app is uninstalled and installed by again the Dialogs will be displayed again.
Sometime we want to give the user ability to see this Dialogs once again. You can do this by setting/resetting the value in shared preferences from the apps settings screen. The user can change the value here and see the Dialogs again on app start.
Just make a Dialog Type Activity and show it automatically at the first time startup of your application.
and also add a help in you menu so that user can see it whenever he/she need help.
Related
I want to make application with activity "UserIntro" that shows ONLY when app is installed and asks user some questions about himself. But latter when user starts app again that activity doesn't appear.
Does anyone know how to accomplish that?
Thank you for the answers!
Use Shared preferences to store a boolean first time the app launches. As the boolean won't exist first time, just check for it's existance upon startup and manually launch an activity.
i just want to know how can i detect if the user opens an app so an activity of mine launches as well.
For example, the user opens the sms app and right after a kind of lockscreen appears.
You can create a service which will run int the background and you can use this API to determine which activity is visible. That's how many app lock works.
As far as I understand the Android system, it is not possible unless you are making a custom firmware.
In my application, I used a library that displays ads in my app. When a user clicks on the ad, it launches the Browser app, and the onClick events are handled by the library itself.
I also have a placed code in onPause() and onStart() methods that detects whether any of my Activities are sent to background (user pressed Home) or switching between any of my Activities.
So if the app is either freshly opened (no instance is running) or re-opened from background, it will display a dialog box. If the user is only switching from any of my Activites, then the dialog box shouldn't be displayed.
Now the problem is that when the user clicks on an Ad, the Browser app gets loaded and would mean that my App has been sent to background, and so when the user closes the Browser, it will still display the dialog box when it shouldn't.
Is it even possible for my App to determine the previously displayed external Activity (ie. Browser) and not display the dialog box?
Or are there better approaches that I can follow in implementing such setup?
Thanks in advance.
I don't think that there is a way for your Activity to know, which was the previous activity. A simple work-around is to save the time the dialog was displayed and not displayed it again, before some time passes. You can decide on the exact time period based on your application's requirements.
This may be in fact better in some situations. If the user switches from the Browser to your application and it has been some time he has used your application, it will be appropriate to show the dialog again.
you can use onResume() method to specify the behaviour when your activity get back from the background.
Can someone point me in the right direction to have an Android Application reopen itself to the forefront after a user has pressed the home key? It should be able to be linked to some kind of countdown (which I already have setup, and runs when pushed to background).
I just can't find the function to force this action
*And yes, this is what the user will want, don't worry, I know this doesn't sound user friendly (forcing open) but in this case the user wants it.
Thanks
I needed the exact same thing before -> an app being displayed upon an event but I was sure I read on the Android developers site that this can't be done and that's what notifications are used for, although starting a new activity does bring an app to front. I found this link however to a NEW_TASK_LAUNCH flag with startactivity that might solve your problem -
http://developer.android.com/guide/appendix/faq/framework.html#4
I need a way to detect if this is the first time the user is ever opening the application, if so, start an activity. Then all previous application launches wouldn't start that activity. I've read in a few places about using preferences to accomplish this. Anyone got any ideas?
Yeah, preferences is the way to go.
Check for the existence of the preference flag, if that exists you have already set, so your application was already started. Otherwise start your welcome activity and set the flag for future.
You can also disable one main activity and enable another one after your intro has run. See: the docs for PackageManager.setComponentEnabledSetting.
what if you have a user who deletes the application data in the device settings. This also removes the sharedPreferences data. The OP said he/she needs a way to determine if "ever" the user has opened an application. Shared Pref is not full proof.