Phonegap Plugin working together with Activity

614 views
Skip to first unread message

אבינועם

unread,
Jun 12, 2011, 8:41:47 AM6/12/11
to phonegap
I am building a Plugin service manager for a "special" Alarm Clock.

The first problem is that i am new to Android but have a lot's of experience in Java.

The Problem is my class Extends Android Activity,
And I Just dont know how to Make Triggers in my Phonegap Plugin to call my Class ??

I tried Creating a new intent in my Plugin but when I call on startActivity() function the program doesn't want to compile.
When I read about it all i get is that Only class that Extends Activity can call other Activities.

Another friend said to me "you need to pass the context of the main activity and then you can do anything".
Obviously I cant pass the context from javascript :)
But when i try the function getApplicationContext(); it does not compile...
Same issue as before....

Any Suggestion or small Example will be most appreciated,
Avinoam

אבינועם

unread,
Jun 12, 2011, 9:55:07 AM6/12/11
to phonegap
I read a bit more and got to the point that that in phonagap plugin i can get context from:

this.ctx

Now my program compiles but it crashes...
my code is pretty simple and it's inside the plugin class to check if it works directly without another class in the middle :

context= this.ctx;
Intent myIntent= new Intent(context, com.Somthing.MyAlarmService.class);
pendingIntent = PendingIntent.getService(context, 0, myIntent, 0);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.SECOND, 10);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);

and some of the error log

06-12 16:48:35.006: INFO/ActivityManager(67): Starting activity: Intent { cmp=com.Somthing/.MyAlarmClock }
06-12 16:48:35.297: DEBUG/dalvikvm(524): newInstance failed: no <init>()
06-12 16:48:35.377: DEBUG/AndroidRuntime(524): Shutting down VM
06-12 16:48:35.571: ERROR/AndroidRuntime(524): Caused by: java.lang.InstantiationException: com.Somthing.MyAlarmClock


any help ... :)

אבינועם

unread,
Jun 12, 2011, 10:52:22 AM6/12/11
to phonegap

manage to figure out the problem works like a charm.
With this.ctx

בתאריך 2011 6 12 16:55, מאת "אבינועם" <avin...@gmail.com> :

Eldad Yamin

unread,
Jun 12, 2011, 11:00:48 AM6/12/11
to phon...@googlegroups.com
I think you sent it to the wrong email.

--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com

אבינועם

unread,
Jun 13, 2011, 1:15:48 AM6/13/11
to phonegap
manage to figure out the problem works like a charm.
With this.ctx

Reply all
Reply to author
Forward
0 new messages