I had the same requirement, and I did this by doing two things.
First of all . I used my own WebView to load another URL for authentication and profile display. Instead, I used WebView as public static , using the default browser, I redirect calls to my own WebView in my work.
Second I set webview.getSettings().setAppCacheEnabled(true); , so now it does not request a login again when viewing a profile.
I declared my activity as singleInstace in the Manifest.xml file.
UPDATE:
How I used WebView in My Activity.
public static WebView WV = null; String uri; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tv = (TextView) findViewById(R.id.tv); if (WV == null) { WV = (WebView) findViewById(R.id.webView1); WV.getSettings().setJavaScriptEnabled(true); WV.getSettings().setAppCacheEnabled(true); // the important change WV.getSettings().setSupportZoom(true); WV.getSettings().setBuiltInZoomControls(true); } final SharedPreferences pref = getSharedPreferences(OAUTH_PREF, MODE_PRIVATE); final String token = pref.getString(PREF_TOKEN, null); final String tokenSecret = pref.getString(PREF_TOKENSECRET, null); if (token == null || tokenSecret == null) { startAutheniticate(); } else { showCurrentUser(new LinkedInAccessToken(token, tokenSecret)); } } void startAutheniticate() { final LinkedInRequestToken liToken = oAuthService .getOAuthRequestToken(OAUTH_CALLBACK_URL); uri = liToken.getAuthorizationUrl(); getSharedPreferences(OAUTH_PREF, MODE_PRIVATE).edit() .putString(PREF_REQTOKENSECRET, liToken.getTokenSecret()) .commit(); WV.loadUrl(uri); } void showCurrentUser(final LinkedInAccessToken accessToken) { // code to get Profile object using Linkedin-J API //which is already available on the API site as Example WV.loadUrl(profile.getSiteStandardProfileRequest().getUrl()); }
MKJParekh
source share