我在特定設備上的意圖URI存在問題,所以我嘗試了CommonsWare URLHandler示例,如下所示:Launching my app using the intent URI,並且其示例頁面上的意向URI超鏈接也無法調用該應用程序。此示例聲明其意圖過濾器是這樣的:標準意圖URI破碎了嗎?
<intent-filter>
<action android:name="com.commonsware.android.MY_ACTION" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
而且在樣品網頁中的超鏈接是:
<a href="intent:#Intent;action=com.commonsware.android.MY_ACTION;end">Link back to URLHandler via intent: URL</a>
這適用於大多數設備,但不是在HTC驚奇4G,運行Android 4.0.3。當我觸摸鏈接時,logcat會給出:
I/PRIME(9029): <CallBackProxy> Send to WebViewClient.
I/PRIME(9029): <Browser> Send to HtcLinkifyDispatcher
I/ActivityManager(262): START intent from pid 9029
D/MP-Decision(891): Aggress decision engine: Off
D/MP-Decision(891): Switch back to normal parameters:
Nw=2.700000, Tw=180, Ns=2.100000, Ts=270, Decision_ms=100, Poll_ms=10
V/NfcService(600): setForegroundNdefPush msg = null callback = null
D/HtcTelephony(561): requestSetFastDormancy: module=0 mode=0
D/WebViewTimersControl(9029): onBrowserActivityPause
D/WebViewTimersControl(9029): Pausing webview timers,
[email protected]
I/ActivityManager(262): Start proc com.htc.HtcLinkifyDispatcher for
activity com.htc.HtcLinkifyDispatcher/.HtcLinkifyDispatcherActivity:
pid=11087 uid=1000 gids={1015, 3002, 3001, 3003, 5001, 5003, 3007, 3006, 2001, 1007}
D/ConnectivityService(262): onUidRulesChanged(uid=1000, uidRules=0)
V/browser(9029): BrowserActivity.onWindowFocusChanged
D/HtcLinkifyDispatcherActivity(11087): @@@@@ receive action=com.commonsware.android.MY_ACTION
I/HtcAppAssociationsUtils (Dispatcher)(11087): @@@@@ enable by 2 = true
I/HtcAppAssociationsUtils (Dispatcher)(11087): @@@@@ method = 0
I/HtcAppAssociationsUtils (Dispatcher)(11087): @@@@@ check enable = true
D/MP-Decision(891): Aggress decision engine: On
D/ActivityManager(262): Config after re-evaluted by window manager: null
D/MP-Decision(891): Switch to aggressive parameters:
Nw=1.990000, Tw=140, Ns=1.400000, Ts=190, Decision_ms=50, Poll_ms=10
V/browser(9029): BrowserActivity.onWindowFocusChanged
D/HtcTelephony(561): requestSetFastDormancy: module=0 mode=1
W/InputManagerService(262): Window already focused, ignoring focus gain of:
[email protected]
D/WebViewTimersControl(9029): onBrowserActivityResume
D/WebViewTimersControl(9029): Resuming webview timers,
[email protected]
W/BaseUi(9029): mMainView is already attached to wrapper in attachTabToContentView!
W/BaseUi(9029): mContainer is already attached to content in attachTabToContentView!
V/NfcService(600): setForegroundNdefPush msg = null
callback = [email protected]
D/memalloc(9029): /dev/pmem: Unmapping buffer base:0x569c5000 size:4386816 offset:4177920
D/browser(9029): [BrowserActivity::Connectivity_Type] ===== 1
I/ActivityManager(262): No longer want
com.htc.providers.settings:remote (pid 10935): hidden #16, adj=15
D/Process(262): killProcessQuiet, pid=10935
D/Process(262): dalvik.system.VMStack.getThreadStackTrace(Native Method)
D/ConnectivityService(262): onUidRulesChanged(uid=1000, uidRules=0)
D/Process(262): java.lang.Thread.getStackTrace(Thread.java:599)
D/Process(262): android.os.Process.killProcessQuiet(Process.java:823)
D/Process(262): com.android.server.am.ActivityManagerService.updateOomAdjLocked(ActivityManagerService.java:15132)
D/Process(262): com.android.server.am.ActivityManagerService.trimApplications(ActivityManagerService.java:15294)
D/Process(262): com.android.server.am.ActivityStack.activityIdleInternal(ActivityStack.java:3450)
D/Process(262): com.android.server.am.ActivityManagerService.activityIdle(ActivityManagerService.java:4303)
D/Process(262): android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:362)
D/Process(262): com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1706)
D/Process(262): android.os.Binder.execTransact(Binder.java:338)
D/Process(262): dalvik.system.NativeStart.run(Native Method)
有人知道這裏有意圖URI嗎?爲什麼它沒有工作?是否有解決方法?
感謝, 西蒙
嗯,這是個壞消息!我想要做的是從我的應用程序將用戶轉移到第三方網站進行認證,然後第三方網站通常會使用我的意圖URI將用戶重定向到具有認證結果的我的應用程序。現在我想知道是否有一種方法可以在我的應用程序內部顯示第三方認證門戶,而不是傳輸到瀏覽器以實現「雙方控制」。 – Simon 2012-08-02 16:04:18
@Simon:您可以嘗試將「WebView」用於身份驗證網頁。 – CommonsWare 2012-08-02 16:08:20
謝謝,我會研究一下。 – Simon 2012-08-02 16:13:43