在Cordova应用程序中获得更多功能 [英] Get extras in Cordova app

查看:86
本文介绍了在Cordova应用程序中获得更多功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

We have two Android applications: one implemented using native Java and another written using Ionic. The Ionic app launches my app which is the Android app using the lampaa plugin. I could receive the extras that the Ionic app provides using the following code:

String keyid = getIntent().getStringExtra("keyid");

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

Before I exit my app, I would like to send extras to the Ionic app. This is easily done from the Android side. How does the Ionic app know that my application has transferred control to it and how can it retrieve the extras that I have sent?

推荐答案

我认为,要从您的本机应用中获取其他功能,您需要使用其他插件,例如

I think in your case to get extras from your native app you need to use other plugin like 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
          }
    };

要获取更多帮助,请访问此处.

For more help check to here.

希望这对您有帮助!

这篇关于在Cordova应用程序中获得更多功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆