I have an activity which holds 3 fragments and in the last fragment i show the accesibility dialog to turn on the service for my app , the issue is when i move back from the settings dialog , it does not redirect me to the last fragment from where i started the dialog , instead it restarts the activity .. i would like to find a solution on how to redirect from settings dialog to the last fragment in my activity , Thank you
Settings Code
val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
startActivity(intent)
Related
I have a button
When the user clicks on it, it will be redirects to a registration page
I want user to be redirect to a loading page after clicking on the signup button
And then i want the user to be returns to the main page
And I want a message with the title of "your registration successfully completed" to be display to the user
And after a few seconds, this alert message to be hide
Follow this way to activity switch
Intent intent = new Intent(RegistrationActivity.this, DashBaord.class);
startActivity(intent);
finish();
Suppose your registration activity is RegistrationActivity where you will showing your sign up button and HomeActivity will be the activity which will be shown to user after registering to the app successfully.
You have to maintain some variable so you can know if that variable is registered or not.
boolean isUserRegistered ;
if a user is registered successfully then,
isUserRegistered = true;
and save this varibale using SharedPreferences.For more info about SharedPreferences :
Android Shared preferences example
In the splash activity or some other activity where you will decide which activity to open put this check,
if(isUserRegistered)
//start HomeActvity
else
//start RegistrationActivity
I think your requirement is to create a signup Activity and on completing signup, the user needs to be redirected to Homepage and display a dialog with content "your registration successfully completed".
First of all you need to create a signup Activity. Then when clicking signup, display a custom dialogfragment indicating Loading. Show this dialog when user clicks the signup button. Then make an api request to complete the signup. On response of this api request, dismiss the custom dialogfragment and go to Home activity.
Creating a dialog Fragment : link
On going to Home activity, you need to pass the response of the API request along with intent. In the Home Activity, you can get the value passed along with the intent to HomeScreen to get the message you want to display. You can use an Alert Dialog or custom DialogFragment for displaying the info.
To dismiss the dialog after x seconds, you can use postDelayed(Runnable, long).
Creating a Post Delayed : link
In my app, I have four activities Splash -> Activity A -> Login Activity -> Main-Activity. Now when user is authenticated, I wanna clear current task and launch a new task for Main-Activity. For this, I have tried the below code.
var intents = Intent(this#Login,MainActivity::class.java)
intents.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK )
startActivity(intents)
finish()
So when i am in Main-Activity, hits the back button and launch the app again, it first shows (Splash-> Main-Activity) instead of showing Main-Activity directly. I also follow this link Clearing the Launcher Activity from the stack
but nothing happened.Please tell me anyone what should i do to make it work..
Keep flag for user Logged in for first time.
Check if user is logging in for first time.
If user is logging in for first time,show splash screen and then Main activity but if user has logged in ,then don't show splash screen. Just start intent for Main Activity
I'm trying to determine when the user opens a Chrome Custom Tab in Chrome (the "Open in Chrome" option from the menu).
My navigation callback returns an event code of 6, which is the same code returned when the user closes a Custom Tab. Is there a way to differentiate between whether the user has closed the Custom Tab or opened it in Chrome?
Navigation code 6 means that CustomTabs Activity is not visible any more for either user has navigated back to the activity that started the CustomTabs intent or another activity, in this case Chrome has been started, has taken place.
When the user navigates from CustomTabs activity to Chrome you get navigation code 6, when back button is hit, another event is sent with code 5 (tab visible again). In this case you are the CustomActivity is still visible, previous activity was finished, the activity that started the intent is still paused.
Starting CustomTabs for activity might solve your case when you have navigation code 6 and onActivityResult() method called on the activity that started the session.
public void openUrlForResult(String url, int requestCode){
CustomTabsIntent customTabsIntent = buildCustomTabIntent(mCustomTabSession);
customTabsIntent.intent.setData(Uri.parse(url));
mContext.startActivityForResult(customTabsIntent.intent, requestCode);
}
I want to close the android application from fragment activity. Fragment layout contains two menus.one of the fragment will display the list. When we click on the list it will display the details for list in Dialog Alert that alert box contains two buttons.if you click one button it will open another activity that activity will contains list. if we click the list it will open previous activity in the fragment activity.if you click back button from this activity it is not closing the app completely.
please give me good solution to exit the app from the situation
As i understand you activity managment is something like this:
A -> B -> A
And if you pressing back now it is not closing.
You should watch to Intent.FLAG_ACTIVITY_CLEAR_TOP
So when you opening Activity A again you code should look like this:
Intent a = new Intent(this,A.class);
a.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(a);
Is it possible to open any acticity on the current tab by clicking the current tab itself?
What is to be done in my application:
user performs a search , a listactivity is displayed on same tab(Using TabGroup activity). Then If User presses the same tab, again the search page should open.
Is this possible?
Try this,,,,
Rather than starting two activities, you perform both in same activity.
On pressing tab show search activity.
show search screen, when user clicks search, get your search result and set it as current activity view i.e, setContentView(list);
when user clicks search again start SearchActivity again (as usual).
Refer this link:
Launching activities within a tab in Android
In first answer,you can set SharedPreference Variable and then check for that variable to know which activity to be loaded in this tab(in YourActivityGROUP class).you can set Extras to Intent accordingly in your main activity which you use to open an activity in a tab. (I haven't tried this,but i think,this will solve your problem.)