0

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?

Michael Roland
  • 39,663
  • 10
  • 99
  • 206

1 Answers1

0

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>
Michael Roland
  • 39,663
  • 10
  • 99
  • 206
  • Thanks for the answer. However, the reason of putting an alias in the NFC tag is to save space on it (capacity is 137 bytes) , as our packages name is quite kilometric and I need the remaining space for app data. But your answer is interesting anyway, thanks. – user3005217 Nov 19 '13 at 23:58
  • Well, then I suggest that you skip using the AAR completely, they were not really designed for efficient memory usage. – Michael Roland Nov 20 '13 at 07:04
  • Btw. what record type do you currently use to store your data? – Michael Roland Nov 20 '13 at 07:08
  • I use RTD_TEXT; I experimented which type give me more user space. Not using AAR? It's there any alternative for launching an app? I use an AAR to start my app and another record with the data it needs. – user3005217 Nov 21 '13 at 07:37
  • If you only want your app to be started, I suggest that you stick to the external type and use the external type's payload for storing your data. That way you can trigger your app with the external type (even without the AAR) as indicated in my answer. However, if you also want the user to be redirected to Play Store in case your app is not installed yet, you will have to stick to the AAR (or create some complicated construct using a URI record). – Michael Roland Nov 21 '13 at 07:59
  • Thanks for the extra information. Yes... I also want to be redirected to play store. We have overcome the data limitation storing a hash code that maps to the full data we cannot store. It's not super-elegant but works. – user3005217 Nov 21 '13 at 08:49