Hi all,

  I am sorry that i may ask known questions to you all. But i couldnt
figure out the exact understanding of implicit intents.

When i was going through the tutorial i read about it.

here are some important points to remember:
1 - Implicit Intents do not specify a target component
2 - Components willing to receive implicit intents have to declare
their ability to handle a specific intent by declaring intent filters
3 - A component can declare any number of Intent Filters
4 - There can be more than one component that declares the same Intent
Filters and hence can respond to the same implicit intent. In that
case the user is presented both the component options and he can
choose which one he wants to continue with
5- You can set priorities for the intent filters to ensure the order
of responses.

I read this about Implicit Intents.

I couldnt get visualisation of 4th point. So wanted to try it out by
writing some examples.

I tested this like below.
Wrote two apps.

I had written two activities in one app, CallingActivity &
anotherActivity.

<manifest xmlns:android="http://schemas.android.com/apk/res/android";
    package="com.android.localguide">
    <application>
        <activity class=".CallingActivity"
android:label="callingactivity">
            <intent-filter>
                <action android:value="android.intent.action.MAIN" />
                <category
android:value="android.intent.category.LAUNCHER" />
            </intent-filter>
      </activity>
       <activity class=".anotherActivity"
android:label="anotheractivity">
            <intent-filter>
                <action
android:value="com.android.localguide.GET_RESULT" />
                <category
android:value="android.intent.category.DEFAULT" />
            </intent-filter>
      </activity>

    </application>
</manifest>

One more app,which has two activities like below.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
      package="com.android.test"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".testmain"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
<activity android:name=".results">
        <intent-filter>
                <action android:name="com.android.localguide.GET_RESULT"/>
                <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
        </activity>
    </application>


</manifest>

I ran the first app in emulator and pressed home screen, it mean it
runs in the background.(Not exited )
Then i opened the second app and clicked a button in frirst
activity(testmain)  and tried to call setAction
"com.android.localguide.GET_RESULT"

i.setAction("com.android.localguide.GET_RESULT");

But it is opening the activity "results".. It dint showed a options to
choose which components( i expected first app ) activity i need to
use ?

Am i right in executing in the right context to understand that point
no 4 ?

Could anyone please elloborate on that point ?

thanks,
Mani

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to