Exemple #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.SMSTransferContactLayout);
            Title = "添加联系电话/邮箱";
            var helper   = new ExtSQLiteHelper(this);
            var editText = FindViewById <EditText>(Resource.Id.contact_text);

            editText.Text = string.Join("\r\n", helper.GetContact());

            #region
            FindViewById <Button>(Resource.Id.save_contact_button).Click += (sender, e) =>
            {
                if (editText != null)
                {
                    var lines = editText.Text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    helper.SaveContact(lines);
                }
                Toast.MakeText(this, "完成", ToastLength.Short).Show();
            };
            FindViewById <Button>(Resource.Id.cancel_contact_button).Click += (sender, e) =>
            {
                this.Finish();
            };
            #endregion
        }
Exemple #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.AppLogLayout);
            var helper  = new ExtSQLiteHelper(this);
            var logtext = FindViewById <TextView>(Resource.Id.text_applog);

            logtext.Text = helper.GetAppLog();
            logtext.SetCursorVisible(false);//Edittext只读
            logtext.Focusable            = false;
            logtext.FocusableInTouchMode = false;

            Title = "运行日志";
            #region
            FindViewById <Button>(Resource.Id.clear_applog_button).Click += (sender, e) =>
            {
                helper.ClearAppLog();
                logtext.Text = "";
                Toast.MakeText(this, "操作完成", ToastLength.Short).Show();
            };
            FindViewById <Button>(Resource.Id.cancel_applog_button).Click += (sender, e) =>
            {
                this.Finish();
            };
            #endregion
            // Create your application here
        }
        public override void OnCreate()
        {
            base.OnCreate();
            #region  --注册短信接收服务--
            intentFilter = new IntentFilter();
            intentFilter.AddAction("android.provider.Telephony.SMS_RECEIVED");
            smsReceiver = new SMSBroadcastReceiver();
            smsReceiver.MessageCallbackEvent += SmsReceiver_MessageCallbackEvent;

            RegisterReceiver(smsReceiver, intentFilter);
            #endregion

            #region
            helper = new ExtSQLiteHelper(this);
            #endregion
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.SMSTransferConfigLayout);
            Title = "发送配置";
            // Create your application here
            var helper = new ExtSQLiteHelper(this);
            Dictionary <string, string> dic;
            var templatetext     = FindViewById <EditText>(Resource.Id.text_template);
            var smtpservertext   = FindViewById <EditText>(Resource.Id.text_smtpserver);
            var smtpporttext     = FindViewById <EditText>(Resource.Id.text_smtpport);
            var smtpaccounttext  = FindViewById <EditText>(Resource.Id.text_smtpaccount);
            var smtppasswordtext = FindViewById <EditText>(Resource.Id.text_smtppassword);
            var controlphonetext = FindViewById <EditText>(Resource.Id.text_controlphone);

            #region
            dic = helper.GetConfig();
            templatetext.Text     = dic.ContainsKey("messagetemplate") ? dic["messagetemplate"] : "";
            smtpservertext.Text   = dic.ContainsKey("smtpserver") ? dic["smtpserver"] : "";
            smtpporttext.Text     = dic.ContainsKey("smtpport") ? dic["smtpport"] : "25";
            smtpaccounttext.Text  = dic.ContainsKey("smtpaccount") ? dic["smtpaccount"] : "";
            smtppasswordtext.Text = dic.ContainsKey("smtppassword") ? dic["smtppassword"] : "";
            controlphonetext.Text = dic.ContainsKey("controlphone") ? dic["controlphone"] : "";
            #endregion

            #region
            FindViewById <Button>(Resource.Id.save_config_button).Click += (sender, e) =>
            {
                dic = new Dictionary <string, string>();
                dic.Add("messagetemplate", templatetext.Text);
                dic.Add("smtpserver", smtpservertext.Text);
                dic.Add("smtpport", smtpporttext.Text);
                dic.Add("smtpaccount", smtpaccounttext.Text);
                dic.Add("smtppassword", smtppasswordtext.Text);
                dic.Add("controlphone", controlphonetext.Text.Trim().TrimStart('+'));
                helper.SaveConfig(dic);

                Toast.MakeText(this, "完成", ToastLength.Short).Show();
            };
            FindViewById <Button>(Resource.Id.cancel_config_button).Click += (sender, e) =>
            {
                this.Finish();
            };
            #endregion
        }
Exemple #5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            //var intent = new Intent(this,typeof(SMSContentProviderActivity));
            //StartActivity(intent);

            //var intent2 = new Intent(this, typeof(BroadcastReceiverActivity));
            //StartActivity(intent2);
            SetContentView(Resource.Layout.Main);
            Title = "短信转发";
            #region
            var helper = new ExtSQLiteHelper(this);
            var dic    = helper.GetSendStatus();
            FindViewById <TextView>(Resource.Id.text_sendsuccessstatistics).Text = string.Format("发送成功{0}条", dic.ContainsKey("sendsuccess") ? dic["sendsuccess"] : "0");
            FindViewById <TextView>(Resource.Id.text_sendfailurestatistics).Text = string.Format("发送失败{0}条", dic.ContainsKey("sendfailure") ? dic["sendfailure"] : "0");
            var startbtn = FindViewById <Button>(Resource.Id.start_service_button);
            var endbtn   = FindViewById <Button>(Resource.Id.stop_service_button);

            if (isServiceRunning(Android.OS.Process.MyPid()))
            {
                startbtn.Visibility = Android.Views.ViewStates.Gone;
            }
            else
            {
                endbtn.Visibility = Android.Views.ViewStates.Gone;
            }
            #endregion

            #region
            startbtn.Click += (sender, e) =>
            {
                Intent intent = new Intent(this, typeof(SMSReceiverService));
                StartService(intent);//启动服务
                helper.UpdateSendStatus(1);
                Toast.MakeText(this, "后台服务已启动", ToastLength.Short).Show();

                startbtn.Visibility = Android.Views.ViewStates.Gone;
                endbtn.Visibility   = Android.Views.ViewStates.Visible;
            };
            endbtn.Click += (sender, e) =>
            {
                Intent intent = new Intent(this, typeof(SMSReceiverService));
                StopService(intent);//停止服务
                helper.UpdateSendStatus(0);
                Toast.MakeText(this, "后台服务已停止", ToastLength.Short).Show();

                endbtn.Visibility   = Android.Views.ViewStates.Gone;
                startbtn.Visibility = Android.Views.ViewStates.Visible;
            };

            FindViewById <Button>(Resource.Id.edit_smscontact_button).Click += (sender, e) =>
            {
                Intent intent = new Intent(this, typeof(SMSTransferContactActivity));
                StartActivity(intent);
            };
            FindViewById <Button>(Resource.Id.edit_smsconfig_button).Click += (sender, e) =>
            {
                Intent intent = new Intent(this, typeof(SMSTransferConfigActivity));
                StartActivity(intent);
            };
            FindViewById <Button>(Resource.Id.view_applog_button).Click += (sender, e) =>
            {
                Intent intent = new Intent(this, typeof(AppLogActivity));
                StartActivity(intent);
            };
            #endregion
        }