当接收到消息时,亮屏震动提醒
来源:互联网 发布:mac book pro 2018 编辑:程序博客网 时间:2024/04/19 06:26
<uses-permission android:name="android.permission.WAKE_LOCK" />解锁屏权限<uses-permission android:name="android.permission.VIBRATE" />震动权限msgGetRemind();PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");wl.acquire();wl.release();Intent alarmIntent = new Intent(context, WindowMessageActivity.class); alarmIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);turnTo(alarmIntent);context.startActivity(alarmIntent);//震动(需要权限)private void msgGetRemind() { Vibrator vib = (Vibrator) context.getSystemService(Service.VIBRATOR_SERVICE); vib.vibrate(500); }以上是震动提醒和亮屏显示,一下是亮屏后显示的Activitypublic class WindowMessageActivity extends ActivityEx { private TextView textName; private Bundle bundle = null; @Override protected void onCreate(Bundle savedInstanceState) { final Window win = getWindow(); win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);setContentView(R.layout.activity_window_message);Log.i("---messagechat", "oncreate_show");textName = (TextView) findViewById(R.id.local_screen_message_content);getData(null);super.onCreate(savedInstanceState);}public void onClick(View view) {Intent intent = new Intent(this,MessageChat.class);intent.putExtras(bundle);startActivity(intent);this.finish();}private void getData(Intent intent) { Intent mIntent = null; if (intent != null) { mIntent = intent; } else { mIntent = getIntent(); } bundle = mIntent.getExtras(); }@Overrideprotected void onNewIntent(Intent intent) { getData(intent); super.onNewIntent(intent); Log.i("---messagechat", "onnewintent_show"); }}
阅读全文
0 0
- 当接收到消息时,亮屏震动提醒
- notification..消息提醒,有震动提醒效果
- iOS 当APP接收到推送消息时,对推送消息进行处理
- Android Notification实现推送消息过程中接受到消息端有声音及震动及亮屏提示
- 安卓应用在后台运行时,通知栏收到应用消息提醒时取消铃声和震动
- 接收到推送消息时,提示声音
- xmpp即时通讯之接收消息提示声音+震动
- LocationListener监听位置变化,当进入到某一距离内时发出提醒
- activemq接收到的消息为空
- 接收到推送消息处理方法
- Jpush消息广播无法接收到
- 接收到推送消息处理方法
- 接收到推送消息处理方法
- notification初使用:震动提醒、跳转
- iOS—接收到APNs远程推送消息时的处理流程
- 如何在接收到空的远程推送消息时,在APP作出响应。
- 消息接收
- 接收消息
- Linux_Redis_Cluster 安装笔记
- Wireshark 系列(1). Ubuntu 上安装
- Makefile常用万能模板(包括静态链接库、动态链接库、可执行文件)
- OGG-00665 OCI Error executing single row select
- Dubbo入门及Demo运行实例
- 当接收到消息时,亮屏震动提醒
- 开始写博客啦!
- 解决UnicodeEncodeError: 'ascii' codec can't encode characters in position问题
- 在Linux运行期间升级Linux系统(Uboot+kernel+Rootfs)
- javaEE开发中使用session同步和token机制来防止并发重复提交
- (86)蓝图UI之我的蓝图
- /*****/关于图2.0
- win10+vs2013+opencv2.4.10+vlfeat+matlab2016b+python配置
- 技术地谈Google Lens