6

I am a newbie to developing in phonegap so I am sorry if this is a obvious answer. This is the last part of my project the only part of it that isnt functioning is the plugin.

I get the message "Failed to send email via Android Intent" and get the following error in logcat "Error: Status=2 Message=Class not found at file:///android_asset/www/phonegap-1.4.1.js:651"

I cannot figure this out, I have been at it for the past day!

I have added the plugin to the plugin.xml

plugin name="webintent" value="com.borismus.webintent.WebIntent"

I have the correct name space for the WebIntent.java file.

package borismus.webintent;

And I have the webintent.js file referenced in my index.html.

Below is the function which uses the plugin. function emailxmlfile(){

var subject = "Sports Code Xml Edit List" + filedate.toDateString();
var body = "";
if(!window.plugins || !window.plugins.webintent){

    alert('Unable to find webintent plugin');

}else{



var extras={};

extras[WebIntent.EXTRA_SUBJECT] = subject;
extras[WebIntent.EXTRA_TEXT] = body;

 window.plugins.webintent.startActivity({
        action: WebIntent.ACTION_SEND,
        type: 'text/plain',
        extras: extras
      }, function() {}, function(e) {alert('Failed to send email via Android Intent');});

}};

Any Help would be greatly appreciated. Thanks

M0nk3y1089
  • 63
  • 1
  • 6

4 Answers4

6

I know I might be late, but got your same code working without a minor and subtle change: respect capitalization when adding the plugin details to the .xml file. I mean, you stated this:

plugin name="webintent" value="com.borismus.webintent.WebIntent"

BUT should read this instead (watch out for the name!):

plugin name="WebIntent" value="com.borismus.webintent.WebIntent"

the red squiggle in Eclipse goes away once you correct the typo, and the code just works fine so I can invoke the email app from mine.

HTH!

Ranhiru Jude Cooray
  • 19,542
  • 20
  • 83
  • 128
Zalakain
  • 597
  • 5
  • 9
4

Usally when you get that message, its that you have missed to add the plugin to plugins.xml

<plugin name="WebIntent" value="com.borismus.webintent.WebIntent"/>
koffster
  • 418
  • 4
  • 7
3

Things change a lot faster when dealing with Android apps, too bad most of the documentation doesn't get updated as fast as it should.

I'm using phonegap 2.0.0 and I had to add the plugin configuration to the config.xml file and not inside plugins.xml.

Make sure you're loading phonegap.js (cordova-2.0.0.js in my case), webintent.js and that you have the correct package structure on your src folder (src/com/borismus/webintent/WenIntent.java)

You should be all set then.

Sikora
  • 766
  • 6
  • 6
  • You are the first one who wrote that plugins.xml changed to config.xml... I was really lost until now and was making plugins.xml file myself...tnx – gorgi93 Sep 21 '12 at 13:28
0

You stated the package is:

package borismus.webintent;

but defined with:

plugin name="webintent" value="com.borismus.webintent.WebIntent"

You're not missing the "com." on the package declaration?

scooterman
  • 1,336
  • 2
  • 17
  • 36