Android Open Source - load-image-on-wall-of-vk Login Activity






From Project

Back to project page load-image-on-wall-of-vk.

License

The source code is released under:

GNU General Public License

If you think the Android project load-image-on-wall-of-vk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.kb2fty7.exampleapp_loadimageforwallofvk_1;
/*from w w  w  .j  av a  2 s . co m*/
import com.perm.kate.api.Auth;


import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class LoginActivity extends Activity {


      WebView webview;
      
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_login);
          
          webview = (WebView) findViewById(R.id.vkontakte_view);
          webview.getSettings().setJavaScriptEnabled(true);
          webview.clearCache(true);
          
          
          webview.setWebViewClient(new VkontakteWebViewClient());
                  
          CookieSyncManager.createInstance(this);
          
          CookieManager cookieManager = CookieManager.getInstance();
          cookieManager.removeAllCookie();
          
          String url=Auth.getUrl(getString(R.string.id_application), Auth.getSettings());
          webview.loadUrl(url);
      }
      
      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;
              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();
          }
      }
  }




Java Source Code List

com.kb2fty7.exampleapp_loadimageforwallofvk_1.Account.java
com.kb2fty7.exampleapp_loadimageforwallofvk_1.LoginActivity.java
com.kb2fty7.exampleapp_loadimageforwallofvk_1.StartActivity.java