Question

I have tried to do so:

<application android:label="@string/app_name" >
    <activity android:name="com.blablabla.NfcLauncherActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoDisplay">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.nfc.action.NDEF_DISCOVERED" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.LAUNCHER" />
            <data android:mimeType="text/plain" />
        </intent-filter>
    </activity>

    <activity-alias
        android:enabled="true"
        android:exported="true"
        android:label="an alias"
        android:name=".AnAlias"
        android:targetActivity="com.blablabla.NfcLauncherActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.nfc.action.NDEF_DISCOVERED" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.LAUNCHER" />
            <data android:mimeType="text/plain" />
        </intent-filter>
    </activity-alias>

If I write com.blablabla as AAR in the tag, all works fine, but if I write .AnAlias just brings me to the Play store. I have tried to remove intents int the real activity (in fact, I have tried all combinations of intents) and still same problem.

Am I doing something wrong, or I just misunderstood the usecases for aliases?

Was it helpful?

Solution

No, the AAR can only specify an application package name, not the name of a specific activity (or activity-alias).

However, you would typically put an additional NDEF record as the first record on the tag, e.g. external type record. You can then setup the intent-filter of your activity-alias to filter for that external type:

If your external type is blablabla.com:mytype, your activity-alias would need to have the following intent filter:

<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="vnd.android.nfc"
        android:host="ext"
        android:pathPrefix="/blablabla.com:mytype" />
</intent-filter>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top