Link to home
Start Free TrialLog in
Avatar of AXISHK
AXISHK

asked on

Android XML file

1. What does it mean for  "tools:context="com.abc.passingdata.MainActivity"  ? (sample 1)
2. What does it mean for the following XML statement ? For "action", does it refer to the corresponding java class. How does "category" defined in sample 2 ? Any special meaning ? Thx

            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />  

           <action android:name="com.abc.usingintent.SecondActivity" />
            <category android:name="android.intent.category.DEFAULT" />
   
SAMPLE 1
-------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"

    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.abc.passingdata.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Welcome to the Second Activity"
        android:id="@+id/textView" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Click to go to Main  Activity"
        android:id="@+id/button"
        android:onClick="onClick"/>

</LinearLayout>

SAMPLE 2
--------------
        <activity android:name=".MainActivity">
            <intent-filter>
               <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".SecondActivity" >
        <intent-filter >
            <action android:name="com.abc.usingintent.SecondActivity" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
ASKER CERTIFIED SOLUTION
Avatar of Jackie Man
Jackie Man
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial