Denys
Denys

Reputation: 4557

Making my Service accessible using intent-filter

I want my service to be accessible as one of the default options of the Share page when the user long-touches the web-link (standard android feature). This is what I wrote in the manifest file :

<service android:name=".ShareLink"
            android:enabled="true">
    <intent-filter>
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/plain" />
    </intent-filter>
</service>

But it is still not being displayed. What am I doing wrong? P.S. When I do the same thing with the Activity - it works fine.

Upvotes: 3

Views: 1855

Answers (2)

nandeesh
nandeesh

Reputation: 24820

This is not possible, You will have to write a Dummy Activity to do this.

This is because, ResolverActivity that shows the names or selects the appropriate component to launch gets the list by querying Only Activities that match intent with API PackageManager.queryIntentActivities

Upvotes: 7

iTurki
iTurki

Reputation: 16398

This should do it:

<intent-filter
    android:label="Open Using My Service">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="http" />
</intent-filter>

Upvotes: 0

Related Questions