├── settings.gradle ├── ic_launcher-web.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── app ├── src │ └── main │ │ ├── res │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ ├── values-v11 │ │ │ └── styles.xml │ │ ├── xml │ │ │ └── my_admin_receiver.xml │ │ ├── values-v14 │ │ │ └── styles.xml │ │ └── layout │ │ │ ├── activity_main.xml │ │ │ └── alert_layout.xml │ │ ├── java │ │ └── com │ │ │ └── cloay │ │ │ └── alertnotifidemo │ │ │ ├── MyAdminReceiver.java │ │ │ ├── MyReceiver.java │ │ │ ├── MainActivity.java │ │ │ ├── MyService.java │ │ │ └── AlertActivity.java │ │ └── AndroidManifest.xml └── build.gradle ├── README.md ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── import-summary.txt └── gradlew /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloay/AlertNotifiDemo/HEAD/ic_launcher-web.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloay/AlertNotifiDemo/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloay/AlertNotifiDemo/HEAD/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloay/AlertNotifiDemo/HEAD/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloay/AlertNotifiDemo/HEAD/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloay/AlertNotifiDemo/HEAD/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AlertNotifiDemo 5 | Hello world! 6 | 7 | 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | AlertNotifiDemo 2 | =============== 3 | 4 | Show a dialog to display a new message on lock screen like QQ5.0 for android. 5 | 6 | like this:
7 | 8 | 9 | [作者博客: 仿QQ5.0Android版 在锁屏桌面显示消息框](http://cloay.com/blog/2014/08/25/fang-qq5-dot-0androidban-zai-suo-ping-zhuo-mian-xian-shi-xiao-xi-kuang/) -------------------------------------------------------------------------------- /app/src/main/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/cloay/alertnotifidemo/MyAdminReceiver.java: -------------------------------------------------------------------------------- 1 | package com.cloay.alertnotifidemo; 2 | 3 | import android.app.admin.DeviceAdminReceiver; 4 | /** 5 | * 6 | * @ClassName: MyAdminReceiver 7 | * @Description: 8 | * @author cloay Email:shangrody@gmail.com 9 | * @date 2014-8-22 下午6:21:08 10 | * 11 | */ 12 | public class MyAdminReceiver extends DeviceAdminReceiver{ 13 | 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/res/xml/my_admin_receiver.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 14 5 | buildToolsVersion "24.0.0" 6 | 7 | defaultConfig { 8 | applicationId "com.cloay.alertnotifidemo" 9 | minSdkVersion 14 10 | targetSdkVersion 14 11 | } 12 | 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile 'com.android.support:support-v4:18.0.0' 23 | } 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | .idea 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | 39 | # Keystore files 40 | *.jks 41 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/cloay/alertnotifidemo/MyReceiver.java: -------------------------------------------------------------------------------- 1 | package com.cloay.alertnotifidemo; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.util.Log; 7 | /** 8 | * 9 | * @ClassName: MyReceiver 10 | * @Description: 11 | * @author cloay Email:shangrody@gmail.com 12 | * @date 2014-8-22 下午6:20:19 13 | * 14 | */ 15 | public class MyReceiver extends BroadcastReceiver{ 16 | 17 | @Override 18 | public void onReceive(Context context, Intent intent) { 19 | // 20 | Log.v("AlertNotifi", "on receive....."); 21 | 22 | Intent intentAlert = new Intent(context, AlertActivity.class); 23 | intentAlert.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 24 | context.startActivity(intentAlert); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Thu Aug 11 14:21:34 CST 2016 16 | systemProp.http.proxyHost=127.0.0.1 17 | systemProp.http.proxyPort=1080 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/cloay/alertnotifidemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.cloay.alertnotifidemo; 2 | 3 | 4 | import android.app.Activity; 5 | import android.app.admin.DevicePolicyManager; 6 | import android.content.ComponentName; 7 | import android.content.Intent; 8 | import android.os.Bundle; 9 | 10 | /** 11 | * 12 | * @ClassName: MainActivity 13 | * @Description: 14 | * @author cloay Email:shangrody@gmail.com 15 | * @date 2014-8-22 上午10:30:31 16 | * 17 | */ 18 | public class MainActivity extends Activity { 19 | private Intent intent; 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_main); 25 | 26 | DevicePolicyManager policyManager = (DevicePolicyManager) getSystemService(DEVICE_POLICY_SERVICE); 27 | ComponentName componentName = new ComponentName(this, MyAdminReceiver.class); 28 | 29 | boolean isAdminActive = policyManager.isAdminActive(componentName); 30 | if(!isAdminActive){ 31 | Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); 32 | intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, componentName); 33 | startActivity(intent); 34 | } 35 | 36 | intent = new Intent(this, MyService.class); 37 | startService(intent); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/res/layout/alert_layout.xml: -------------------------------------------------------------------------------- 1 | 4 | 10 | 15 | 20 | 24 |