Dominik
Dominik

Reputation: 1693

Open external Android app from within MGWT (gwt-phonegap) app

I'm trying to find out how I can launch a native Android app inside a MGWT app (wrapped into a native Android app with PhoneGap) by clicking on a button (for example).

I've followed the Open another application from your own (intent) and it works great using this code snippet:

Button openAppButton = (Button) findViewById(R.id.openApp);
openAppButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

            // THIS WORKS GREAT         
            Intent i = new Intent();
            PackageManager manager = getPackageManager();
            i = manager.getLaunchIntentForPackage("ch.android.test2");
            i.addCategory(Intent.CATEGORY_LAUNCHER);
            startActivity(i);
        }

    });

So basically if I click the button in app1 it opens the native app with namespace "ch.android.test2".

The difference is though that this works just launching a native Android app from within another native Android app. What I need is the same functionality from a PhoneGap app made with MGWT.

How would I have to accomplish this? Thanks for suggestions in advance.

Upvotes: 0

Views: 852

Answers (1)

Daniel Kurka
Daniel Kurka

Reputation: 7985

With phonegap you can write any native code, so you need to move the code you pointed out into a phonegap plugin as Simon pointed out, see: http://docs.phonegap.com/en/2.3.0/guide_plugin-development_android_index.md.html#Developing%20a%20Plugin%20on%20Android

After that you need to call your plugin from GWT source code by using JSNI. Take a look at the ChildBrowser implementation in gwt-phonegap: http://code.google.com/p/gwt-phonegap/source/browse/src/main/java/com/googlecode/gwtphonegap/client/plugins/childbrowser/ChildBrowserPhoneGapImpl.java

Upvotes: 2

Related Questions