Activity not found exception when clicking on the image - android

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

Related

Adding multiple intent filters to MainActivity doesn't work?

I have MainAcitivty on which I am adding multiple intent-filters, with a purpose to open the MainActivity.
But the problem is that onNewIntent() is called but intent.action is always main, even when it should be VIEW_RICH_PUSH_MESSAGE. If I remove the second intent filter and add that to another new Activity, it will work for that Activity.
What I want is to define multiple intent filters for one Activity but I couldn't figure out the problem.
My manifest is defined as follows:
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="com.urbanairship.VIEW_RICH_PUSH_MESSAGE" />
<data android:scheme="message"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
Any help is appreciated.

Unable to start activity by using the package name

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"));

Implicit intent from test application

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);

Launching an Activity with an Intent

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>

Add new contact on Android no activity to handle intent error

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"/>

Categories

Resources