I have a scenario in which I have to move to app settings screen from my current app activity. There is a dialog that does this. When I put the dialog open and goes to settings screen explicitly and change something, the button of the dialog that has to take me to app settings does not work. Any help please ?
If you don't want the history, can you try:
Intent.FLAG_ACTIVITY_NO_HISTORY
Intent.FLAG_ACTIVITY_CLEAR_TOP
Intent.FLAG_ACTIVITY_CLEAR_TASK
Related
I've been trying to use FLAG_SHOW_WHEN_LOCKED and FLAG_DISMISS_KEYGUARD to display an activity each time someone turn the screen on. It works well most of the time but there is some case causing strange behaviour. This happens when the activity is already existing and I send it a intent after it has been moved back in the history stack, by using the Home button.
First, if I press the Home button when on my activity, then switch the screen off and on, the activity is expected to be displayed right away as it was. However what is displayed instead is the basic android lockscreen. My activity is behind.
Worst, sometime, if I touch the home screen, then turn the screen off and on, the home screen overlay (all appli logo and widgets) are displayed with my activity in the background!
The intent I am using each time the screen is turned off to laucn and recall the activity :
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);
context.startActivity(intent);
So, it seems that when my activity is in the history stack, it sometimes does not correctly get recalled and bypass the android lockscreen. Is there something wrong with my intent?
Add more flags :
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
Wither via Intent.addFlags() or using getWindow().addFlags() from your activity. These flag will disable lockscreen when your activity is started
This will solve your query
Reference Answer : Here
You can integrate the Adenda SDK in your app to achieve what you're after. They let you display what you want on the lock screen relatively easily.
I'm affiliated with Adenda, for full disclosure
I have an app that shows the user a profile edit screen the first time he or she uses the app. Within the edit profile activity, I need to allow the user to create a profile image capture an image or select from the gallery.
I want to be able to catch OnActivityResult, but once they are done with
editing profile, I don't want this to be on the stack. Setting noHistory to true kills the activity and I can't catch the result.
I want this for first time:
splash screen----> edit profile ----> main menu.
When the user presses the back button from the main menu, I want the app to stop, not pop edit profile from the stack.
Any idea on how to set noHistory after I've gotten OnActivityResult?
According to the documentation there is no way to get result in activity that is specified with "noHistory"
In this case, onActivityResult() is never called if you start another
activity for a result from this activity.
You can try to achieve desire result by clearing existing stack like this:
Intent i = new Intent(context, MainMenuActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(i);
It should start new task based on main menu activity.
I have an app widget on the home screen which includes a button that launches a basic settings Activity.
When the user presses the Back button, if the main application has some activities in it's stack, the back press takes you to the most recently viewed Activity in the app, rather than back to the homepage. I've tried the following flags for my intent:
settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
settingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
But no luck with any. Is there any flag or combination of flags I can use to do this? Thanks.
You need to do the following:
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
You are currently using setFlags which overrides the flags you set previously when you need both of these flags for it to work correctly.
You can read abut this at http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP
try next
settingsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
settingsIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
This flags run activity in new task and don't add it to history after exit.
So your settings activity don't cross with main app
I am developing an application in android. I am new in android.
In my application I have a category selection activity from that user have to check a check-box, based on that he will get view on another screen. I have a menu button in 3rd screen in that I have a button for selecting category, when I click on that button its also works fine but when I click back button it will redirect me 2 times at same activity... How to remove this problem? I have used finish() method but its also creates problem its get's me out from the application directly...
I want redirect to selection activity and it should not show me 2 times when I click back button ....
Is there any way please redirect me thank you.
a call to finish() should work so you schould check your code for multiple calling the wrong method or something like this.
Intent intent = new Intent(activity, activityClass.class);
activity.startActivity(intent);
finish();
you should also take a look at the Intent flags:
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
Your question isn't clear enough for me to know if this will solve your problem, but if you include the following attributes on your Activity in AndroidManifest.xml, the so-attributed Activity will never appear in your history list.
android:excludeFromRecents="true"
android:noHistory="true"
As for removing something from the history, I'm not sure how to do that, but I'm interested in the answer!
You should call finish before you call Intent and go to next activity. so the current task is finished and will not be saved in stack and then you intent activity will come on top of stack. If you directly want to go to Selection activity, override onBackPressed() and intent to the activity you want to go to.
There are different flags that you can use to control how your activity interacts with the activity history stack. Two that might be of interest to you are FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_NO_HISTORY.
I am developing an application and its Home Screen Widget.
Now from my widget when i press on a button it would open up my application from where it was left.
Means if i press home button during my application running then my application will go in background mode.
Now i want that it should resume my opened application.
Whenever i press a button from my Widget. How Can i Do it??
Please help
Thanks a bunch in advance!
I've never made a widget before, but this is how I've made a notification launch back into my original activity when you pull down the bar and click it.
Intent originalActivity = new Intent(getApplicationContext(), Widget.class);
originalActivity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
Once again, not sure how you would do this with a widget, but to relaunch it for a notification you convert that Intent into a PendingIntent to be called later when you want to launch back into it. I would assume this is a similar fashion for how you would it on a widget.