Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. public static final String CLIENT_ID = "seu_id";
  2. public static final String CLIENT_SECRET = "seu_secret";
  3. public static final String CALLBACK_URL = "callback";
  4. String url ="https://instagram.com/oauth/authorize?" +"response_type=token" + "&redirect_uri=" + CALLBACK_URL+"&scope=basic"+"&client_id=" + CLIENT_ID ;
  5.  
  6. WebView webview;
  7.  
  8. @Override
  9. protected void onCreate(Bundle savedInstanceState) {
  10. super.onCreate(savedInstanceState);
  11. setContentView(R.layout.photo_activity);
  12.  
  13. ActionBar bar = getActionBar();
  14. bar.setDisplayHomeAsUpEnabled(true);
  15.  
  16. WebView webview = (WebView)findViewById(R.id.webView2);
  17.  
  18. webview.setWebViewClient(new WebViewClient() {
  19.  
  20. public void onPageStarted(WebView view, String url, Bitmap favicon) {
  21. String fragment = "#access_token=";
  22. int start = url.indexOf(fragment);
  23. if (start > -1) {
  24.  
  25. // You can use the accessToken for api calls now.
  26. String accessToken = url.substring(start + fragment.length(), url.length());
  27.  
  28. Log.v(TAG, "OAuth complete, token: [" + accessToken + "].");
  29. Log.i(TAG, "" +accessToken);
  30. Toast.makeText(PhotosActivity.this, "Token: " + accessToken, Toast.LENGTH_SHORT).show();
  31. }
  32. }
  33. });
  34.  
  35. webview.loadUrl(url);
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement