![](/img/trans.png)
[英]Can Android Application Launch Start an Activity That Has No Intent-Filter?
[英]Unable to launch Activity using an Intent-Filter in the Emulator Browser
我是Android的新手,正在嘗試一些Android功能以准備項目工作。 在提出問題之前,我要指出的是,我花了幾個小時仔細研究了這個問題,即使在Stack Overflow上也只能找到相同的答案。 我相信我已經遵循了Stack Overflow和其他站點上給出的建議(多數是相同的答案),但是仍無法解決我的問題。
我的問題是,只要用戶單擊鏈接,我都希望能夠從模擬器的瀏覽器啟動我的活動。 這只是用於測試目的; 下一步是對意圖過濾器數據進行其他過濾。
我可以從自己的WebView和消息中將活動顯示在活動選擇器對話框中。 但是,它從未顯示在瀏覽器中。 為了確保代碼中沒有其他內容,我創建了一個非常簡單的應用程序來演示該問題。
我的活動只是使用TextView加載簡單的布局。 下面是我的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="14"/>
<uses-permission
android:name="android.permission.INTERNET"/>
<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher">
<activity
android:name="MyActivity"
android:label="@string/app_name">
<intent-filter>
<action
android:name="android.intent.action.MAIN"/>
<category
android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<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:scheme="http"/>
</intent-filter>
</activity>
</application>
</manifest>
我還檢查了瀏覽器的“默認”操作,它們為空。 有誰知道為什么這不起作用?
如果希望能夠使意圖過濾器在瀏覽器中工作,則必須導航到頁面,然后單擊包含要過濾的URL的鏈接。 將其輸入地址欄將始終轉到URL,並且從不提示運行該應用程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.