编辑:事实证明问题比预期更深入。我刚刚检查了我的进程,结果发现,当Web浏览器“返回”时,它不会返回到原始应用程序进程,而是创建一个新进程。结果是我的应用程序一次运行的两个实例。我该如何解决这个问题?这是我的清单中的intent过滤器,我必须处理回调
<activity
android:name=".LoginActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="whodunit" android:scheme="callback"></data>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
这是我的onResume:
@Override
protected void onResume() {
super.onResume();
if (this.getIntent()!=null && this.getIntent().getData()!=null){
Uri uri = this.getIntent().getData();
if (uri != null && uri.toString().startsWith("callback://whodunit"))
{
Verifier verifier = new Verifier ( uri.getQueryParameter("oauth_verifier") );
new OnCallBackTask(verifier).execute();
}
}
else
new LoginTask().execute();
}