Domanda

I want my application to be on the list to open pdfs from anywhere in the android environment. I've looked around and added these intents based on what I've read. However when testing and opening a pdf it just opens it using the default application polaris?

It is my understanding that in the activity I use the code below to get the information passed in.

Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();

I tried disbaling Polaris and then when opening it says unable to find application to perform this application.

<activity
        android:name=".UserLogIn"
        android:label="User Authentication" >
        <intent-filter>
            <action android:name="com.example.USERLOGIN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />

            <data android:scheme="http" />
            <data android:host="*" />
            <data android:pathPattern=".*\\.pdf" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />

            <data android:scheme="http" />
            <data android:host="*" />
            <data android:mimeType="application/pdf" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:scheme="file" />
            <data android:host="*" />
            <data android:pathPattern=".*\\.pdf" />
        </intent-filter>
</activity>
È stato utile?

Soluzione

This works for mine:

    <activity
        android:name=".ui.PdfViewerActivity" >
        <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:mimeType="application/pdf" />
        </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:host="*" />
            <data android:scheme="file" />
            <data android:scheme="smb" />
            <data android:scheme="content" />
            <data android:scheme="http" />
            <data android:scheme="https" />
            <data android:mimeType="*/*" />
            <data android:pathPattern=".*\\.pdf" />
        </intent-filter>
    </activity>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top