Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Because I use my code to generate lot of application with different package names I cannot use standard mypackage.GCMIntentService name.</p> </blockquote> <p>I'm not sure whether you ask for a runtime or a build time solution. The other answers are runtime solutions so I thought I add some information on possibilites during build time.</p> <hr> <p>In AndroidManifest, you can use the variable <code>$PACKAGE_NAME</code> (available by default) which will refer to the package name you specified in the attribute <code>package</code> in the <code>manifest</code> root element.</p> <p>The value of this <code>package</code> attribute needs not be a hard coded string but can also be set dynamically via resource reference like so:</p> <pre><code>&lt;manifest package="@string/app_package" ...&gt; ... &lt;service android:name="$PACKAGE_NAME.service.GCMIntentService" android:enabled="true" /&gt; ... &lt;/manifest&gt; </code></pre> <p>Note <code>.service</code> is just a subpackage that I included to show how you specify these. Of course, this solution would work only if your applications follow general rules like putting Service classes in a <code>.service</code> subpackage.</p> <p>Also note, that you can actually leave the root package off completely. It will be expanded by Android:</p> <pre><code>&lt;manifest package="@string/app_package" ...&gt; ... &lt;service android:name=".service.GCMIntentService" android:enabled="true" /&gt; ... &lt;/manifest&gt; </code></pre> <p>In effect, same as above.</p> <p>If you are looking for a more flexible way to replace values in an AndroidManifest (or different files), you might want to have a look at the Ant Replace task (<a href="http://ant.apache.org/manual/Tasks/replace.html" rel="nofollow">http://ant.apache.org/manual/Tasks/replace.html</a>) or Resource Filtering (<a href="http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html" rel="nofollow">http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html</a>) with Maven.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload