open an activity from a CordovaPlugin

前端 未结 6 1900
深忆病人
深忆病人 2020-12-13 06:27

I have written a CordavaPlugin derived class.

public class ShowMap extends CordovaPlugin {

@Override
public boolean execute(String action, JSONArray args,
          


        
6条回答
  •  攒了一身酷
    2020-12-13 07:20

    Post now in 2017, because it's the top-ranked google search result for "cordova plugin activity" and top-voted answer, along with Cordova plugin guide are both missing the following critical information, that took me many hours to figure out... the parent attrib of config-file and the specific code:

    Added to plugin.xml, customized according to your needs:

    
    
        
                 
    
    

    Updating launching code with above package & activity:

    Context context=this.cordova.getActivity().getApplicationContext();
    //or Context context=cordova.getActivity().getApplicationContext();
    Intent intent=new Intent(context, com.custompackage.MyCustomActivity.class);
    
    context.startActivity(intent);
    //or cordova.getActivity().startActivity(intent);
    

提交回复
热议问题