Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap 1.4.1 WebIntent plugin Error "Class not found" Android

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

like image 742
M0nk3y1089 Avatar asked Apr 03 '12 11:04

M0nk3y1089


Video Answer


2 Answers

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!

like image 186
Zalakain Avatar answered Nov 14 '22 23:11

Zalakain


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"/>
like image 33
koffster Avatar answered Nov 14 '22 22:11

koffster