我通过使用正确的 URL 调用移动浏览器解决了这个问题:
String url = "http://cloud.feedly.com/v3/auth/auth?client_id=xxxx&redirect_uri=myownuri%3A%2F%2F&scope=https://cloud.feedly.com/subscriptions&response_type=code";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
finish();
然后通过在清单文件中注册自定义 URI 来获取重定向的 URL:
<activity
android:name=".BrowserActivity"
android:label="Feedly Login" >
<intent-filter>
<data android:scheme="myownuri" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
然后我在我的活动中解析返回的参数:
Uri data = this.getIntent().getData();
if (data != null && data.isHierarchical()) {
String url = this.getIntent().getDataString();