title: foursquare integration in android
body: <p>I want to integrate foursquare in android. So i tried two examples.</p>
  
  <p>First Example:</p>
  
  <pre><code>public class ActivityWebView extends Activity 
  {
  private static final String TAG = "ActivityWebView";
  
  /**
   * Get these values after registering your oauth app at: https://foursquare.com/oauth/
   */
  
  public static final String CLIENT_ID = "";
  public static final String OAUTH_CALLBACK_SCHEME = "x-oauthflow-foursquare";
  public static final String OAUTH_CALLBACK_HOST = "callback";
  public static final String CALLBACK_URL = OAUTH_CALLBACK_SCHEME + "://" + OAUTH_CALLBACK_HOST;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_webview);
  
      String url =
          "https://foursquare.com/oauth2/authenticate" + 
              "?client_id=" + CLIENT_ID + 
              "&amp;response_type=token" + 
              "&amp;redirect_uri=" + CALLBACK_URL;
  
      // If authentication works, we'll get redirected to a url with a pattern like:  
      //
      //    http://YOUR_REGISTERED_REDIRECT_URI/#access_token=ACCESS_TOKEN
      //
      // We can override onPageStarted() in the web client and grab the token out.
      WebView webview = (WebView)findViewById(R.id.webview);
      webview.getSettings().setJavaScriptEnabled(true);
      webview.setWebViewClient(new WebViewClient() {
          public void onPageStarted(WebView view, String url, Bitmap favicon) {
              String fragment = "#access_token=";
              int start = url.indexOf(fragment);
              if (start &gt; -1) {
                  // You can use the accessToken for api calls now.
                  String accessToken = url.substring(start + fragment.length(), url.length());
  
                  Log.v(TAG, "OAuth complete, token: [" + accessToken + "].");
  
                  Toast.makeText(ActivityWebView.this, "Token: " + accessToken, Toast.LENGTH_SHORT).show();
              }
          }
      });
      webview.loadUrl(url);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Second Example :</p>
  
  <p><a href="http://blog.doityourselfandroid.com/2011/09/05/integrate-foursquare-android-application/" rel="nofollow">http://blog.doityourselfandroid.com/2011/09/05/integrate-foursquare-android-application/</a></p>
  
  <p>And i added additional code in Manifest file</p>
  
  <pre><code>&lt;activity android:name=".ActivityWebView" android:launchMode="singleTask"  android:noHistory="true"&gt; 
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.VIEW" /&gt;
              &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;category android:name="android.intent.category.BROWSABLE" /&gt;
              &lt;data android:scheme="x-oauthflow-foursquare" android:host="callback" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  </code></pre>
  
  <p>after run the two applications Authentication was success but it shows web view with this message</p>
  
  <pre><code>you dont have permission to open this page x-oauthflow-foursquare://callback#access_token=DRWDP004zzAIZ1PPJEANEBFCM3NZJ1T414U2Z
  </code></pre>
  
  <p>So please tell me is it need add any extra permissions. Please solve my problem.</p>