Back to project page DoomPlay.
The source code is released under:
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUC...
If you think the Android project DoomPlay listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.perm.DoomPlay; //from w w w . j a va2 s . com /* * Copyright 2013 Vladislav Krot * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * You can contact me <DoomPlaye@gmail.com> */ import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; import android.util.Log; import android.view.Window; import android.webkit.CookieManager; import android.webkit.CookieSyncManager; import android.webkit.WebView; import android.webkit.WebViewClient; import com.api.Auth; public class LoginActivity extends Activity { private static final String TAG = "Kate.LoginActivity"; public static final String API_ID = "3861634"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.login); WebView webview = (WebView) findViewById(R.id.vkontakteview); webview.getSettings().setJavaScriptEnabled(true); webview.clearCache(true); webview.setWebViewClient(new VkontakteWebViewClient()); CookieSyncManager.createInstance(this); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); String url= Auth.getUrl(API_ID, Auth.getSettings()); webview.loadUrl(url); } private class VkontakteWebViewClient extends WebViewClient { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); parseUrl(url); } } private void parseUrl(String url) { try { if(url==null) return; Log.i(TAG, "url="+url); if(url.startsWith(Auth.redirect_url)) { if(!url.contains("error=")){ String[] auth=Auth.parseRedirectUrl(url); Intent intent=new Intent(); intent.putExtra("token", auth[0]); intent.putExtra("user_id", Long.parseLong(auth[1])); setResult(Activity.RESULT_OK, intent); } finish(); } } catch (Exception e) { e.printStackTrace(); } } }