TimePicker Plugin Direction

100 views
Skip to first unread message

Keith

unread,
Apr 5, 2011, 11:10:07 PM4/5/11
to phonegap
Hi all,

I'm trying to integrate the native android timepicker into a phonegap
app.

I'm aware of the android plugins out on git but they all seem to deal
with Intents and not Dialogs.

Can someone give me some advice on the best way to accomplish this?
Is it possible through the plugin architecture?

Thanks for the help!

Keith

unread,
Apr 6, 2011, 11:05:18 PM4/6/11
to phonegap
http://wiki.phonegap.com/w/page/27915465/How-to-show-and-hide-soft-keyboard-in-Android

This describes the direction I'm planning to take except use the
Android native timepicker wherever you see keyboard.

I'd love to do this in the plugin architecture, but need some
direction on how it would work.

Keith

unread,
Apr 8, 2011, 12:46:13 AM4/8/11
to phonegap

FWIW here's what I've got working.

A simple TimePicker class with a showTimePicker method.

public class TimePicker {
private DroidGap mGap;

public TimePicker(DroidGap gap)
{
mGap = gap;
}

public void showTimePicker(){
mGap.showDialog(HelloWorldPlugin.TIME_DIALOG_ID);
}
}

A custom TimePickerDialog.OnTimeSetListener which is initialized with
knowledge of DroidGap too...

@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
mGap.sendJavascript(" callback javascript goes here!");
}

Initialize and add the createdialog stuff like the android dialog
tutorial.

TimePicker timepicker = new TimePicker(this, appView);
appView.addJavascriptInterface(timepicker, "TimePicker");

Then in the javascript, once phonegap loads, you can refer to the
timepicker:

window.TimePicker.showTimePicker();


Hope that Saves Somebody else some time or inspires somebody to show
me the ways of the plugin framework.

Reply all
Reply to author
Forward
0 new messages