Permission Error Opening Gmail Compose with Lampaa com.lampaa.startapp Plugin


#1

I am trying to get the startApp plugin to work properly, but am having trouble. I can get it to open up gmail from inside my app with:

let sApp = startApp.set({
      "action": "ACTION_VIEW",
      "package":"com.google.android.gm"
    });

However, what I’m really trying to do is get it to open up the compose view in gmail and also pass gmail the address I’m hoping to send to. This is my first time working with android intents and I’m not quite sure of a couple things:

The com.lampaa.startapp README says I can use this format to open a specific activity within the target package:

var sApp = startApp.set({ /* params */
	"component": ["com.app.name","com.app.name.Activity"]
}, { /* extras */
	"extraKey1":"extraValue1",
	"extraKey2":"extraValue2"
});

I found a few other sites that lay out how I might do this if I were developing natively with java:

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setType("plain/text");
sendIntent.setData(Uri.parse("test@gmail.com"));
sendIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "test@gmail.com" });
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "test");
sendIntent.putExtra(Intent.EXTRA_TEXT, "hello. this is a message sent from my demo app :-)");
startActivity(sendIntent);

However, when I translate what I’m seeing up in that codeblock to what the startapp documentation asks for, I get an error.

let sApp = startApp.set({
      "action": "ACTION_VIEW",
      "component": ['com.google.android.gm', 'com.google.android.gm.ComposeActivityGmail'],
      "package": 'com.google.android.gm',
      "type": "plain/text",
    }, {
      EXTRA_EMAIL: ['picard@enterprise.com'],
      EXTRA_SUBJECT: 'Your tea is ready',
      EXTRA_TEXT: "earl grey, hot."
    });
I/startApp: android.intent.extra.EMAIL
E/startApp: android.intent.extra.EMAIL
I/startApp: android.intent.extra.SUBJECT
E/startApp: android.intent.extra.SUBJECT
I/startApp: android.intent.extra.TEXT
E/startApp: android.intent.extra.TEXT
E/PluginManager: Uncaught exception from plugin
                 java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] typ=plain/text flg=0x10000000 pkg=com.google.android.gm cmp=com.google.android.gm/.ComposeActivityGmail (has extras) } from ProcessRecord{e9404d6 30081:org.gds.hop/u0a180} (pid=30081, uid=10180) not exported from uid 10091
                     at android.os.Parcel.readException(Parcel.java:1943)
                     at android.os.Parcel.readException(Parcel.java:1889)
                     at android.app.IActivityManager$Stub$Proxy.startActivity(IActivityManager.java:4365)
                     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1610)
                     at android.app.Activity.startActivityForResult(Activity.java:4472)
                     at org.apache.cordova.CordovaActivity.startActivityForResult(CordovaActivity.java:342)
                     at android.app.Activity.startActivityForResult(Activity.java:4430)
                     at android.app.Activity.startActivity(Activity.java:4791)
                     at android.app.Activity.startActivity(Activity.java:4759)
                     at com.lampa.startapp.startApp.start(startApp.java:178)
                     at com.lampa.startapp.startApp.execute(startApp.java:44)
                     at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
                     at org.apache.cordova.PluginManager.exec(PluginManager.java:132)
                     at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:57)
                     at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
                     at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
                     at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:9)
                     at android.os.Handler.dispatchMessage(Handler.java:105)
                     at android.os.Looper.loop(Looper.java:164)
                     at android.os.HandlerThread.run(HandlerThread.java:65)
  1. Does the permission mean I have to whitelist something in config.xml? If so – what do I need to whitelist?
  2. What am I doing wrong?