Android sets the system time to 24 hours and turns on the HP printing service

1. Set the system time to 24 hours
if(!DateFormat.is24HourFormat(mContext)) {
    android.provider.Settings.System.putString(mContext.getContentResolver(),
            android.provider.Settings.System.TIME_12_24, "24");
}

2. Set the system time

public void setSysDate(int year,int month,int day, int hour,int minute, int second){
    try {

        Calendar c = Calendar.getInstance();
        c.set(Calendar.YEAR, year);
        c.set(Calendar.MONTH, month - 1);
        c.set(Calendar.DAY_OF_MONTH, day);

        c.set(Calendar.HOUR_OF_DAY, hour);
        c.set(Calendar.MINUTE, minute);
        c.set(Calendar.SECOND, second);
        c.set(Calendar.MILLISECOND, 0);

        long when = c.getTimeInMillis();

        if(when / 1000 < Integer.MAX_VALUE){
            ((AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE)).setTime(when);
        }

    }catch (Exception e) {
        e.printStackTrace();
    }

}

Use the code to set in the APP, the APP needs the system signature, the above code function will take effect

//Enable the HP printing service of the system
String str = Settings.Secure.getString(mContext.getContentResolver(), "enabled_print_services");
if(str == null || str.equals("")) {
    Settings.Secure.putString(mContext.getContentResolver(), "enabled_print_services", "com.hp.android.printservice/com.hp.android.printservice.ServiceAndroidPrint");
}

おすすめ

転載: blog.csdn.net/chongchi_wxcc/article/details/126822394