Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - application hasCode tag

Tags:

android

Android developer page for <application> contains the flag hasCode. Its description says:

An application would not have any code of its own only if it's using 
nothing but built-in component classes, such as an activity that uses 
the AliasActivity class, a rare occurrence.

Can someone please give a code example of the AliasActivity use case (rare occurence) they talk about ?

like image 531
Jake Avatar asked Sep 08 '26 03:09

Jake


1 Answers

An AliasActivity is - as the name suggests - just an alias to another activity.

You can create one just in XML. There is an example available in the Android git repository.

You manifest could look like this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.aliasactivity">
    <application android:hasCode="false" android:label="@string/app_label">
        <activity android:name="android.app.AliasActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <meta-data android:name="android.app.alias"
                    android:resource="@xml/alias" />
        </activity>
    </application>
</manifest>

In res/xml/alias.xml you define the intent:

<alias xmlns:android="http://schemas.android.com/apk/res/android">
    <intent android:action="android.intent.action.VIEW"
        android:data="http://www.google.com/">
    </intent>
</alias>
like image 183
Johann Bauer Avatar answered Sep 10 '26 17:09

Johann Bauer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!