Вопрос

I have to start a service when user click on a button from a web page. I know it is possible to do that with an Activity by adding this in the manifest :

<activity
    android:name="MyActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <data android:scheme="myscheme" /> 
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

my idea was to do the same for a service :

<service
        android:name="MyService"
        android:enabled="true"
        android:exported="true" >
        <intent-filter >
            <data android:scheme="myscheme"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </service>

but it doesn't work.

So is it possible to call the service from the browser and how to do? If not, what can I do (I don't want an application view appear when the user click on the web page button)?

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

Решение

So is it possible to call the service

No, except by perhaps launching an activity and having that activity do something with your service.

(I don't want an application view appear when the user click on the web page button)?

You are welcome to create a Theme.NoDisplay activity, which calls startService() from its onCreate(), then immediately calls finish().

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top