4

Two activities are installed having the following manifest files on device respectively:

The First app's activity has in its manifest:- where, package="com.example.tictactoe"

<intent-filter> <action android:name="com.example.tictactoe.YOYO" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/*" /> </intent-filter> 

The second app's activity has in its manifest:- where,
package="com.example.project"

 <intent-filter> <action android:name="com.example.project.YOYO" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/*" /> </intent-filter> 

Now, i want to start one of these activity from third application using the following code:

i=new Intent(); i.setAction("YOYO"); i.putExtra("KEY","HII..i am from third app"); startActivity(i); 

But execution shows an error:-

03-11 08:12:30.496: E/AndroidRuntime(1744): FATAL EXCEPTION: main 03-11 08:12:30.496: E/AndroidRuntime(1744): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=ACTION_SEND (has extras) } 
8
  • try Intent i =new Intent("com.example.project.YOYO);//include package startActivity(i); Commented Mar 11, 2013 at 8:25
  • "Now, i want to start one of these activity from third application..." - Which one? Using "YOYO" as an action for the Intent isn't enough - you must use the exact name you specify in the <intent-filter>. Commented Mar 11, 2013 at 8:27
  • @Raghunandan it didnt work... Commented Mar 11, 2013 at 8:34
  • @Squonk actually, i want to generate an implicit intent then i want the above mentioned activities to be able to respond after selection as they will pass the intent-filter. Commented Mar 11, 2013 at 8:37
  • the answer by Rvdk should work. Use the package along with the activity class. You were using just the class name. Commented Mar 11, 2013 at 8:38

3 Answers 3

6

You need to supply the full action name; supply the mimeType you used in manifest by calling setType() in your intent.

Manifest :

<intent-filter> <action android:name="com.example.tictactoe.YOYO" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent-filter> 

Java :

Intent i=new Intent(); i.setAction("com.example.tictactoe.YOYO"); i.setType("text/plain"); i.putExtra("KEY","HI..i am from third app"); startActivity(i); 
Sign up to request clarification or add additional context in comments.

Comments

3

You need to supply the full action:

i=new Intent(); i.setAction("com.example.tictactoe.YOYO"); i.putExtra("KEY","HII..i am from third app"); startActivity(i); 

Or (depending which project you want to launch):

i.setAction("com.example.project.YOYO"); 

You can do it also via: (supply action directly in constructor)

i=new Intent("com.example.tictactoe.YOYO"); i.putExtra("KEY","HII..i am from third app"); startActivity(i); 

Also loose the data mimeType or read up on how to use it. Because via putExtra is not going to work.

3 Comments

Remove the data attribute of your XML and try again.
thanks....for all but it still not working..:p could u please refer to any link where a application is automatically started in response to the qualifying the implicit intent generated from other application
We need to add Default Category in order to make Implicit intents work.
0

First of all you need to ensure that the name of the intent is the fully qualified name with the package name is the same in the intent filter and the activity firing the intent. In this case: "YOYO" should be "com.example.tictactoe.YOYO". You should also remove the mime type since you are not including data in the setData(), you are in this case using a bundle. So you should have for the activity firing the intent:

ACTIVITY FIRING INTENT

i=new Intent(); i.setAction("com.example.tictactoe.YOYO"); i.putExtra("KEY","HII..i am from third app"); startActivity(i); 

and for the receiving activity's entry in the manifest: You need to ensure you set the category as DEFAULT and remove the data type tag.

ACTIVITY RECEIVING INTENT

<intent-filter> <action android:name="com.example.tictactoe.YOYO" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.