Start Activity Using Custom Action

Just add and intent-filter category as Default.

Implicit intent works perfectly and in many cases its better to use a implicit intent with Intent-action to call a service/Activity than using class-name.

Before startActivty() / startService() with proper context you cane use this method 'queryIntentActivities(Intent intent, int flags)' from package manager class.

It helps the ActivityManager (responsible for launching activities) to check whether the Android system is getting any match with you Intent.

If it doesn't it returns a list size 0 or else >0.

By this you can also check if your app is getting the call,and in this case even if your app is not installed / has got some problem, it will not crash but will throw a warning in Log. Users will face no big trouble apart from app not being launched.

(users will never forgive you if tour app crashes).

Hope this will help !!! Happy Coding. :)


I think what you need is to add a default category to your intent-filter, eg.

<activity
    android:name=".FeedbackActivity" >  
    <intent-filter>
        <action android:name="com.example.foo.bar.YOUR_ACTION" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

see this answer for more info.


I think you are creating your intent wrong. Try like this:

String CUSTOM_ACTION = "com.example.foo.bar.YOUR_ACTION";

//Intent i = new Intent(this, FeedBackActivity.class);  // <--- You might need to do it this way.
Intent i = new Intent();
i.setAction(CUSTOM_ACTION);

startActivity(i);