我有一个项目,在发布推文之前,我使用 twitter oAuth 流程来验证用户的身份。
问题是 oAuth 在流程结束时重定向回应用程序不起作用,但只有当用户为流程选择 Twitter 应用程序时 - 即“使用...完成此操作”同时具有浏览器和 Twitter。
当使用浏览器完成 oAuth 流程时,这 100% 有效 - twitter 页面重定向,应用程序特定的 URL 被捕获,并且在调用 onResume 时应用程序被传递了正确的意图。
原生 Android Twitter 应用程序继续显示“将您重定向回应用程序。这可能需要一些时间”,并且它不会重定向。事实上,在进入本地 Twitter 应用程序时,logcat 中没有关于身份验证过程的更多内容。还应该注意的是,单击上一页上的“取消”按钮也不会执行任何操作 - logcat 中没有任何内容表明 Twitter 本地应用程序甚至试图回调到原始应用程序。
这是触发 oAuth“Auth Url”意图时的 logcat:
I/ActivityManager( 251): START {act=android.intent.action.VIEW dat=https://twitter.com/oauth/authorize?oauth_token=zpY3RH5tzyM2SuB2TfNfI1tou8VpLTw14xNmMFs8A flg=0x3000000 cmp=com.twitter.android/.UrlInterpreterActivity u=0} from pid 251
I/ActivityManager( 251): START {dat=https://twitter.com/oauth/authorize?oauth_token=zpY3RH5tzyM2SuB2TfNfI1tou8VpLTw14xNmMFs8A cmp=com.twitter.android/.WebViewActivity u=0} from pid 8560
V/PhoneStatusBar( 352): setLightsOn(true)
I/ActivityManager( 251): Displayed com.twitter.android/.WebViewActivity: +225ms (total +267ms)
D/TilesManager( 8560): new EGLContext from framework: 5151cd88
D/GLWebViewState( 8560): Reinit shader
D/GLWebViewState( 8560): Reinit transferQueue
W/ThrottleService( 251): unable to find stats for iface rmnet0
D/AudioHardware( 90): AudioHardware pcm playback is going to standby.
D/AudioHardware( 90): closePcmOut_l() mPcmOpenCnt: 1
D/SizeAdaptiveLayout( 352): com.android.internal.widget.SizeAdaptiveLayout@42100048child view android.widget.FrameLayout@420a2188 measured out of bounds at 95px clamped to 96px
D/SizeAdaptiveLayout( 352): com.android.internal.widget.SizeAdaptiveLayout@41e4ac40child view android.widget.FrameLayout@4204c8b8 measured out of bounds at 95px clamped to 96px
D/dalvikvm( 8272): WAIT_FOR_CONCURRENT_GC blocked 0ms
D/dalvikvm( 8272): GC_EXPLICIT freed 365K, 11% free 10374K/11655K, paused 2ms+3ms, total 36ms
我很清楚 Twitter 应用程序设置中的“虚拟 URL”问题,并且由于浏览器流程运行良好,我看不出这是问题所在。
在 Nexus S + Android 4.1.1 以及 LG Sprint(不确定型号)+ Android 2.3.3 上进行的测试。这两种情况下的行为是相同的。