title: Can't get back from browser to app
body: <p>I am trying to authorize my GitHub app and turn back to my app. I open authorization page with Intent but can't go back to my app from browser. Could you please look at my code and tell me where I got it wrong?</p>
  
  <p>LoginActivity.java</p>
  
  <pre><code>private final String clientId="myclientid";
  private final String clientSecret="myclientsecret";
  private final String redirectUri="http://localhost";
  private final String state="randomshit";
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_login);
  
      Button loginButton = (Button) findViewById(R.id.loginbutton);
      loginButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent = new Intent(Intent.ACTION_VIEW,
                      Uri.parse("https://github.com/login/oauth/authorize?" +
                              "&amp;client_id="+clientId+
                             "&amp;redirect_uri="+redirectUri+
                              "&amp;state="+state)
                      );
              startActivity(intent);
          }
      });
  }
  
  
  @Override
  protected void onResume() {
      super.onResume();
  
      // the intent filter defined in AndroidManifest will handle the return from ACTION_VIEW intent
      Uri uri = getIntent().getData();
  
      if (uri != null &amp;&amp; uri.toString().startsWith(redirectUri)) {
          String code = uri.getQueryParameter("code");
  
          if (code != null) {
              Log.d("code",code);
          }
      }
  
  }
  </code></pre>
  
  <p>AndroidManifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.figengungor.retrogithub"&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;activity android:name=".LoginActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.VIEW"&gt;&lt;/action&gt;
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
                  &lt;category android:name="android.intent.category.BROWSABLE" /&gt;
                  &lt;data
                      android:host="localhost"
                      android:scheme="http" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>My GitHub app and redirect uri:</p>
  
  <p><a href="https://i.stack.imgur.com/0WzFC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0WzFC.png" alt="enter image description here"></a></p>