Вопрос

I have been searching the web, and I still can’t find the answer. I have an Android app with a WebView, I am trying to make my activity the default browser for the phone. Therefore when I do a Google search in the Google search widget, it should pass the results into my WebView.

I am new to android development any examples would be highly grateful.

Это было полезно?

Решение

What I believe you are trying to ask is how to subscribe your application to intents for launching web URIs. In order to do so, you can add an intent filter to your application's manifest.

There's an example of this on Lars Vogel's blog. It boils down to this:

<application android:icon="@drawable/icon" android:label="@string/app_name">
     <activity android:name=".BrowserActivitiy"
               android:label="@string/app_name">
         <intent-filter>
             <action android:name="android.intent.action.VIEW" />
             <category android:name="android.intent.category.DEFAULT" />
             <data android:scheme="http"/>
         </intent-filter>
     </activity>
 </application>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top