Skip to main content

Post 73: Android: Intent Filter Collision - What happens if multiple activities has the same filter name?

Intent Filter Collision
What happens if another activity (in either the same or a separate application) has the same filter name? For example, suppose your application has another activity named Activity3, with the following entry in the AndroidManifest.xml file:


<?xml version=“1.0“ encoding=“utf-8“?>
<manifest xmlns:android=“http://schemas.android.com/apk/res/android“
    package="net.revan.UsingIntent"
    android:versionCode="1"
    android:versionName="1.0" >
 
    <uses-sdk android:minSdkVersion="14" />
    <application
           android:icon="@drawable/ic_launcher"
           android:label=”@string/app_name” >
 
           <activity
                android:label=”@string/app_name”
                android:name=”.UsingIntentActivity” >
 
                <intent-filter >
                     <action android:name=”android.intent.action.MAIN” />
                     <category android:name=”android.intent.category.LAUNCHER” />
                </intent-filter> 
           </activity>
 
           <activity
                android:label=”Second Activity”
                android:name=”.SecondActivity” >
 
                <intent-filter >
                     <action android:name="net.revan.SecondActivity" />
                     <category android:name=”android.intent.category.DEFAULT” />
                </intent-filter>
           </activity>
 
           <activity
                android:label=”Third Activity”
                android:name=”.ThirdActivity” >
 
                <intent-filter >
                     <action android:name="net.revan.SecondActivity" />
                     <category android:name=”android.intent.category.DEFAULT” />
                </intent-filter>
          </activity>
      </application>
</manifest>

If you call the startActivity() method with the following intent, then the Android OS will display a selection of activities, as shown in below figure: 


startActivity(new Intent("net.revan.SecondActivity"));


If you check the “Use by default for this action” item and then select an activity, then the next time the intent “net.revan.SecondActivity” is called again, it will launch the previous activity that you have selected.

To clear this default, go to the Settings application in Android and select Apps ➪ Manage applications, and then select the application name (below see Figure). When the details of the application are shown, scroll down to the bottom and click the Clear defaults button. 


 

Comments

Popular posts from this blog

How to get VTU Provisional Degree Certificate (PDC) ?

Here is the procedure to get the Provisional Degree Certificate from the VTU by passed out candidates. You can get the certificate through post by sending the required documents to VTU. Documents and things required: 1. Provisional Degree Certificate (PDC) application form 2. DD of specified fees amount or print copy of receipt if you paid the fees online 3. A letter to the VTU registrar 4. A4 size envelope Step 1: Fill the PDC application You can download the PDC application form from the VTU website. Click below link for application download. PDC application form download     After downloading the application take a print of it and properly fill the form. Step 2: Make a DD of specified amount as the fees of PDC: Go to the bank and make the DD of prescribed fee amount for the PDC. The fee amount is specified in the above link from where you downloaded the application. Make the DD in favor of " Finance Officer, VTU Belgaum ".   ...

TIME TABLE: VTU BE/B.Tech June/July 2016 Exam Time table Draft Layout

Semester-wise June-July 2016 Exam time table (Draft Layout) Are You Using updated Kwikstudy App?