Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open browser with last visited url

This is what I am using to open the browser with the given URI

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com/"));
startActivity(browserIntent);

Is there a way I can open the browser with previous visited page. Or say just open the Browser, so that last viewed page is shown.

Purpose:

In application user is asked to submit a URL, So instead of typing, it has an option Open Browser so that he/she can copy the URL, come back and submit it. There is a good probability that the last URL is what he/she wants to submit

EDIT:

I can get the last visited page from the browser history using

<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />

but while installing the application, it says:

This application will read your browser history

which on seeing, no one installs.

Any way to change the Browser settings like, switch on Continue where I left ??

like image 994
Archie.bpgc Avatar asked Jan 10 '13 13:01

Archie.bpgc


1 Answers

I believe that you are developing this app so you know when you are firing an intent for opening the web browser. Just save that URL as a string in your shared preferences variable and whenever you open a new URL replace its value with new opened URL.

This way you will always have the last URL address in your shared pref variable. Now whenever you need it, just get it from the shared preferences.

You can find in more details about shared preferences from here:

http://developer.android.com/reference/android/content/SharedPreferences.html

like image 199
mudit Avatar answered Nov 01 '22 07:11

mudit