在Cordova应用程序中获得更多功能

San*_*ung 2 android extras cordova

我们有两个Android应用程序:一个使用本机Java实现,另一个使用Ionic编写。Ionic应用程序使用lampaa插件启动我的应用程序,即Android应用程序。我可以使用以下代码接收Ionic应用提供的额外功能:

String keyid = getIntent().getStringExtra("keyid");
Run Code Online (Sandbox Code Playgroud)

在退出我的应用程序之前,我想将其他内容发送到Ionic应用程序。从Android方面很容易做到这一点。Ionic应用程序如何知道我的应用程序已将控制权转移给它,它如何检索我已发送的附加内容?

San*_*nde 5

我认为,在您的情况下,要从本机应用程序获取其他功能,您需要使用其他插件,例如cordova-plugin-intent

例如 :

    //To get the intent and extras when the app it's open for the first time
    window.plugins.intent.getCordovaIntent (function (intent) {
        intenthandler(intent);
    });

    //To get the intent and extras if the app is running in the background
    window.plugins.intent.setNewIntentHandler (function (intent) {
        intenthandler(intent);
    });

    //To handle the params
    var intenthandler = function (intent) {
          if (intent && intent.extras && intent.extras.myParams) {
        //Do something
          }
    };
Run Code Online (Sandbox Code Playgroud)

如需更多帮助,请访问此处

希望这对您有帮助!