Пример #1
0
 public void SetValue(Java.Lang.String value)
 {
     returnValue = value.ToString();
     try { latch.CountDown(); } catch (System.Exception ex) {
         DLogger.WriteLog(ex);
     }
 }
        public bool OpenURLScheme(Java.Lang.String packageName, Java.Lang.String URIScheme)
        {
            if (IsPackageInstalledAndEnabled(packageName.ToString(), activity))
            {
                Intent intent = new Intent();
                intent.SetPackage(packageName.ToString());
                intent.SetAction(Intent.ActionView);
                intent.SetData(Uri.Parse(URIScheme.ToString()));
                activity.StartActivityForResult(intent, 0);

                return(true);
            }
            else
            {
                Intent intent = new Intent();
                intent.SetAction(Intent.ActionView);
                intent.SetData(Uri.Parse(URIScheme.ToString()));
                activity.StartActivityForResult(intent, 0);
            }

            return(false);
        }
Пример #3
0
        private void Read()
        {
            int bytes = 0;

            byte[] buffer = new byte[32];
            isReading = true;

            while (isReading)
            {
                try
                {
                    bytes = mInputStream.Read(buffer);
                    Java.Lang.String str = new Java.Lang.String(buffer, 0, bytes);
                    mSaveLastMessage(str.ToString());
                }
                catch (Java.Lang.Exception ex)
                {
                    Log.Debug("WifiSocketReader", "Error while reading");
                }
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            /**
             * 使用地图sdk前需先初始化BMapManager.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;
            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }
            SetContentView(Resource.Layout.activity_geometry);
            ICharSequence titleLable = new String("自定义绘制功能");
            Title = titleLable.ToString();

            //初始化地图
            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            mMapView.Controller.SetZoom(12.5f);
            mMapView.Controller.EnableClick(true);

            //UI初始化
            clearBtn = FindViewById<Button>(Resource.Id.button1);
            resetBtn = FindViewById<Button>(Resource.Id.button2);

            Android.Views.View.IOnClickListener clearListener = new ClearListenerImpl(this);
            Android.Views.View.IOnClickListener restListener = new RestListenerImpl(this);

            clearBtn.SetOnClickListener(clearListener);
            resetBtn.SetOnClickListener(restListener);

            //界面加载时添加绘制图层
            AddCustomElementsDemo();
        }
        MapView mMapView = null;	// 地图View
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            /**
             * 使用地图sdk前需先初始化BMapManager.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;
            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }
            SetContentView(Resource.Layout.activity_customroute);
            ICharSequence titleLable = new String("路线规划功能——自设路线示例");
            Title = titleLable.ToString();
            //初始化地图
            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            mMapView.Controller.EnableClick(true);
            mMapView.Controller.SetZoom(13);

            /** 演示自定义路线使用方法	
             *  在北京地图上画一个北斗七星
             *  想知道某个点的百度经纬度坐标请点击:http://api.map.baidu.com/lbsapi/getpoint/index.html	
             */
            GeoPoint p1 = new GeoPoint((int)(39.9411 * 1E6), (int)(116.3714 * 1E6));
            GeoPoint p2 = new GeoPoint((int)(39.9498 * 1E6), (int)(116.3785 * 1E6));
            GeoPoint p3 = new GeoPoint((int)(39.9436 * 1E6), (int)(116.4029 * 1E6));
            GeoPoint p4 = new GeoPoint((int)(39.9329 * 1E6), (int)(116.4035 * 1E6));
            GeoPoint p5 = new GeoPoint((int)(39.9218 * 1E6), (int)(116.4115 * 1E6));
            GeoPoint p6 = new GeoPoint((int)(39.9144 * 1E6), (int)(116.4230 * 1E6));
            GeoPoint p7 = new GeoPoint((int)(39.9126 * 1E6), (int)(116.4387 * 1E6));
            //起点坐标
            GeoPoint start = p1;
            //终点坐标
            GeoPoint stop = p7;
            //第一站,站点坐标为p3,经过p1,p2
            GeoPoint[] step1 = new GeoPoint[3];
            step1[0] = p1;
            step1[1] = p2;
            step1[2] = p3;
            //第二站,站点坐标为p5,经过p4
            GeoPoint[] step2 = new GeoPoint[2];
            step2[0] = p4;
            step2[1] = p5;
            //第三站,站点坐标为p7,经过p6
            GeoPoint[] step3 = new GeoPoint[2];
            step3[0] = p6;
            step3[1] = p7;
            //站点数据保存在一个二维数据中
            GeoPoint[][] routeData = new GeoPoint[3][];
            routeData[0] = step1;
            routeData[1] = step2;
            routeData[2] = step3;
            //用站点数据构建一个MKRoute
            MKRoute route = new MKRoute();
            route.CustomizeRoute(start, stop, routeData);
            //将包含站点信息的MKRoute添加到RouteOverlay中
            RouteOverlay routeOverlay = new RouteOverlay(this, mMapView);
            routeOverlay.SetData(route);
            //向地图添加构造好的RouteOverlay
            mMapView.Overlays.Add(routeOverlay);
            //执行刷新使生效
            mMapView.Refresh();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            /**
             * 使用地图sdk前需先初始化BMapManager.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;
            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }
            SetContentView(Resource.Layout.routeplan);
            ICharSequence titleLable = new String("路线规划功能");
            Title = titleLable.ToString();
            //初始化地图
            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            mMapView.SetBuiltInZoomControls(false);
            mMapView.Controller.SetZoom(12);
            mMapView.Controller.EnableClick(true);

            //初始化按键
            mBtnDrive = FindViewById<Button>(Resource.Id.drive);
            mBtnTransit = FindViewById<Button>(Resource.Id.transit);
            mBtnWalk = FindViewById<Button>(Resource.Id.walk);
            mBtnPre = FindViewById<Button>(Resource.Id.pre);
            mBtnNext = FindViewById<Button>(Resource.Id.next);
            mBtnCusRoute = FindViewById<Button>(Resource.Id.custombutton);
            mBtnCusIcon = FindViewById<Button>(Resource.Id.customicon);
            mBtnPre.Visibility = ViewStates.Invisible;
            mBtnNext.Visibility = ViewStates.Invisible;

            //按键点击事件
            Android.Views.View.IOnClickListener clickListener = new ClickListenerImpl(this);
            Android.Views.View.IOnClickListener nodeClickListener = new NodeClickListenerImpl(this);
            Android.Views.View.IOnClickListener customClickListener = new CustomClickListenerImpl(this);
            Android.Views.View.IOnClickListener changeRouteIconListener = new ChangeRouteIconListenerImpl(this);

            mBtnDrive.SetOnClickListener(clickListener);
            mBtnTransit.SetOnClickListener(clickListener);
            mBtnWalk.SetOnClickListener(clickListener);
            mBtnPre.SetOnClickListener(nodeClickListener);
            mBtnNext.SetOnClickListener(nodeClickListener);
            mBtnCusRoute.SetOnClickListener(customClickListener);
            mBtnCusIcon.SetOnClickListener(changeRouteIconListener);
            //创建 弹出泡泡图层
            CreatePaopao();

            //地图点击事件处理
            mMapView.RegMapTouchListner(new IMKMapTouchListenerImpl(this));
            // 初始化搜索模块,注册事件监听
            mSearch = new MKSearch();
            mSearch.Init(app.mBMapManager, new IMKSearchListenerImpl(this));
        }
Пример #7
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.activity_busline);
     ICharSequence titleLable = new String("������·��ѯ����");
     Title = titleLable.ToString();
     mBtnPre = FindViewById<Button>(Resource.Id.pre);
     mBtnNext = FindViewById<Button>(Resource.Id.next);
     mBtnPre.Visibility = ViewStates.Invisible;
     mBtnNext.Visibility = ViewStates.Invisible;
     mBaiduMap = (Android.Runtime.Extensions.JavaCast<SupportMapFragment>(SupportFragmentManager
             .FindFragmentById(Resource.Id.bmapView))).BaiduMap;
     mBaiduMap.SetOnMapClickListener(this);
     mSearch = PoiSearch.NewInstance();
     mSearch.SetOnGetPoiSearchResultListener(this);
     mBusLineSearch = BusLineSearch.NewInstance();
     mBusLineSearch.SetOnGetBusLineSearchResultListener(this);
     busLineIDList = new List<string>();
 }
Пример #8
0
            public override void HandleMessage(Message msg)
            {
                switch (msg.What)
                {
                case MESSAGE_STATE_CHANGE:
                    if (Debug)
                    {
                        Log.Info(TAG, "MESSAGE_STATE_CHANGE: " + msg.Arg1);
                    }
                    switch (msg.Arg1)
                    {
                    case BluetoothChatService.STATE_CONNECTED:
                        //bluetoothChat.title.SetText (Resource.String.title_connected_to);
                        //bluetoothChat.title.Append (bluetoothChat.connectedDeviceName);
                        Log.Info(TAG, "MESSAGE_STATE_CHANGE: STATE_CONNECTED");
                        bluetoothChat.conversationArrayAdapter.Clear();
                        break;

                    case BluetoothChatService.STATE_CONNECTING:
                        //bluetoothChat.title.SetText (Resource.String.title_connecting);
                        Log.Info(TAG, "MESSAGE_STATE_CHANGE: STATE_CONNECTING");
                        break;

                    case BluetoothChatService.STATE_LISTEN:
                    case BluetoothChatService.STATE_NONE:
                        //bluetoothChat.title.SetText (Resource.String.title_not_connected);
                        Log.Info(TAG, "MESSAGE_STATE_CHANGE: STATE_LISTEN/None");
                        break;
                    }
                    break;

                case MESSAGE_WRITE:
                    byte[] writeBuf = (byte[])msg.Obj;
                    // construct a string from the buffer
                    var writeMessage = new Java.Lang.String(writeBuf);
                    bluetoothChat.conversationArrayAdapter.Add("Me: " + writeMessage);
                    break;

                case MESSAGE_READ:
                    byte[] readBuf = (byte[])msg.Obj;
                    // construct a string from the valid bytes in the buffer
                    var readMessage = new Java.Lang.String(readBuf, 0, msg.Arg1);
                    bluetoothChat.conversationArrayAdapter.Add(bluetoothChat.connectedDeviceName + ":  " + readMessage);
                    Console.WriteLine("MESSAGE_READ:{0}", readMessage.ToString());
                    //AccountStorage.SetAccount (bluetoothChat, readMessage.ToString ());
                    //var account = (TextView)bluetoothChat.FindViewById (Resource.Id.card_account_field);
                    //string s = AccountStorage.GetAccount (bluetoothChat);
                    //account.Text = s;
                    AccountStorage.SetAccount(bluetoothChat, readMessage.ToString());
                    var fm = bluetoothChat.FragmentManager;
                    FragmentTransaction   transaction = fm.BeginTransaction();
                    CardEmulationFragment fragment    = new CardEmulationFragment();
                    transaction.Replace(Resource.Id.sample_content_fragment, fragment);
                    transaction.Commit();
                    //************send result to real reader**************
                    //var sintent = new Intent("CE2.cardservice.sendApdu");
                    //sintent.PutExtra("_apdu", s);
                    //bluetoothChat.SendBroadcast(sintent);


                    //cs.SendResponseApdu (Encoding.UTF8.GetBytes(s));
                    //************send result to real reader**************



                    //bluetoothChat.OnAccountRecieved (s);
                    //account.AddTextChangedListener(new CE2.CardEmulationFragment.AccountUpdater(bluetoothChat));
                    //EditText mAccountField = bluetoothChat.FindViewById<EditText> (Resource.Id.card_account_field);
                    //mAccountField.Text = (string) readMessage;
                    break;

                case MESSAGE_DEVICE_NAME:
                    // save the connected device's name
                    bluetoothChat.connectedDeviceName = msg.Data.GetString(DEVICE_NAME);
                    Toast.MakeText(Application.Context, "Connected to " + bluetoothChat.connectedDeviceName, ToastLength.Short).Show();
                    break;

                case MESSAGE_TOAST:
                    Toast.MakeText(Application.Context, msg.Data.GetString(TOAST), ToastLength.Short).Show();
                    break;
                }
            }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            /**
             * 使用地图sdk前需先初始化BMapManager.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;

            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }

            SetContentView(Resource.Layout.buslinesearch);

            ICharSequence titleLable = new String("公交线路查询功能");

            Title = titleLable.ToString();

            //地图初始化
            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            mMapView.Controller.EnableClick(true);
            mMapView.Controller.SetZoom(12);
            busLineIDList = new List<string>();

            //创建 弹出泡泡图层
            CreatePaopao();

            // 设定搜索按钮的响应
            mBtnSearch = FindViewById<Button>(Resource.Id.search);
            mBtnNextLine = FindViewById<Button>(Resource.Id.nextline);
            mBtnPre = FindViewById<Button>(Resource.Id.pre);
            mBtnNext = FindViewById<Button>(Resource.Id.next);
            mBtnPre.Visibility = ViewStates.Invisible;
            mBtnNext.Visibility = ViewStates.Invisible;

            //地图点击事件处理
            mMapView.RegMapTouchListner(new MKMapTouchListenerImpl(this));

            // 初始化搜索模块,注册事件监听
            mSearch = new MKSearch();
            mSearch.Init(app.mBMapManager, new MKSearchListenerImpl(this));

            Android.Views.View.IOnClickListener clickListener = new ClickListenerImpl(this);
            Android.Views.View.IOnClickListener nextLineClickListener = new NextLineClickListener(this);
            Android.Views.View.IOnClickListener nodeClickListener = new NodeClickListener(this);

            mBtnSearch.SetOnClickListener(clickListener);
            mBtnNextLine.SetOnClickListener(nextLineClickListener);
            mBtnPre.SetOnClickListener(nodeClickListener);
            mBtnNext.SetOnClickListener(nodeClickListener);

            //mBtnSearch.Click += (sender, e) =>
            //{
            //    SearchButtonProcess(mBtnSearch);
            //};


            //mBtnNextLine.Click += (sender, e) =>
            //{
            //    SearchNextBusline();
            //};

            //mBtnPre.Click += (sender, e) =>
            //{
            //    NodeClick(mBtnPre);
            //};

            //mBtnNext.Click += (sender, e) =>
            //{
            //    NodeClick(mBtnNext);
            //};
        }
Пример #10
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.activity_routeplan);
     ICharSequence titleLable = new String("·�߹滮����");
     Title = titleLable.ToString();
     //��ʼ����ͼ
     mMapView = FindViewById<MapView>(Resource.Id.map);
     mBaidumap = mMapView.Map;
     mBtnPre = FindViewById<Button>(Resource.Id.pre);
     mBtnNext = FindViewById<Button>(Resource.Id.next);
     mBtnPre.Visibility = ViewStates.Invisible;
     mBtnNext.Visibility = ViewStates.Invisible;
     //��ͼ����¼�����
     mBaidumap.SetOnMapClickListener(this);
     // ��ʼ������ģ�飬ע���¼�����
     mSearch = RoutePlanSearch.NewInstance();
     mSearch.SetOnGetRoutePlanResultListener(this);
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            /**
             * 使用地图sdk前需先初始化BMapManager.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;
            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }
            SetContentView(Resource.Layout.geocoder);
            ICharSequence titleLable = new String("地理编码功能");
            Title = titleLable.ToString();

            //地图初始化
            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            mMapView.Controller.EnableClick(true);
            mMapView.Controller.SetZoom(12);

            // 初始化搜索模块,注册事件监听
            mSearch = new MKSearch();
            mSearch.Init(app.mBMapManager, new IMKSearchListenerImpl(this));

            // 设定地理编码及反地理编码按钮的响应
            mBtnReverseGeoCode = FindViewById<Button>(Resource.Id.reversegeocode);
            mBtnGeoCode = FindViewById<Button>(Resource.Id.geocode);

            Android.Views.View.IOnClickListener clickListener = new ClickListenerImpl(this);

            mBtnReverseGeoCode.SetOnClickListener(clickListener);
            mBtnGeoCode.SetOnClickListener(clickListener);
        }
Пример #12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_poisearch);
            // ��ʼ������ģ�飬ע�������¼�����
            mPoiSearch = PoiSearch.NewInstance();
            mPoiSearch.SetOnGetPoiSearchResultListener(this);
            mSuggestionSearch = SuggestionSearch.NewInstance();
            mSuggestionSearch.SetOnGetSuggestionResultListener(this);
            keyWorldsView = FindViewById<AutoCompleteTextView>(Resource.Id.searchkey);
            sugAdapter = new ArrayAdapter<string>(this,
                    Android.Resource.Layout.SimpleDropDownItem1Line);
            keyWorldsView.Adapter = sugAdapter;
            mBaiduMap = (Android.Runtime.Extensions.JavaCast<SupportMapFragment>(SupportFragmentManager
                    .FindFragmentById(Resource.Id.map))).BaiduMap;

            /**
             * ������ؼ��ֱ仯ʱ����̬���½����б�
             */
            keyWorldsView.AfterTextChanged += (sender, e) => { };
            keyWorldsView.BeforeTextChanged += (sender, e) => { };
            keyWorldsView.TextChanged += (sender, e) =>
            {
                ICharSequence cs = new String(e.Text.ToString());
                if (cs.Length() <= 0)
                {
                    return;
                }
                string city = (FindViewById<EditText>(Resource.Id.city)).Text;
                /**
                 * ʹ�ý������������ȡ�����б�������onSuggestionResult()�и���
                 */
                mSuggestionSearch
                        .RequestSuggestion((new SuggestionSearchOption())
                                .Keyword(cs.ToString()).City(city));
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            /**
             * 使用地图sdk前需先初始化BMapManager.
             * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建,
             * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁
             */
            DemoApplication app = (DemoApplication)this.Application;
            if (app.mBMapManager == null)
            {
                app.mBMapManager = new BMapManager(ApplicationContext);
                /**
                 * 如果BMapManager没有初始化则初始化BMapManager
                 */
                app.mBMapManager.Init(new DemoApplication.MyGeneralListener());
            }
            SetContentView(Resource.Layout.activity_locationoverlay);
            ICharSequence titleLable = new String("定位功能");
            Title = titleLable.ToString();

            myListener = new MyLocationListenner(this);

            requestLocButton = FindViewById<Button>(Resource.Id.button1);
            mCurBtnType = E_BUTTON_TYPE.LOC;
            Android.Views.View.IOnClickListener btnClickListener = new BtnClickListenerImpl(this);

            requestLocButton.SetOnClickListener(btnClickListener);

            RadioGroup group = this.FindViewById<RadioGroup>(Resource.Id.radioGroup);
            radioButtonListener = new RadioButtonListenerImpl(this);
            group.SetOnCheckedChangeListener(radioButtonListener);

            //地图初始化
            mMapView = FindViewById<MyLocationMapView>(Resource.Id.bmapView);
            mMapController = mMapView.Controller;
            mMapView.Controller.SetZoom(14);
            mMapView.Controller.EnableClick(true);
            mMapView.SetBuiltInZoomControls(true);
            //创建 弹出泡泡图层
            CreatePaopao();

            //定位初始化
            mLocClient = new LocationClient(this);
            locData = new LocationData();
            mLocClient.RegisterLocationListener(myListener);
            LocationClientOption option = new LocationClientOption();
            option.OpenGps = true;//打开gps
            option.CoorType = "bd09ll";     //设置坐标类型
            option.ScanSpan = 1000;
            mLocClient.LocOption = option;
            mLocClient.Start();

            //定位图层初始化
            myLocationOverlay = new LocationOverlay(this, mMapView);
            //设置定位数据
            myLocationOverlay.SetData(locData);
            //添加定位图层
            mMapView.Overlays.Add(myLocationOverlay);
            myLocationOverlay.EnableCompass();
            //修改定位数据后刷新图层生效
            mMapView.Refresh();

        }
Пример #14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_geocoder);
            ICharSequence titleLable = new String("������빦��");
            Title = titleLable.ToString();

            // ��ͼ��ʼ��
            mMapView = FindViewById<MapView>(Resource.Id.bmapView);
            mBaiduMap = mMapView.Map;

            // ��ʼ������ģ�飬ע���¼�����
            mSearch = GeoCoder.NewInstance();
            mSearch.SetOnGetGeoCodeResultListener(this);
        }