I have the following in my AndroidManifest:
<activity android:name="IntentChild"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.intent.cursor.item/intent_example"
android:host="example.intent"
android:path="intent_example"
android:scheme="content"
/>
</intent-filter>
</activity>
I launch the activity with
Uri uri = new Uri.Builder().scheme("content").authority("example.intent").appendPath("intent_example").build();
Intent intent = new Intent(Intent.ACTION_EDIT, uri);
IntentExample.this.startActivity(intent);
But I get:
E/AndroidRuntime( 865): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.EDIT dat=content://
example.intent/intent_example }
What am I doing wrong? Also, does Uri.Builder.authority() refer to the same thing as the android:host attribute of the <data> tag in my manifest?
Prompted by the comment by #A--C, I ended up adding a call to Intent.setType() to set the desired MIME type:
Uri uri = new Uri.Builder().scheme("content").authority("example.intent").appendPath("intent_example").build();
Intent intent = new Intent(Intent.ACTION_EDIT, uri);
intent.setType("vnd.intent.cursor.item/intent_example");
IntentExample.this.startActivity(intent);
For simplicity, I also pruned my <intent-filter> to only declare the android:mimeType. I guess, but not entirely certain, that this isn't as important as the previous change.
<activity android:name="IntentChild"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.intent.cursor.item/intent_example"/>
</intent-filter>
</activity>
Related
I have a question regarding package visibility in Android 11. I read the oficial docs and also checked stack overflow question-answer. But I've few doubts. Please check the code below:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.test">
<application
.....>
<activity
android:name=".TestActivity"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<data
android:host="open"
android:scheme=“xxx” />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<intent-filter
android:autoVerify="true"
tools:targetApi="m">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.xxx.com"
android:pathPrefix="/"
android:scheme="https" />
</intent-filter>
</activity>
<activity
android:name=".ABCActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
</application>
</manifest>
Doubt:
I tried and understood that <query> tag suggestion is coming only outside of <application> tag. Am I right?
If you see my code like this android.intent.category.BROWSABLE written inside particular TestActivity. Now If I'll move intent filter code outside of application tag, then how Android will understand that for which activity browsable is required?
There are multiple intent filter with BROWSABLE, so I need to declare query tag multiple times?
I saw that people uses intent tag inside query tag, and no one is using intent-filter. So is that fine?
Can I do one last request? Can someone please correct my code and post it in answer? I already reduced and added only required code according to my questions. Thanks in advance!
EDIT:
Usage 1:
upiIntent = Intent(Intent.ACTION_VIEW)
val pm: PackageManager = packageManager
val app: MutableList<ResolveInfo>? = pm.queryIntentActivities(upiIntent!!, 0)
Usage 2:
Intent intent = new Intent(Intent.ACTION_SEND, null);
intent.setType("text/plain");
private List<ResolveInfo> sharingAppList = new ArrayList<>();
PackageManager pManager = context.getPackageManager();
sharingAppList = pManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
Usage 3:
mVersionName.setText(getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
The latest code in your question seems wrong, insofar as upiIntent needs more than an action string.
But, ignoring that, you would need a <queries> element like:
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="text/plain" />
</intent>
</queries>
The first <intent> matches an ACTION_VIEW with no content; the second matches an ACTION_SEND with a MIME type of text/plain.
I am trying to use a library where I have to pass the action and the URI and to open the activity I have to use the package name but the thing is even I change the package name it is not working at all
this is the code that I am trying
Intent intent = new Intent(Intent.ACTION_EDIT, Uri.parse(filename));
intent.putExtra("was_get_content_intent", mWasGetContentIntent);
intent.setClassName("neelay.mediaplayer.beatbox.ringdroid", "neelay.mediaplayer.beatbox.ringdroid.RingdroidEditActivity");
startActivityForResult(intent, REQUEST_CODE_EDIT);
and this is my manifest code for setting the activity
<activity
android:name=".ringdroid.RingdroidSelectActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="audio/*" />
</intent-filter>
</activity>
<activity
android:name=".ringdroid.RingdroidEditActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<intent-filter android:label="#string/edit_intent">
<action android:name="android.intent.action.EDIT" />
<data android:mimeType="audio/*" />
</intent-filter>
</activity>
The package name is package="neelay.mediaplayer.beatbox"
I know it is easy to open the activity by just calling the names of the activity but in this case i have to pass the action with a uri and this is the only possible way i can see and guide will be helpful .
You said your package name (in the manifest) is "neelay.mediaplayer.beatbox". In that case you need to change this:
intent.setClassName("neelay.mediaplayer.beatbox.ringdroid", "neelay.mediaplayer.beatbox.ringdroid.RingdroidEditActivity");
to this:
intent.setClassName("neelay.mediaplayer.beatbox", "neelay.mediaplayer.beatbox.ringdroid.RingdroidEditActivity");
Since there are a number of ways to set the Component, you can also use any of the following methods:
intent.setClassName(this, "neelay.mediaplayer.beatbox.ringdroid.RingdroidEditActivity");
or like this:
intent.setClassName(getApplicationContext(), "neelay.mediaplayer.beatbox.ringdroid.RingdroidEditActivity");
or like this:
intent.setComponent(new ComponentName("neelay.mediaplayer.beatbox", "neelay.mediaplayer.beatbox.ringdroid.RingdroidEditActivity"));
or like this:
intent.setComponent(new ComponentName(this, "neelay.mediaplayer.beatbox.ringdroid.RingdroidEditActivity"));
or like this:
intent.setComponent(new ComponentName(getApplicationContext(), "neelay.mediaplayer.beatbox.ringdroid.RingdroidEditActivity"));
I am new for implicit intent part of android.
In my application I have registered the intent like below:
<activity
android:name="ihpc.mocha.fakertt.view.MainActivity"
android:label="#string/app_name"
android:screenOrientation="reverseLandscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<data
android:host="mocha"
android:path="/RTT/reset"
android:scheme="content" />
</intent-filter>
</activity>
<activity
android:name="ihpc.mocha.fakertt.view.SessionTimeOutActivity"
android:label="#string/app_name"
android:screenOrientation="reverseLandscape" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="mocha"
android:path="/RTT/sessionTimeOut"
android:scheme="content" />
</intent-filter>
</activity>
Now I want to trigger these intent from some test application but I do not know how to achieve that? I tried googling the same but could not find appropriate solution.Please suggest the way to do it.
your intent filter will catch all the intent with the "android.intent.action.VIEW" key. so if any application send an intent with this your application will receive. To test from another test application try this
intent = new Intent("android.intent.action.VIEW");
// if needed put some extra data
startActivity(intent);
I am trying to add new contact to android and receive this ActivityNotFoundException: No Activity to handle intent. I am pretty sure that I need to use intent filter to resolve this problem but have no idea how.
Intent addContactIntent = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT);
addContactIntent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
addContactIntent.putExtra(ContactsContract.Intents.Insert.NAME, "My Name");
addContactIntent.putExtra(ContactsContract.Intents.Insert.PHONE, "123456789");
startActivity(addContactIntent);
Here is my manifest file:
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/com.example.android.beam"></data>
</intent-filter>
<intent-filter>
<action android:name="com.android.contacts.action.SHOW_OR_CREATE_CONTACT" />
<data android:scheme="mailto" />
<data android:scheme="tel" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
try changing these to
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
// Just two examples of information you can send to pre-fill out data for the
// user. See android.provider.ContactsContract.Intents.Insert for the complete
// list.
intent.putExtra(ContactsContract.Intents.Insert.NAME, "some Contact Name");
intent.putExtra(ContactsContract.Intents.Insert.PHONE, "some Phone Number");
you will have to add this permission also
<uses-permission android:name="android.permission.READ_CONTACTS"/>
i am getting following error:
log is:
android.content.ActivityNotFoundException:
No Activity found to handle Intent { act=android.intent.action.VIEW
dat=android.resource://com.isummation.customgallery/2130837504 typ=image/* }
my code is as:
intent.setAction(Intent.ACTION_VIEW);
Uri hacked_uri = Uri.parse("android.resource://com.isummation.customgallery/" + R.drawable.a);
intent.setDataAndType(hacked_uri, "image/*");
startActivity(intent);
manifest.xml is as:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
any suggestion?
thanks
Try putting all actions/categories in the same intent filter, as opposed to the two different ones you currently have:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Also make sure you added the intent filter to the correct activity. For an example, check out the Note Pad example.
i can't see setName() in ur code . usually Activity not found means we set a name to intent but no Activity tag in menifest with this name exist . so please check