I have an Honor V8 that has just updated to android 7.0
But now the DatePickerDialog in my app no longer shows a calendar, just spinners.
When I test in a emulator with android 7.0, it shows again the calendar.
I'm using this code to call the DatePickerDialog:
public static void OpenCalendarioDialog(Activity activity, DatePickerDialog.OnDateSetListener mDateSetListener, int year, int month, int day) {
DateFormat dateFormat = android.text.format.DateFormat.getLongDateFormat( activity.getApplicationContext());
Calendar cal = Calendar.getInstance();
String title = dateFormat.format(GetTimeDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)));
DatePickerDialog dialog = new DatePickerDialog(activity, mDateSetListener, year, month, day);
dialog.setTitle(title);
dialog.show();
}
So how I can make sure my DatePickerDialog will always use calendar view?
I'm not interested using a third party library
I found the solution. It is so simple I feel ashamed.
I just had to raise the targetSdkVersion to 24 because of the android 7.0
That reminds me when something is not working after an update this is the first thing I should check.
Edit:
I was wrong! Raising the targetSdkversion didn't solve the problem.
Instead, I had to add a DatePicker in a AlertDialog.
After the samsung lollipop issue, now this? Android is such a mess!!
Related
Facing issue in handling date picker in iOS App while automation of ios application.
Date picker is always showing current date. So, It changes everday.
Date format is MMM DD, YYYY
As it change on daily basis its hard to automate it with rolling measurement.
Code
List<WebElement> dateValue = driver.findElementsByClassName("XCUIElementTypePickerWheel");
for (int i = 0; i < dateValue.size(); i++) {
System.out.println(dateValue.get(i).getText());
}
dateValue.get(0).sendKeys("23");
dateValue.get(0).sendKeys(Keys.TAB);
dateValue.get(1).sendKeys("December");
dateValue.get(1).sendKeys(Keys.TAB);
dateValue.get(2).sendKeys("2000");
dateValue.get(2).sendKeys(Keys.TAB);
Appium provides mobile: method called selectPickerWheelValue that can be used for navigating a picker wheel using forward-and-back gestures:
HashMap<String, Object> params = new HashMap<>();
params.put("order", "next");
params.put("offset", 0.15);
params.put("element", ((RemoteWebElement) pickerWheelElement).getId());
driver.executeScript("mobile: selectPickerWheelValue", params);
This approach is more robust to select values. You can check the full example here
I am trying to get timezone from iOS device by using following code:
DateFormat date = new SimpleDateFormat("z",Locale.getDefault());
String localTime = date.format(currentLocalTime);
But it always return me in format of zone and city ex: Asia/Kolkata, whereas I want it to be like GMT+4-30.
On Android device and simulator it works fine but on iOS device it goes with city name.
So how do I get only timezone like GMT+ or GMT- for iOS?
Any information would be helpful. Thanks
Try using DateUtil.getOffset() e.g.:
int offset = new DateUtil().getOffset(timeInMS);
My app crashes with NullPointerException, since the android calendar does not return a Collection of calendar names from the dc.getCalendars(); function from the CN1 Calendar Lib, even though it is working to this point on the iOS iphone version.
Device Calendar dc = DeviceCalendar.getInstance();
Collection<String> calNames = dc.getCalendars();
String [] nameArray = calName.toArray(new String[calName.size()]);
Its throwing me an NullPointerException for the 3rd line because calName is a null object and I cant use size() on it. Again, the code IS working on iPhone, so it seems there is a problem with android.
Thanks in advance.
The javadocs for that method say that getCalendars() will return null if you don't have permission
https://github.com/sidiabale/codenameone-calendar/blob/master/CN1Calendar/src/com/codename1/calendar/DeviceCalendar.java#L91
You'll need to add the permissions using the android.xpermissions build hint.
codename1.arg.android.xpermissions=<uses-permission android:name="android.permission.READ_CALENDAR"/> <uses-permission android:name="android.permission.WRITE_CALENDAR"/>
And it looks like you also need to set android.targetSDKVersion=21
See this SO thread for a related issue.
Code works fine in simulator and for Android. Returns a null pointer exception when built for ios and run on an iPad. This worked last year when my app was originally written.
import java.util.Date;
import com.codename1.l10n.SimpleDateFormat;
public class StateMachine extends StateMachineBase {
#Override
protected void beforeNewSchedule(Form f) {
Date today = new Date(System.currentTimeMillis());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String curDate = dateFormat.format(today);
}}
Console output
java.lang.NullPointerException
at java_util_GregorianCalendar.computeFields:157
at java_util_Calendar.complete:406
at java_util_Calendar.setTimeInMillis:501
at java_util_Calendar.__INIT__:345
at java_util_GregorianCalendar.__INIT__:70
at java_util_Calendar.getInstance:422
at com_codename1_l10n_SimpleDateFormat.format:282
at com_codename1_l10n_SimpleDateFormat.format:265
at userclasses_StateMachine.beforeNewSchedule:51
at generated_StateMachineBase.beforeShow:178
at com_codename1_ui_util_UIBuilder_FormListener.run:2813
at com_codename1_ui_Display.processSerialCalls:1152
at com_codename1_ui_Display.edtLoopImpl:1096
at com_codename1_ui_Display.mainEDTLoop:997
at com_codename1_ui_RunnableWrapper.run:120
at com_codename1_impl_CodenameOneThread.run:176
at java_lang_Thread.runImpl:153
Nov 24 07:23:31 Barbaras-iPad MyApplication[1793] <Warning>:
This seems to be a regression related to this commit which fixed a timezone issue and effectively caused this cascading problem. It seems to only occur in specific timezones which is why we were unable to see this.
For now we deployed an older version of the VM to the servers to workaround this problem until we have a stabler fix.
It works now !!! Thanks so much.
My time zone is Arizona where we don't ever change to Daylight savings time if that helps.
I have just started using Agile Toolkit 4.2.0 for a simple CRUD web application, and so far I'm very impressed with the framework, except that I can't get column sorting to function properly.
Updating the dvdrental page/video.php example with an added line at the end for setting makeSortable() does not seem to work as intended. In all the browsers I have tested the code on so far (Firefox 12, Chrome 18, Opera 11.62 and IE 9), it only outputs a malformed line of HTML before the 'Year' column header.
class page_video extends Page {
function init(){
parent::init();
$this->api->auth->check();
$grid = $this->add('MVCGrid');
$grid->setModel('Movie');
$grid->getColumn('year')->makeSortable();
}
}
Any help would be greatly appreciated, and hopefully it's not a simple error caused by my own ineptitude with this new tool.
There is already an issue opened for this, https://github.com/atk4/atk4/issues/46