【问题标题】:Update the device time from another App not from System App从另一个应用程序而不是系统应用程序更新设备时间
【发布时间】:2014-01-06 12:03:12
【问题描述】:

您好,我正在构建一个 Android 应用程序。它接受用户在 DatePicker 和 TimePicker 中的输入并设置设备时间或模块时间。

这是我正在使用的代码

            int     nHrTime;
    int     nMinTime;
    int     nYear;

    int nMonth;
    int nDay;

    nHrTime     =  DeviceTimePickr.getCurrentHour();
    nMinTime    =  DeviceTimePickr.getCurrentMinute();

    nYear   =  DeviceDatePickr.getYear();
    nMonth      =  DeviceDatePickr.getMonth();
    nDay        =  DeviceDatePickr.getDayOfMonth();

    dDeviceCalendar.set(nYear, nMonth,nDay,nHrTime, nMinTime);

在 manifest.xml 文件中,我也更改了权限。

清单文件的变化

         <uses-permission android:name="android.permission.SET_TIME" 
    android:protectionLevel="signature|system"/>

为什么这不起作用?我使用的是安卓 4.22

【问题讨论】:

    标签: android date android-datepicker android-timepicker


    【解决方案1】:

    更改设备时间不适用于非 root 设备上的应用。因此,它对您不起作用:

    android:protectionLevel="signature|system"
    

    这意味着只有系统应用程序或使用系统证书签名的应用程序才被授予此权限。你不是。

    【讨论】:

    • 那么,如果我从 Manifest 中删除这行代码,它会开始工作吗?如果不是,那么需要做哪些更改?
    • 请给我建议。我是安卓新手。
    • 没有。您不会被授予此权限。您无法通过应用更改系统时间。
    • 那么还有什么其他的解决方案请给我建议吗?我应该使用哪个系统应用来更改设备时间?
    • 根设备。或者放弃这个想法。
    猜你喜欢
    • 2021-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-05
    相关资源
    最近更新 更多