1: 启动App在前台,即使已经锁屏
final Window win = getWindow();
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
// 保持屏幕高亮
win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
//去除Activity标题
requestWindowFeature(Window.FEATURE_NO_TITLE);
//布局解析器
LayoutInflater mFactory = LayoutInflater.from(this);
mFactory.inflate(AlarmClock.CLOCKS[position], null);
SharedPreferences 共享存储
SharedPreferences mPrefs = getSharedPreferences(AlarmClock.PREFERENCES, 0);
int face = mPrefs.getInt(AlarmClock.PREF_CLOCK_FACE, 0);
SharedPreferences.Editor ed = mPrefs.edit();
ed.putInt(AlarmClock.PREF_CLOCK_FACE, position);
ed.commit();
2:对Provider 数据改动注册监听
private class FormatChangeObserver extends ContentObserver {
public FormatChangeObserver() {
super(new Handler());
}
@Override
public void onChange(boolean selfChange) {
setDateFormat();
updateTime();
}
}
mFormatChangeObserver = new FormatChangeObserver();
mContext.getContentResolver().registerContentObserver(
Settings.System.CONTENT_URI, true, mFormatChangeObserver);
Settings.System.CONTENT_URI 可用任意Provider的URi进行替换,
在provider中可通过getContentResolver().notifyChange(uri,..)提示更改,call back ContentObserver
public void notifyChange
(Uri uri,
ContentObserver observer)
Notify registered observers that a row was updated. To register, call registerContentObserver()
.
By default, CursorAdapter objects will get this notification.
Parameters
observer
The observer that originated the change, may be null
|
3:键盘锁管理器
KeyguardManager km =
(KeyguardManager) context.getSystemService(
Context.KEYGUARD_SERVICE);
//If keyguard screen is showing or in restricted key input mode
km.inKeyguardRestrictedInputMode()
//开启键盘锁
km.newKeyguardLock( tag)
//关闭,带回调接口
km.exitKeyguardSecurely( arg0)
4:PowerManager.WakeLock
在Android中,申请WakeLock可以让你的进程持续执行即使手机进入睡眠模式,
比较实用的是比如:
后台有网络功能,可以保证操作持续进行
PowerManager pm =
(PowerManager) context.getSystemService(Context.POWER_SERVICE);
sCpuWakeLock = pm.newWakeLock(
PowerManager.PARTIAL_WAKE_LOCK |
PowerManager.ACQUIRE_CAUSES_WAKEUP |
PowerManager.ON_AFTER_RELEASE, Log.LOGTAG);
sCpuWakeLock.acquire();
释放
if (sCpuWakeLock != null) {
sCpuWakeLock.release();
sCpuWakeLock = null;
}
5: Alarm Manager
AlarmManager am = (AlarmManager)
context.getSystemService(Context.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, atTimeInMillis, Intent);
am.setInexactRepeating
(int type, long triggerAtTime, long interval,
PendingIntent operation)
am.setRepeating
(int type, long triggerAtTime, long interval,
PendingIntent operation)
分享到:
相关推荐
android studio期末作业AnderWeb-android_packages_apps_Launcher-4458ee4AnderWeb-android_packages_apps_Launcher-4458ee4AnderWeb-android_packages_apps_Launcher-4458ee4AnderWeb-android_packages_apps_...
slam cleaner robot android app source code
AnderWeb-android_packages_apps_Launcher-4458ee4.zip AnderWeb-android_packages_apps_Launcher-4458ee4.zip AnderWeb-android_packages_apps_Launcher-4458ee4.zip AnderWeb-android_packages_apps_Launcher-4458...
Pro-Android-Web-Apps-Developing-HTML5-JavaScript-CSS-and-Chrome-OS-Web-Apps.pd
Android-apps-android-wikipedia.zip,官方的Android维基百科应用程序!,安卓系统是谷歌在2008年设计和制造的。操作系统主要写在爪哇,C和C 的核心组件。它是在linux内核之上构建的,具有安全性优势。
Android--开发--AnderWeb-Android--开发--_packages_apps_Launcher-4458ee4
Android Apps的GUI设计(GUI Design for Android Apps)-英文原版,0积分
Android-amazing-android-apps.zip,用Java编写的惊人的开源Android应用程序。,安卓系统是谷歌在2008年设计和制造的。操作系统主要写在爪哇,C和C 的核心组件。它是在linux内核之上构建的,具有安全性优势。
Developing-Android-Apps-course Udacity course by Google see: https://www.udacity.com/course/developing-android-apps--ud853 Lesson 1 - Creating Project Sunshine - Learn how to create and run a simple ...
com-google-android-apps-authenticator2-6004000-64865720-4047d033a11fdda7627bb45f5be525b1.apk.1
Apps using the library: Gourmet (http://thegourmet.app) Playstore PS: Please let me know if you are using this library in your app to list here. email: ark.akshaykale@gmail.com) Install Add ...
This library is a download manager android/java library which developers can use in their apps and allow you to download files in parallel mechanism in some chunks and notify developers about tasks ...
Android Payments Support both Google Play and Amazon Kindle Fire in-app purchase payments with a single API Handy for small apps with in-app purchase (IAP) items that need both Google Play store and ...
Android 16-bit Clock Widget. Download it at Google Play: https://play.google.com/store/apps/details?id=com.lucasdnd.bitclock16 It works by dividing the day into 16 bits, or 65536 parts. That makes ...
This library provides a highly configurable logging framework for Android apps, supporting multiple log destinations simultaneously: files SQLite databases logcat sockets syslog email Runs on ...
Android-android-instant-apps.zip,迁移:,安卓系统是谷歌在2008年设计和制造的。操作系统主要写在爪哇,C和C 的核心组件。它是在linux内核之上构建的,具有安全性优势。
Version 4.0.0 now requires Android target SDK 26 and Gradle 3 plugin in order to support ExoPlayer 2.9.0. Google is dropping support for apps using target SDKs older than 26 as of Oc
We specialize in the designing and coding of custom UI for Mobile Apps and Websites.Looking for developers for your project? The Android mockup available here. Requirements Android 4.0 ...