protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById<Button> (Resource.Id.myButton); Button button1 = FindViewById<Button> (Resource.Id.button1); // Instantiate the builder and set notification elements: builder = new Notification.Builder (this) .SetContentTitle ("Test") .SetContentText ("This is test") .SetSmallIcon (Resource.Drawable.Icon); // Build the notification: notification = builder.Build (); // Get the notification manager: notificationManger = GetSystemService (Context.NotificationService) as NotificationManager; const int notificationId = 0; button.Click += delegate { // Publish the notification: notificationManger.Notify (notificationId,notification); button.Text = string.Format ("{0} clicks!", count++); }; button1.Click += delegate { builder = new Notification.Builder (this) .SetContentTitle ("Updated Test") .SetContentText ("This is updated test") .SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate) .SetSmallIcon (Resource.Drawable.Icon); // Build the notification: notification = builder.Build (); // Publish the notification: notificationManger.Notify (notificationId,notification); button.Text = string.Format ("{0} clicks!", count++); }; }
public MediaNotificationManager(MusicService serv) { service = serv; UpdateSessionToken(); notificationColor = ResourceHelper.GetThemeColor(service, Android.Resource.Attribute.ColorPrimary, Color.DarkGray); notificationManager = (NotificationManager) service .GetSystemService(Context.NotificationService); var pkg = service.PackageName; pauseIntent = PendingIntent.GetBroadcast(service, RequestCode, new Intent(ActionPause).SetPackage(pkg), PendingIntentFlags.CancelCurrent); playIntent = PendingIntent.GetBroadcast(service, RequestCode, new Intent(ActionPlay).SetPackage(pkg), PendingIntentFlags.CancelCurrent); previousIntent = PendingIntent.GetBroadcast(service, RequestCode, new Intent(ActionPrev).SetPackage(pkg), PendingIntentFlags.CancelCurrent); nextIntent = PendingIntent.GetBroadcast(service, RequestCode, new Intent(ActionNext).SetPackage(pkg), PendingIntentFlags.CancelCurrent); notificationManager.CancelAll(); mCb.OnPlaybackStateChangedImpl = (state) => { playbackState = state; LogHelper.Debug (Tag, "Received new playback state", state); if (state != null && (state.State == PlaybackStateCode.Stopped || state.State == PlaybackStateCode.None)) { stopNotification (); } else { Notification notification = CreateNotification (); if (notification != null) { notificationManager.Notify (NotificationId, notification); } } }; mCb.OnMetadataChangedImpl = (meta) => { metadata = meta; LogHelper.Debug (Tag, "Received new metadata ", metadata); var notification = CreateNotification (); if (notification != null) { notificationManager.Notify (NotificationId, notification); } }; mCb.OnSessionDestroyedImpl = () => { LogHelper.Debug (Tag, "Session was destroyed, resetting to the new session token"); UpdateSessionToken (); }; }
public void NotifyVersion26(Context context, Android.Content.Res.Resources res, Android.App.NotificationManager manager) { string channelName = "Secondary Channel"; var importance = NotificationImportance.High; var channel = new NotificationChannel(PRIMARY_CHANNEL, channelName, importance); var path = Android.Net.Uri.Parse("android.resource://com.ufinix.uberdriver/" + Resource.Raw.alert); var audioattribute = new AudioAttributes.Builder() .SetContentType(AudioContentType.Sonification) .SetUsage(AudioUsageKind.Notification).Build(); channel.EnableLights(true); channel.EnableLights(true); channel.SetSound(path, audioattribute); channel.LockscreenVisibility = NotificationVisibility.Public; manager.CreateNotificationChannel(channel); Intent intent = new Intent(context, typeof(MainActivity)); intent.AddFlags(ActivityFlags.SingleTop); PendingIntent pendingIntent = PendingIntent.GetActivity(context, 0, intent, PendingIntentFlags.CancelCurrent); Notification.Builder builder = new Notification.Builder(context) .SetContentTitle("Uber Driver") .SetSmallIcon(Resource.Drawable.ic_location) .SetLargeIcon(BitmapFactory.DecodeResource(res, Resource.Drawable.iconimage)) .SetContentText("You have a new trip request") .SetChannelId(PRIMARY_CHANNEL) .SetAutoCancel(true) .SetContentIntent(pendingIntent); manager.Notify(NOTIFY_ID, builder.Build()); }
public void Create(string deviceName) { string content = deviceName + "(이)가 등록되었습니다"; Intent defaultIntent = new Intent(Application.Context, typeof(MainActivity)); defaultIntent.PutExtra("goToMain", "goToMain"); PendingIntent defaultPendingIntent = PendingIntent.GetActivity(Application.Context, 1, defaultIntent, PendingIntentFlags.UpdateCurrent); var notification = new Notification.Builder(Application.Context, channelId) .SetContentIntent(defaultPendingIntent) .SetSmallIcon(Resource.Drawable.noti_logo) .SetLargeIcon(BitmapFactory.DecodeResource(Application.Context.Resources, Resource.Drawable.bell)) .SetContentTitle("장치 등록") .SetContentText(content) .SetShowWhen(true) .Build(); manager.Notify(NOTIFICATION_ID++, notification); }
public override void OnCreate() { base.OnCreate(); _player = MediaPlayer.Create(this, Resource.Raw.M77_Bombay_Street_Up_In_The_Sky); _player.Looping = false; _notificationManager = (NotificationManager)GetSystemService(NotificationService); var notification = new Notification(Resource.Drawable.Icon, "Service started", DateTime.Now.Ticks); notification.Flags = NotificationFlags.NoClear; PendingIntent notificationIntent = PendingIntent.GetActivity(this, 0, new Intent(this, typeof(GiraffeActivity)), 0); notification.SetLatestEventInfo(this, "Music Service", "The music service has been started", notificationIntent); _notificationManager.Notify((int)Notifications.Started, notification); }
public void NotifyNewChapters(Context context, List <Chapter> chapters) { if (chapters.Count < 1) { return; } Builder builder = GetBuilder(context, ChannelId.NewChapter); builder.SetAutoCancel(true); builder.SetNumber(4); builder.SetOnlyAlertOnce(true); builder.SetContentTitle("1 New Chapter"); builder.SetContentText(chapters[0].Title); Intent intent = new Intent(Intent.ActionView); intent.SetData(Uri.Parse(chapters[0].URL)); intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask); PendingIntent pendingIntent = PendingIntent.GetActivity(context, (int)ChannelId.NewChapter, intent, PendingIntentFlags.OneShot); builder.SetContentIntent(pendingIntent); if (chapters.Count > 1) { builder.SetContentTitle($"{chapters.Count} New Chapters"); builder.SetSubText($"and {chapters.Count - 1} more"); var inboxStyle = new Notification.InboxStyle(GetBuilder(context, ChannelId.NewChapter)); inboxStyle.SetBigContentTitle($"{chapters.Count} New Chapters"); foreach (Chapter chapter in chapters) { inboxStyle.AddLine(chapter.Title); } builder.SetStyle(inboxStyle); } //Bitmap icon = BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.new_chapter_icon); builder.SetSmallIcon(Resource.Drawable.new_chapter_icon); NotificationManagerCompat notificationManager = GetManager(context); notificationManager.Notify((int)ChannelId.NewChapter, builder.Build()); }
public void NotifyOtherVersions(Context context, Android.Content.Res.Resources res, Android.App.NotificationManager manager) { Intent intent = new Intent(context, typeof(MainActivity)); intent.AddFlags(ActivityFlags.SingleTop); PendingIntent pendingIntent = PendingIntent.GetActivity(context, 0, intent, PendingIntentFlags.CancelCurrent); var path = Android.Net.Uri.Parse("android.resource://com.ufinix.uberdriver/" + Resource.Raw.alert); Notification.Builder builder = new Notification.Builder(context) .SetContentTitle("Uber Driver") .SetSmallIcon(Resource.Drawable.ic_location) .SetLargeIcon(BitmapFactory.DecodeResource(res, Resource.Drawable.iconimage)) .SetTicker("You have a new trip request") .SetChannelId(PRIMARY_CHANNEL) .SetSound(path) .SetAutoCancel(true) .SetContentIntent(pendingIntent); manager.Notify(NOTIFY_ID, builder.Build()); }
public override void OnCreate() { base.OnCreate(); socket.On("notification", data => { var e = JsonConvert.DeserializeObject <List <Device> >(data.ToString()); Android.App.Notification.Builder builder = new Android.App.Notification.Builder(this) .SetContentTitle("Turned On") .SetContentText(e[0].name + " " + e[0].value + " W") .SetDefaults(NotificationDefaults.Sound) .SetSmallIcon(e[0].icon_id); // Build the notification: Android.App.Notification notification = builder.Build(); // Get the notification manager: Android.App.NotificationManager notificationManager = GetSystemService(Context.NotificationService) as NotificationManager; // Publish the notification: const int notificationId = 0; notificationManager.Notify(notificationId, notification); }); }
public override View GetView(int position, View convertView, ViewGroup parent) { if (convertView != null) return convertView; LayoutInflater mInflater = LayoutInflater.From(context); View view = null; view = mInflater.Inflate(Resource.Layout.Index_Item, null); ImageView image = view.FindViewById<ImageView>(Resource.Id.Index_ItemImage); TextView name = view.FindViewById<TextView>(Resource.Id.Index_ItemText); TextView no = view.FindViewById<TextView>(Resource.Id.Index_ItemText_no); switch (list[position]) { #region 录入补货 case "录入补货": image.SetImageResource(Resource.Drawable.AccBook); name.Text = list[position]; view.Click += delegate { //Intent intent = new Intent(); //intent.SetClass(context, typeof(Customer)); //context.StartActivity(intent); context.StartActivity(typeof(Customer)); }; break; #endregion #region 购 物 车 case "购 物 车": image.SetImageResource(Resource.Drawable.shoppingcart); name.Text = list[position]; //if (Shopping.GetShoppingToStr() != "") // no.Visibility = ViewStates.Visible; view.Click += delegate { context.StartActivity(typeof(OrderSave)); }; break; #endregion #region 本地订单 case "本地订单": image.SetImageResource(Resource.Drawable.GetMain); name.Text = list[position]; //int row = SqliteHelper.ExecuteNum("select count(*) from getmain where isupdate ='N'"); //if (row > 0) // no.Visibility = ViewStates.Visible; view.Click += delegate { context.StartActivity(typeof(GetMian)); }; break; #endregion #region 订单查询 case "订单查询": image.SetImageResource(Resource.Drawable.Replenishment); name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "App/Dw_GetMain"); intent.PutExtras(bu); intent.SetClass(context, typeof(Web)); context.StartActivity(intent); }; break; #endregion #region 出货单查询 case "出货单查询": image.SetImageResource(Resource.Drawable.OutOne); name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "App/Dw_OutOne"); intent.PutExtras(bu); intent.SetClass(context, typeof(Web)); context.StartActivity(intent); }; break; #endregion #region 库存查询 case "库存查询": image.SetImageResource(Resource.Drawable.btn_Stock); name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "App/Dw_Stock"); intent.PutExtras(bu); intent.SetClass(context, typeof(Web)); context.StartActivity(intent); }; break; #endregion #region 刷新数据 case "刷新数据": image.SetImageResource(Resource.Drawable.Refresh); name.Text = list[position]; view.Click += delegate { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetTitle("提示:"); builder.SetMessage("确认刷新所有数据吗?建议在WiFi环境下执行此操作"); builder.SetPositiveButton("确定", delegate { SysVisitor.CreateServerDB(); Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "data"); bu.PutString("update", "update"); intent.PutExtras(bu); intent.SetClass(context, typeof(Loading)); context.StartActivity(intent); }); builder.SetNegativeButton("取消", delegate { }); builder.Show(); }; break; #endregion #region 注销登陆 case "注销登陆": image.SetImageResource(Resource.Drawable.zhuxiao); name.Text = list[position]; view.Click += delegate { _publicfuns.of_SetMySysSet("Login", "username", ""); _publicfuns.of_SetMySysSet("Login", "password", ""); _publicfuns.of_SetMySysSet("Login", "logindate", DateTime.Now.AddDays(-30).ToString()); Intent it = new Intent(); it.SetClass(context.ApplicationContext, typeof(MainActivity)); context.StartActivity(it); }; break; #endregion #region 退出系统 case "退出系统": image.SetImageResource(Resource.Drawable.btn_Exit); name.Text = list[position]; view.Click += delegate { System.Threading.Thread.Sleep(500); ContextWrapper cw = new ContextWrapper(context); Intent exitIntent = new Intent(Intent.ActionMain); exitIntent.AddCategory(Intent.CategoryHome); exitIntent.SetFlags(ActivityFlags.NewTask); cw.StartActivity(exitIntent); Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); }; break; #endregion #region 检查更新 case "检查更新": image.SetImageResource(Resource.Drawable.btn_update); name.Text = list[position]; view.Click += delegate { view.Enabled = false; string str = Core.Update.of_update(true); view.Enabled = true; if (str.Substring(0, 2) != "ER") { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetTitle("提示:"); builder.SetMessage("当前版本为" + _publicfuns.of_GetMySysSet("app", "vercode") + "服务器上最新版本为 " + str + " ,确定下载更新吗?"); builder.SetPositiveButton("确定", delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "download"); intent.PutExtras(bu); intent.SetClass(context, typeof(Loading)); context.StartActivity(intent); }); builder.SetNegativeButton("取消", delegate { return; }); builder.Show(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetTitle("提示:"); builder.SetMessage(str + " 当前版本为" + _publicfuns.of_GetMySysSet("app", "vercode")); builder.SetPositiveButton("确定", delegate { return; }); builder.Show(); } }; break; #endregion #region 录入回款 case "录入回款": image.SetImageResource(Resource.Drawable.backmoneyrecord); name.Text = list[position]; view.Click += delegate { //Intent intent = new Intent(Android.Provider.MediaStore.ActionImageCapture); //string file = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(), // Android.OS.Environment.DirectoryDcim.ToString(), "test.jpg"); //outputFileUri = Android.Net.Uri.Parse(file); //intent.PutExtra(Android.Provider.MediaStore.ExtraOutput, outputFileUri); //activity.StartActivityForResult(intent, TAKE_PICTRUE); Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "backmoneyrecord"); bu.PutString("ischeck", "false"); intent.PutExtras(bu); intent.SetClass(context, typeof(Customer)); context.StartActivity(intent); }; break; #endregion #region 本地回款 case "本地回款": image.SetImageResource(Resource.Drawable.GetBackmoney); name.Text = list[position]; //int row = SqliteHelper.ExecuteNum("select count(*) from Backmoneyrecord where isupdate ='N'"); //if (row > 0) // no.Visibility = ViewStates.Visible; view.Click += delegate { context.StartActivity(typeof(GetBackmoney)); }; break; #endregion #region 消息通知 case "消息通知": image.SetImageResource(Resource.Drawable.message); int li_msg_count = 0; try { //以后在后台刷新 防止网络不好时卡在启动页面 //li_msg_count = int.Parse(SysVisitor.Of_GetStr(SysVisitor.Get_ServerUrl()+ "/App/MsgList.aspx?select=num")); } catch { } if (li_msg_count > 0) { no.Visibility = ViewStates.Visible; Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "App/GetAppMsg.ashx"); intent.PutExtras(bu); intent.SetClass(context, typeof(Web)); nMgr = (NotificationManager)context.GetSystemService(Context.NotificationService); Notification notify = new Notification(Resource.Drawable.Icon, "有新的通知消息"); //初始化点击通知后打开的活动 PendingIntent pintent = PendingIntent.GetActivity(context, 0, intent, PendingIntentFlags.UpdateCurrent); //设置通知的主体 notify.SetLatestEventInfo(context, "有新的通知消息", "点击查看详细内容", pintent); nMgr.Notify(0, notify); } name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "App/GetAppMsg.ashx"); intent.PutExtras(bu); intent.SetClass(context, typeof(Web)); context.StartActivity(intent); }; break; #endregion #region 即时通讯 case "即时通讯": image.SetImageResource(Resource.Drawable.im3); name.Text = list[position]; view.Click += delegate { context.StartActivity(typeof(Buddylist)); }; break; #endregion #region 系统设置 case "系统设置": image.SetImageResource(Resource.Drawable.config); name.Text = list[position]; view.Click += delegate { context.StartActivity(typeof(Config)); }; break; #endregion #region 拍照上传 case "拍照上传": image.SetImageResource(Resource.Drawable.picture); name.Text = list[position]; view.Click += delegate { context.StartActivity(typeof(PhotoBrowse)); }; break; #endregion #region 新品订货 case "新品订货": image.SetImageResource(Resource.Drawable.AccBook_new); name.Text = list[position]; view.Click += delegate { //Intent intent = new Intent(Android.Provider.MediaStore.ActionImageCapture); //string file = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(), // Android.OS.Environment.DirectoryDcim.ToString(), "test.jpg"); //outputFileUri = Android.Net.Uri.Parse(file); //intent.PutExtra(Android.Provider.MediaStore.ExtraOutput, outputFileUri); //activity.StartActivityForResult(intent, TAKE_PICTRUE); Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "OrderCar"); bu.PutString("ischeck", "false"); intent.PutExtras(bu); intent.SetClass(context, typeof(Customer)); context.StartActivity(intent); }; break; #endregion #region 客户对账 case "客户对账": image.SetImageResource(Resource.Drawable.BackMoney); name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "WebDw_AccBook"); bu.PutString("ischeck", "false"); intent.PutExtras(bu); intent.SetClass(context, typeof(Customer)); context.StartActivity(intent); }; break; #endregion #region 回款查询 case "回款查询": image.SetImageResource(Resource.Drawable.ShowBackMoneyreCord); name.Text = list[position]; view.Click += delegate { Intent intent = new Intent(); Bundle bu = new Bundle(); bu.PutString("name", "App/Dw_BackMoneyreCord.aspx"); intent.PutExtras(bu); intent.SetClass(context, typeof(Web)); context.StartActivity(intent); }; break; #endregion #region 查看销价 case "查看销价": image.SetImageResource(Resource.Drawable.SalePrice); name.Text = list[position]; view.Click += delegate { context.StartActivity(typeof(SalePrice)); }; break; #endregion } view.SetPadding(2, 4, 2, 8); return view; }