@@ -280,7 +280,7 @@ protected Intent configureIntent(JSONArray args, JSONObject activityParams, Call
280280 intent .setPackage (targetPackage );
281281 }
282282
283- intentFromClass (intent , activityParams , callbackContext );
283+ intent = intentFromClass (intent , activityParams , callbackContext );
284284
285285 intent = intentFromComponent (intent , activityParams , callbackContext );
286286 }
@@ -342,33 +342,27 @@ protected Intent intentFromUri(Intent intent, JSONObject activityParams, Callbac
342342
343343 protected Intent intentFromClass (Intent intent , JSONObject activityParams , CallbackContext callbackContext ) throws JSONException {
344344
345- if (activityParams .has ("className" )) {
345+ if (activityParams .has ("className" ) && activityParams . has ( "packageName" ) ) {
346346
347- Activity activity = null ;
348-
349- if (!activityParams .has ("packageName" )
350- || activityParams .getString ("packageName" ).contains (cordova .getActivity ().getPackageName ())) {
351- activity = cordova .getActivity ();
352- }
353-
354- if (activity != null ) {
355- try {
347+ try {
356348
357- Class <?> activityClass = Class .forName (activityParams .getString ("packageName" ) + "." + activityParams .getString ("className" ));
358- intent = new Intent (activity , activityClass );
359- intent .setFlags (Intent .FLAG_ACTIVITY_CLEAR_TOP );
349+ intent = new Intent (activityParams .optString ("packageName" ) + "." + activityParams .getString ("className" ));
350+ intent .setFlags (Intent .FLAG_ACTIVITY_CLEAR_TOP );
360351
361- }catch (Exception clsErr ) {
362- JSONObject error = errorResult (clsErr );
352+ }catch (Exception clsErr ) {
353+ JSONObject error = errorResult (clsErr );
363354
364- callbackContext .error (error );
365- clsErr .printStackTrace ();
366- }
367- }else {
368- ComponentName component = new ComponentName (activityParams .getString ("packageName" ), activityParams .getString ("className" ));
369- intent = new Intent ().setComponent (component );
355+ callbackContext .error (error );
356+ clsErr .printStackTrace ();
370357 }
358+ }else {
359+ JSONObject error = new JSONObject ();
360+ error .put ("message" , "The params 'packageName' and 'className' is required" );
361+ error .put ("sucess" , false );
362+
363+ callbackContext .error (error );
371364 }
365+
372366 return intent ;
373367 }
374368
0 commit comments