标签:des android blog java os io for ar art
一开始的思路是通过android content provider获取
大部分手机系统,闹钟都被重新包装了一道,根本找不到的。
Uri uri = Uri.parse("content://com.android.alarmclock/alarm"); Cursor c = context.getContentResolver().query(uri, null, null, null, null); if (c != null) { if (c.moveToFirst()) { do { for (int j = 0; j < c.getColumnCount(); j++) { Log.i(tag_alarm, c.getColumnName(j) + " which has value " + c.getString(j)); } } while (c.moveToNext()); } c.close(); }
还会有可能出现如下错误:
10-29 12:01:05.597: W/System.err(30638): java.lang.SecurityException: Provider com.android.deskclock/com.android.deskclock.AlarmProvider does not allow granting of Uri permissions (uri content://com.android.deskclock/alarm) 10-29 12:01:05.597: W/System.err(30638): at android.os.Parcel.readException(Parcel.java:1425) 10-29 12:01:05.597: W/System.err(30638): at android.os.Parcel.readException(Parcel.java:1379) 10-29 12:01:05.597: W/System.err(30638): at android.app.ActivityManagerProxy.grantUriPermission(ActivityManagerNative.java:2941) 10-29 12:01:05.597: W/System.err(30638): at android.app.ContextImpl.grantUriPermission(ContextImpl.java:1382) 10-29 12:01:05.597: W/System.err(30638): at android.content.ContextWrapper.grantUriPermission(ContextWrapper.java:453) 10-29 12:01:05.597: W/System.err(30638): at com.ry.ui.phone.RYUIPlatform.AlarmTime(RYUIPlatform.java:285) 10-29 12:01:05.597: W/System.err(30638): at com.ry.ui.sunlock.sunLock.onResume(sunLock.java:319) 10-29 12:01:05.597: W/System.err(30638): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1184) 10-29 12:01:05.597: W/System.err(30638): at android.app.Activity.performResume(Activity.java:5082) 10-29 12:01:05.597: W/System.err(30638): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2816) 10-29 12:01:05.597: W/System.err(30638): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2854) 10-29 12:01:05.597: W/System.err(30638): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2329) 10-29 12:01:05.597: W/System.err(30638): at android.app.ActivityThread.access$600(ActivityThread.java:139) 10-29 12:01:05.597: W/System.err(30638): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1295) 10-29 12:01:05.597: W/System.err(30638): at android.os.Handler.dispatchMessage(Handler.java:99) 10-29 12:01:05.597: W/System.err(30638): at android.os.Looper.loop(Looper.java:137) 10-29 12:01:05.597: W/System.err(30638): at android.app.ActivityThread.main(ActivityThread.java:5117) 10-29 12:01:05.597: W/System.err(30638): at java.lang.reflect.Method.invokeNative(Native Method) 10-29 12:01:05.597: W/System.err(30638): at java.lang.reflect.Method.invoke(Method.java:511) 10-29 12:01:05.597: W/System.err(30638): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 10-29 12:01:05.597: W/System.err(30638): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558) 10-29 12:01:05.597: W/System.err(30638): at dalvik.system.NativeStart.main(Native Method) 10-29 12:01:05.597: W/System.err(30638): java.lang.SecurityException: Provider com.android.deskclock/com.android.deskclock.TimersProvider does not allow granting of Uri permissions (uri content://com.android.deskclock.timers)
google 了一翻。就是没找到解决之道
发现用如下方法可以直接取到下一个闹钟的时间
String str = Settings.System.getString(mActivityObject.getContentResolver(), Settings.System.NEXT_ALARM_FORMATTED);
标签:des android blog java os io for ar art
原文地址:http://www.cnblogs.com/owner/p/3934736.html