Android Browser Intent back button - android

Hello I am lauching the browser from my application using an intent such as:
String url = "XXXX";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
but when I press back on the browser i want to go back to the my application, instead of going to the options of the browser. how can i control this behaviour?

You can't as the back button implementation is now under control of Browser Application.
Implement a WebView in your application and handle Back Key Pressed is the only option.

Try:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setData(Uri.parse(url));
startActivity(i);
A task (from the activity that started it to the next task activity) defines an atomic group of activities that the user can move to. Tasks can be moved to the foreground and background; all of the activities inside of a particular task always remain in the same order. You can find more about it here: http://developer.android.com/guide/components/tasks-and-back-stack.html

Related

can't go back to the previous activity

This is how my app opens a page in default browser
Intent i = Intent.parseUri("http://www.google.com", Intent.URI_INTENT_SCHEME);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
Once the browser activity is active, I can't navigate back to my app using back button. It goes the activity before my app. My app/activity is not destroyed though as I can still resume it from the app list. I suspect my activity is 'removed' from the back stack somehow. Please help me debug/fix this. Thanks.
try to use Intent.ACTION_VIEW
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(myUrl));
startActivity(intent);

Failed to go back to home screen from Android apps

I have a button in my app named "Go Home" to redirect the user to the home screen. It is working fine without the very first launch. The process of first launch is noted below:
After uploading the APK into SVN I am downloading using the web browser. Then go back to the download folder and installing the app. When install finishes I click on Open. Then In my app I click on the "Go Home" button. The application redirect me to the web browser instead of the home screen. I am tired to search a solution for that.
I am using the following code:
finish();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
Thanks in advance, Siddiqui Noor
Your app is opening in the task of the browser. Try this:
finish();
Intent intent = new Intent(context, HomeActivity.class);
intent.setAction(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_HOME)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
try adding FLAG_ACTIVITY_NEW_TASK:
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
and also try putting finish() after startActivity
I'm pretty sure that it's not really redirecting you anywhere, it's just closing the Activity. You call finish() after which the intent to start the activity never happens. The app is closed because you've finished the Activity and you end up looking at the screen that was showing before you opened the app. In this case, that is the browser.
Try removing the line to finish();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
kill your current activity after redirect the next activity
finish();

Close all activities and come to mobile's home screen

When I press the log out button and come to start(main) screen and when I press the back button from main screen it comes to 2nd screen. but, i want to close the application on click of back button from main screen and close all the activities before that.
while doing research I found,
Intent intent = new Intent(this, Home.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
but its not satisfying my requirement.
You can use this code that I referred from here How to exit from the application and show the home screen?:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Although Android's design does not favor exiting an application by choice.
Related Links:
How to close Android application?
Android exit application
just add line in your code and this will work fine
startActivity(intent);

Android killing applications

I have a login page and then a home page, then I have an exit button on the home page. When you press the exit, I need the app to close.
If I use finish() on the home page's exit onClick(),it just take me back to the login page.
So I am using
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Now this does act like an exit but when you start the application again, it by passes the login screen and directly goes to the home page (as the app was never closed).
What would be the best solution here?
What would be the best solution here?
The best solution would be to delete the exit button and its associated functionality.
First, it is not necessary, as what you are providing with the exit button is already provided via the HOME button on the device.
Second, you have been told, repeatedly, by Googlers, not to have such a button.
See also: Is quitting an application frowned upon?
Before Coming to HomePage from Login Page use finish();
Intent i = new Intent(Login.this, Home.class);
StartActivity(i);
finish();

kill an ActionView (Web browser) in the Android stack of my application

I need to call a ActionView in my application. But after used it, I would like to kill it of my stack (if I press return,I don't want to come back in this view). How can I do?
Here how I call the actionView:
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(liToken.getAuthorizationUrl()));
startActivity(i);
Thanks!

Categories

Resources