This is WAI. The format is <appId>/<FQCN of receiver>.

When you apply an applicationID in build.gradle you only affect the first
one so your class name is still com.example.package.... You can look at the
merged manifest to see that the merger expanded name=".BroadcastRecevier"
to name="com.example.package.BroadcaseReceiver" (since you cannot express
it as a relative path to the applicationId anymore)

Applying applicationId=... in build.gradle cannot go in and repackage your
classes. It simply would not work, so we only affect the "package"
attribute of the manifest, which is really the Application ID, not its
package. This is why we renamed it in gradle to say applicationId as it's
more obvious (or at least should be) that it does not affect your class
package names.

On Fri, Apr 3, 2015 at 11:50 AM, Michael Sung <shp...@gmail.com> wrote:

> Hi,
>
> I am trying to mimic INSTALL_REFERRER intents from Google Play using adb
> shell am.  I’m having some issues when my application ID in Gradle is
> different than my package name in my Manifest.
>
> In my manifest, I define my BroadcastReceiver as:
>
>         <receiver
>             android:name=“.BroadcastReceiver"
>             android:exported="true">
>             <intent-filter>
>                 <action
> android:name="com.android.vending.INSTALL_REFERRER"/>
>             </intent-filter>
>         </receiver>
>
> and my package is “com.example.package”.
>
> In my app build.gradle file, I define my application ID:
>
>     productFlavors {
>         flavor {
>             applicationId ‘com.flavor.applicationID'
>             versionName ‘1.0.0'
>         }
>     }
>
> What I am seeing, is that my BroadcastReceiver is not able to receive an
> explicit INSTALL_REFERRER intent unless the component specifying the name
> of the BroadcastReceiver includes the package name:
>
> # fail
> am broadcast -a com.android.vending.INSTALL_REFERRER
> -n com.flavor.applicationID/.BroadcastReceiver --es "referrer"
> "test_referrer=test”
>
> # fail
> am broadcast -a com.android.vending.INSTALL_REFERRER -n
> com.flavor.applicationID/com.flavor.applicationID.BroadcastReceiver --es
> "referrer" "test_referrer=test”
>
> # fail
> am broadcast -a com.android.vending.INSTALL_REFERRER -n
> com.example.package/com.example.package.BroadcastReceiver --es "referrer"
> "test_referrer=test”
>
> # success
> am broadcast -a com.android.vending.INSTALL_REFERRER -n
> com.flavor.applicationID/com.example.package.BroadcastReceiver --es
> "referrer" "test_referrer=test”
>
> I’m wondering why my BroadcastReceiver does not receive the intent unless
> the package name is explicitly in the BroadcastReceiver’s name.  I’m also
> wondering how Google Play sends the INSTALL_REFERRER intent - I believe
> intents use the "com.flavor.applicationID/.BroadcastReceiver” component and
> I’m missing INSTALL intents.  If I explicitly specify the package name as
> the name of my BroadcastReceiver (com.example.package.BroadcastReceiver) in
> my Manifest, would Android still be able to route intents from Google Play
> to my BroadcastReceiver?
>
> Thanks!
>
> Best regards,
>
> Michael Sung
>
> --
> You received this message because you are subscribed to the Google Groups
> "adt-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to adt-dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adt-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to