コード例 #1
0
        internal static void SwitchToActivity <T>(this ContextWrapper contextWrapper, ActivityFlags flags) where T : BaseActivity
        {
            Intent intent = new Intent(contextWrapper, typeof(T));

            intent.SetFlags(flags);
            contextWrapper.StartActivity(intent);
        }
コード例 #2
0
ファイル: clocktest.cs プロジェクト: probo11/EHBO
        /// <summary>
        /// Receives the OneShot alarm Broadcast when it gets sent
        /// </summary>
        /// <param name="context"></param>
        /// <param name="intent"></param>
        public override void OnReceive(Context context, Intent intent)
        {
            //Not sure if i can use this  context here, might work buggy
            ContextWrapper p = new ContextWrapper(context);
            Intent         q = new Intent(context, typeof(AlarmScreenActivity));

            q.AddFlags(ActivityFlags.NewTask);
            p.StartActivity(q);
        }
コード例 #3
0
        public static void NavigateToSendEmail(this ContextWrapper context, Email toSend)
        {
            var email = new Intent(Intent.ActionSend);

            email.PutExtra(Intent.ExtraEmail, new[] { toSend.To });
            email.PutExtra(Intent.ExtraSubject, toSend.Subject);
            email.PutExtra(Intent.ExtraText, toSend.Body);
            email.SetType("message/rfc822");
            context.StartActivity(email);
        }
コード例 #4
0
        /// <summary>
        /// 下载的文件进行安装
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="context"></param>
        public static void installApk(string filePath, ContextWrapper context)
        {
            if (context == null)
            {
                return;
            }
            // 通过Intent安装APK文件
            Intent intent = new Intent(Intent.ActionView);

            intent.SetDataAndType(Android.Net.Uri.Parse("file://" + filePath), "application/vnd.android.package-archive");
            //Uri content_url = Uri.Parse(filePath);
            //intent.SetData(content_url);
            intent.SetFlags(ActivityFlags.NewTask);
            context.StartActivity(intent);
        }
コード例 #5
0
ファイル: Index.cs プロジェクト: eatage/AppTest.bak
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            // TODO Auto-generated method stub  
            LayoutInflater mInflater = LayoutInflater.From(context);
            //产生一个View  
            View view = null;
            //根据type不同的数据类型构造不同的View,也可以根据1,2,3天数构造不同的样式  
            //view = mInflater.inflate(R.layout.city_item, 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);
            switch (list[position])
            {
                case "在线补货":
                    image.SetImageResource(Resource.Drawable.customer);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        //Intent intent = new Intent();
                        //intent.SetClass(context, typeof(Customer));
                        //context.StartActivity(intent);
                        context.StartActivity(typeof(Customer));
                    };
                    break;
                case "购物车":
                    image.SetImageResource(Resource.Drawable.shoppingcart);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        Intent intent = new Intent();
                        intent.SetClass(context, typeof(OrderSave));
                        context.StartActivity(intent);
                    };
                    break;
                case "查看订单":
                    image.SetImageResource(Resource.Drawable.GetMain);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        Intent intent = new Intent();
                        intent.SetClass(context, typeof(GetMian));
                        context.StartActivity(intent);
                    };
                    break;
                case "网上查单":
                    image.SetImageResource(Resource.Drawable.Replenishment);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        Intent intent = new Intent();
                        intent.SetClass(context, typeof(Web));
                        context.StartActivity(intent);
                    };
                    break;
                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", "Dw_Stock");
                        intent.PutExtras(bu);
                        intent.SetClass(context, typeof(Web));
                        context.StartActivity(intent);
                    };
                    break;
                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;
                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;
                case "退出系统":
                    image.SetImageResource(Resource.Drawable.btn_Exit);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        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;
                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;
                case "选择相片":
                    image.SetImageResource(Resource.Drawable.Icon);
                    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);
                        context.StartActivity(typeof(ChatMian));
                    };
                    break;
            }
            view.SetPadding(8, 8, 8, 28);
            return view;
        }
コード例 #6
0
ファイル: Index.cs プロジェクト: eatage/AppTest
            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;
            }
コード例 #7
0
ファイル: Config.cs プロジェクト: eatage/GyAppMf
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.Config);

            ImageButton cancel = FindViewById<ImageButton>(Resource.Id.Config_cancel);
            TextView version = FindViewById<TextView>(Resource.Id.Config_version);
            TextView usernanme = FindViewById<TextView>(Resource.Id.Config_username);
            RelativeLayout update = FindViewById<RelativeLayout>(Resource.Id.Config_btn_update);
            RelativeLayout zhuxiao = FindViewById<RelativeLayout>(Resource.Id.Config_btn_zhuxiao);
            RelativeLayout Refresh = FindViewById<RelativeLayout>(Resource.Id.Config_btn_Refresh);
            RelativeLayout exit = FindViewById<RelativeLayout>(Resource.Id.Config_btn_exit);

            usernanme.Text = Core.SysVisitor.UserName;
            version.Text = "版本:" + Core.SysVisitor.getVersionName(this) + "  日期:" + Core.SysVisitor.getVersionCode(this);
            cancel.Click += delegate { StartActivity(typeof(Index)); };
            update.Click += delegate
            {
                update.Enabled = false;
                string str = Core.Update.of_update(true);
                update.Enabled = true;
                if (str.Substring(0, 2) != "ER")
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.SetTitle("提示:");
                    builder.SetMessage("当前版本为" + Core._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(this, typeof(Loading));
                        StartActivity(intent);
                    });
                    builder.SetNegativeButton("取消", delegate { return; });
                    builder.Show();
                }
                else
                {
                    str = str.Substring(4);
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.SetTitle("提示:");
                    builder.SetMessage(str);
                    builder.SetPositiveButton("确定", delegate
                    {
                        return;
                    });
                    builder.Show();
                }
            };
            zhuxiao.Click += delegate
            {
                SysVisitor.GetVibrator(this);
                //Core._publicfuns.of_SetMySysSet("Login", "username", "");
                //Core._publicfuns.of_SetMySysSet("Login", "password", "");
                //Core._publicfuns.of_SetMySysSet("Login", "logindate", DateTime.Now.AddDays(-30).ToString());
                _publicfuns.of_SetMySysSet("Login", "Login", "N");//标记为不自动登录
                StartActivity(typeof(MainActivity));
            };
            Refresh.Click += delegate
            {
                SysVisitor.GetVibrator(this);
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                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(this, typeof(Loading));
                    StartActivity(intent);
                });
                builder.SetNegativeButton("取消", delegate { });
                builder.Show();
            };
            exit.Click += delegate
            {
                SysVisitor.GetVibrator(this);
                System.Threading.Thread.Sleep(500);
                ContextWrapper cw = new ContextWrapper(this);
                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());
            };

            System.Threading.Thread thr = new System.Threading.Thread(new System.Threading.ThreadStart(of_netType));
            thr.Start();

            System.Threading.Thread thr1 = new System.Threading.Thread(() => { int a = 0;a++; });
            thr1.Start();
        }
コード例 #8
0
ファイル: SysVisitor.cs プロジェクト: eatage/AppTest.bak
 /// <summary>
 /// 关闭程序并释放所有程序占用的资源
 /// </summary>
 /// <param name="active"></param>
 public static void EXIT(Context context)
 {
     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());
 }
コード例 #9
0
 public static void StartActivity <T>(this ContextWrapper activity, Context context = null)
 {
     activity.StartActivity(new Intent(context ?? Application.Context, typeof(T)));
 }
コード例 #10
0
ファイル: Config.cs プロジェクト: eatage/AppTest
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.Config);

            LinearLayout cancel = FindViewById<LinearLayout>(Resource.Id.Config_cancel);
            TextView version = FindViewById<TextView>(Resource.Id.Config_version);
            TextView printername = FindViewById<TextView>(Resource.Id.Config_PrinterName);
            TextView usernanme = FindViewById<TextView>(Resource.Id.Config_username);
            RelativeLayout update = FindViewById<RelativeLayout>(Resource.Id.Config_btn_update);
            RelativeLayout zhuxiao = FindViewById<RelativeLayout>(Resource.Id.Config_btn_zhuxiao);
            RelativeLayout Refresh = FindViewById<RelativeLayout>(Resource.Id.Config_btn_Refresh);
            RelativeLayout RefreshAdd = FindViewById<RelativeLayout>(Resource.Id.Config_btn_RefreshAdd);
            RelativeLayout QRCode = FindViewById<RelativeLayout>(Resource.Id.Config_btn_QRCode);
            RelativeLayout exit = FindViewById<RelativeLayout>(Resource.Id.Config_btn_exit);
            RelativeLayout TestPrinter = FindViewById<RelativeLayout>(Resource.Id.Config_btn_TestPrinter);
            TextView netType = FindViewById<TextView>(Resource.Id.Config_netType);
            usernanme.Text = Core.SysVisitor.UserName;
            string ls_printerName= baseclass.MyConfig.of_GetMySysSet("printer", "name");
            if(!string.IsNullOrEmpty(ls_printerName))
            {
                printername.Text = ls_printerName;
            }
            version.Text = "版本:" + Core.SysVisitor.getVersionName(this) + "  日期:" + Core.SysVisitor.getVersionCode(this);
            cancel.Click += delegate
            {
                OnBackPressed();
                //StartActivity(typeof(Index));
            };
            update.Click += delegate
            {
                update.Enabled = false;
                string str = Core.Update.of_update(true);
                update.Enabled = true;
                if (str.Substring(0, 2) != "ER")
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.SetTitle("提示:");
                    builder.SetMessage("当前版本为" + Core._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(this, typeof(Loading));
                        StartActivity(intent);
                    });
                    builder.SetNegativeButton("取消", delegate { return; });
                    builder.Show();
                }
                else
                {
                    str = str.Substring(4);
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.SetTitle("提示:");
                    builder.SetMessage(str);
                    builder.SetPositiveButton("确定", delegate
                    {
                        return;
                    });
                    builder.Show();
                }
            };
            zhuxiao.Click += delegate
            {
                SysVisitor.GetVibrator(this);
                //Core._publicfuns.of_SetMySysSet("Login", "username", "");
                //Core._publicfuns.of_SetMySysSet("Login", "password", "");
                //Core._publicfuns.of_SetMySysSet("Login", "logindate", DateTime.Now.AddDays(-30).ToString());
                _publicfuns.of_SetMySysSet("Login", "Login", "N");//标记为不自动登录
                StartActivity(typeof(MainActivity));
            };
            Refresh.Click += delegate
            {
                SysVisitor.GetVibrator(this);
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.SetTitle("提示:");
                builder.SetMessage("确认刷新本地所有数据吗?\n此操作将会删除所有本地数据,并重新从服务器上下载\n建议在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(this, typeof(Loading));
                    StartActivity(intent);
                });
                builder.SetNegativeButton("取消", delegate { });
                builder.Show();
            };
            RefreshAdd.Click += delegate
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.SetTitle("提示:");
                builder.SetMessage("每次启动程序是会同步客户数据,历史销价数据与产品数据\n确定手动同步数据吗?");
                builder.SetPositiveButton("确定", delegate
                {
                    StarThread st = new StarThread();
                    int row = st.UpdateTableRow;
                    if (row == 0)
                        Toast.MakeText(this, "服务器没有更新数据或在启动时客户端已经完成同步", ToastLength.Short).Show();
                    else
                        Toast.MakeText(this, "成功从服务器同步" + row + "条数据", ToastLength.Short).Show();
                });
                builder.SetNegativeButton("取消", delegate { return; });
                builder.Show();

            };
            QRCode.Click += delegate
            {
                StartActivity(typeof(QRCode));
            };
            exit.Click += delegate
            {
                SysVisitor.GetVibrator(this);
                System.Threading.Thread.Sleep(500);
                ContextWrapper cw = new ContextWrapper(this);
                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());
            };
            netType.Click += delegate
            {
                if (as_date == null)
                    ai_clickNum++;
                else
                {
                    if (SysVisitor.DateDiff(as_date, SysVisitor.timeSpan.Milliseconds) < 300)
                    {
                        if (ai_clickNum == 3)
                        {
                            SysVisitor.GetVibrator(this);
                            StartActivity(typeof(TelePhoneManager));
                            Finish();
                        }
                        ai_clickNum++;
                    }
                    else
                    {
                        ai_clickNum = 0;
                    }
                }
                as_date = DateTime.Now;
            };
            TestPrinter.Click += delegate
            {
                string ls_BluetoothName = new BluetoothPrinter(this).as_BluetoothName;
                if (!string.IsNullOrEmpty(ls_BluetoothName))
                    baseclass.MyConfig.of_SetMySysSet("printer", "name", ls_BluetoothName);
            };
            System.Threading.Thread thr = new System.Threading.Thread(new System.Threading.ThreadStart(of_netType));
            thr.Start();
        }