Hello everyone.
I have an Android application an I want to implement a Facebook login with the spring-android module. For that, I used the spring-android-facebook-client from the samples, which is running perfect. But when I run my application, I get the following error:
Here's my code(shortened), which should be the same as in the samples:Code:FATAL EXCEPTION: WebViewCoreThread java.lang.NullPointerException at android.webkit.WebViewDatabase.getInstance(WebViewDatabase.java:184)at android.webkit.CacheManager.init(CacheManager.java:178) at android.webkit.BrowserFrame.<init>(BrowserFrame.java:202) at android.webkit.WebViewCore.initialize(WebViewCore.java:186) at android.webkit.WebViewCore.access$500(WebViewCore.java:53) at android.webkit.WebViewCore$WebCoreThread$1.handleMessage(WebViewCore.java: at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:629) at java.lang.Thread.run(Thread.java:1019)
Code:public abstract class AbstractWebViewActivity extends Activity implements BaseActivity { private Activity container; private WebView webView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_PROGRESS); getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON); webView = new WebView(this); setContentView(webView); container = this; webView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int progress) { container.setTitle("Loading..."); container.setProgress(progress * 100); if (progress == 100) { container.setTitle(R.string.app_name); } } }); } protected WebView getWebView() { return this.webView; } }In debug mode I can see thatCode:public class FacebookOAuthSignInActivity extends AbstractWebViewActivity { private static final String TAG = FacebookOAuthSignInActivity.class.getSimpleName(); private ConnectionRepository connectionRepository; private FacebookConnectionFactory connectionFactory; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWebView().getSettings().setJavaScriptEnabled(true); getWebView().setWebViewClient(new FacebookOAuthWebViewClient()); this.connectionRepository = getAppContext().getConnectionRepository(); this.connectionFactory = getAppContext().getFacebookConnectionFactory(); } @Override public void onStart() { super.onStart(); // display the Facebook authorization page getWebView().loadUrl(getAuthorizeUrl()); } private String getAuthorizeUrl() { String redirectUri = getString(R.string.facebook_oauth_callback_url); String scope = getString(R.string.facebook_scope); OAuth2Parameters params = new OAuth2Parameters(); params.setRedirectUri(redirectUri); params.setScope(scope); params.add("display", "touch"); return this.connectionFactory.getOAuthOperations().buildAuthorizeUrl(GrantType.IMPLICIT_GRANT, params); } private void displayFacebookOptions() { Intent intent = new Intent(); intent.setClass(this, GMapActivity.class); startActivity(intent); finish(); } private class FacebookOAuthWebViewClient extends WebViewClient { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { // parse the captured url Uri uri = Uri.parse(url); String uriFragment = uri.getFragment(); if (uriFragment != null && uriFragment.startsWith("access_token=")) { try { // split to get the two different parameters String[] params = uriFragment.split("&"); // split to get the access token parameter and value String[] accessTokenParam = params[0].split("="); String accessToken = accessTokenParam[1]; AccessGrant accessGrant = new AccessGrant(accessToken); Connection<Facebook> connection = connectionFactory.createConnection(accessGrant); try { connectionRepository.addConnection(connection); } catch (DuplicateConnectionException e) { // connection already exists in repository! } } catch (Exception e) { } displayFacebookOptions(); } if (uri.getQueryParameter("error") != null) { CharSequence errorReason = uri.getQueryParameter("error_description").replace("+", " "); Toast.makeText(getApplicationContext(), errorReason, Toast.LENGTH_LONG).show(); displayFacebookOptions(); } } } }is invoced with context=null. But The context is given because ofCode:WebViewDataBase.getInstance(context);Code:webView = new WebView(this)
Unfortunately I couldn't find any ideas or solutions via internet research.
Any ideas? Do I miss something???
Thanks in advance!
Markus


Reply With Quote