public class MyBroadCastReceiver extends BroadcastReceiver {
@SuppressWarnings("deprecation")
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
String string = intent.getStringExtra("msg");
Toast.makeText(context, string, 0).show();
NotificationManager manager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent2 = new Intent(context, MainActivity.class);
intent2.putExtra("NOTICE", true);
intent2.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
intent2, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new Notification(R.drawable.ic_launcher,
"通知未打开显示的标题", System.currentTimeMillis());
notification.setLatestEventInfo(context.getApplicationContext(),
"通知的标题", "通知的内容" + string, pendingIntent);
AudioManager mAudioManager = (AudioManager) context
.getSystemService(Context.AUDIO_SERVICE);
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.defaults = Notification.DEFAULT_LIGHTS
| Notification.DEFAULT_VIBRATE;
notification.sound = Uri.parse("android.resource://"
+ context.getPackageName() + "/" + R.raw.newdatatoast);
manager.notify(0, notification);
}
}
Android 广播 通知 带振动 声音
原创
©著作权归作者所有:来自51CTO博客作者leeyulong的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇:我的友情链接
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Android平台RTMP推送|轻量级RTSP服务如何实现麦克风|扬声器声音采集切换
技术背景我们在做Android端同屏的时候,开发者希望可以高版本的Android系统上,在设备支持的前提下,可以采集到扬声器输出的audio,并支持和麦克风采集的audio相互切换,实现无纸化|智慧教室同屏不同audio模式的输出。Android系统出于安全和隐私的考虑,默认并不允许应用程序直接访问系统级别的音频输出。从Android 10(API级别29)开始,Android引入了媒体投影API
Android采集扬声器声音 Android采集扬声器 Android扬声器播放声音 Android同屏 大牛直播SDK