@ Override public Intent getIntentForActivity ( Class < ? extends Activity > activityClass ) { PackageManager packageManager = getTargetContext ( ) . getPackageManager ( ) ; ComponentName componentName = new ComponentName ( getTargetContext ( ) , activityClass ) ; Intent intent = Intent . makeMainActivity ( componentName ) ; if ( packageManager . resolveActivity ( intent , 0 ) != null ) { return intent ; } return Intent . makeMainActivity ( new ComponentName ( getContext ( ) , activityClass ) ) ; }
This implementation makes sure that the activity you are trying to launch exists