当前位置: 首页>>代码示例>>C#>>正文


C# Activity.GetSystemService方法代码示例

本文整理汇总了C#中Android.App.Activity.GetSystemService方法的典型用法代码示例。如果您正苦于以下问题:C# Activity.GetSystemService方法的具体用法?C# Activity.GetSystemService怎么用?C# Activity.GetSystemService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.App.Activity的用法示例。


在下文中一共展示了Activity.GetSystemService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        public static void Initialize(Activity activity)
        {
            audioManager = (AudioManager)activity.GetSystemService(Context.AudioService);

            mediaPlayer = MediaPlayer.Create(activity.ApplicationContext, Resource.Raw.Message);

            notificationManager = (NotificationManager)activity.GetSystemService(Context.NotificationService);
            vibrator = (Vibrator)activity.GetSystemService(Context.VibratorService);

            //context = activity.ApplicationContext;
            context = activity;

            isAlertsEnabled = true;
            isProgressEnabled = true;
        }
开发者ID:FlyingPie,项目名称:SteamDroid,代码行数:15,代码来源:SteamAlerts.cs

示例2: SelectPicPopWindow

		public SelectPicPopWindow (Activity _activity,View.IOnClickListener listener)
		{
			activity = _activity;
			LayoutInflater inflater = (LayoutInflater) activity.GetSystemService (Context.LayoutInflaterService);
			contentView = inflater.Inflate(Resource.Layout.headImgSelectorPop, null);  
			ContentView = contentView;
			btn_take_photo = contentView.FindViewById<Button> (Resource.Id.btn_take_photo);
			btn_pick_photo = contentView.FindViewById<Button> (Resource.Id.btn_pick_photo);
			btn_cancel = contentView.FindViewById<Button> (Resource.Id.btn_pic_cancel);
			//设置宽度、高度
			Width = Android.Views.ViewGroup.LayoutParams.MatchParent;
			Height = Android.Views.ViewGroup.LayoutParams.WrapContent;
			Focusable = true;
			OutsideTouchable = true;
			SetBackgroundDrawable (new ColorDrawable());
			AnimationStyle = Resource.Style.Animationbottom;

			//设置按钮绑定
			btn_take_photo.SetOnClickListener (listener);
			btn_pick_photo.SetOnClickListener (listener);

			//取消
			btn_cancel.Click += (sender, e) => 
			{
				Dismiss();

			};

			DismissEvent+= (sender, e) => 
			{
				BackgroundAlpha(1f);
			};

		}
开发者ID:lq-ever,项目名称:CommunityCenter,代码行数:34,代码来源:SelectPicPopWindow.cs

示例3: ProtoPadServer

        private ProtoPadServer(View window, int? overrideListeningPort = null, string overrideBroadcastedAppName = null)
        {
            _window = window;
            _contextActivity = window.Context as Activity;

            _httpServer = new SimpleHttpServer(responseBytes =>
            {
                var response = "{}";
                var remoteCommandDoneEvent = new AutoResetEvent(false);
                _contextActivity.RunOnUiThread(() => Response(responseBytes, remoteCommandDoneEvent, ref response));
                remoteCommandDoneEvent.WaitOne();
                return response;
            });

            IPAddress broadCastAddress;
            using (var wifi = _contextActivity.GetSystemService(Android.Content.Context.WifiService) as WifiManager)
            {
                _mcLock = wifi.CreateMulticastLock("ProtoPadLock");
                _mcLock.Acquire();
                broadCastAddress = GetBroadcastAddress(wifi);
            }

            BroadcastedAppName = overrideBroadcastedAppName ?? String.Format("ProtoPad Service on ANDROID Device {0}", Android.OS.Build.Model);
            ListeningPort = overrideListeningPort ?? 8080;
            LocalIPAddress = Helpers.GetCurrentIPAddress();

            _udpServer = new UdpDiscoveryServer(BroadcastedAppName, String.Format("http://{0}:{1}/", LocalIPAddress, ListeningPort), broadCastAddress);
        }
开发者ID:slodge,项目名称:ProtoPad,代码行数:28,代码来源:ProtoPadServer.cs

示例4: isNetworkConnected

        /// <summary>
        /// 网络是否联通
        /// </summary>
        public static bool isNetworkConnected(Activity active)
        {
            bool net = false;

            ConnectivityManager connManager = (ConnectivityManager)active.GetSystemService(Context.ConnectivityService);

            // connManager.ActiveNetworkInfo ==null   手机无法连接网络
            if (connManager.ActiveNetworkInfo != null)
            {
                //获得 wifi 连接管理
                NetworkInfo networkInfo = connManager.GetNetworkInfo(ConnectivityType.Wifi);
                //获得 GPRS 连接管理
                NetworkInfo gp = connManager.GetNetworkInfo(ConnectivityType.Mobile);
                if (networkInfo != null && networkInfo.IsAvailable != false)
                {
                    //Toast.MakeText(active, "WIFI打开!", ToastLength.Long).Show();
                    net = true;
                }
                // gp.IsConnected==false 有信号无网络
                if (gp != null && gp.IsConnected != false)
                {
                    //Toast.MakeText(active, "有信号gprs打开!", ToastLength.Long).Show();
                    net = true;
                }
            }
            else
            {
                //Toast.MakeText(active, "无法连接到互联网!", ToastLength.Long).Show();
            }
            return net;
        }
开发者ID:eatage,项目名称:AppTest.bak,代码行数:34,代码来源:SysVisitor.cs

示例5: UnbindPopWindow

		public UnbindPopWindow (Activity _activity,GuardianInfoListItem item)
		{
			activity = _activity;
			LayoutInflater inflater = (LayoutInflater) activity.GetSystemService (Context.LayoutInflaterService);
			contentView = inflater.Inflate(Resource.Layout.customunbinddialogLayout, null);  

			ContentView = contentView;
			Width = 900;
			Height = 450;
			Focusable = true;
			OutsideTouchable = true;
			//Update ();
			SetBackgroundDrawable (new ColorDrawable());
			AnimationStyle = Resource.Style.AnimationPreview;
			var btn_confirm = contentView.FindViewById<Button> (Resource.Id.btn_confirm);
			btn_confirm.Click += (sender, e) => 
			{
				Dismiss();

				if(UnBindEventHandler != null)
					UnBindEventHandler(item);
		
			};
			var btn_cancel = contentView.FindViewById<Button> (Resource.Id.btn_cancel);
			btn_cancel.Click += (sender, e) => 
			{
				Dismiss();
			};

			DismissEvent += (sender, e) => 
			{
				BackgroundAlpha(1f);

			};
		}
开发者ID:lq-ever,项目名称:CommunityCenter,代码行数:35,代码来源:UnbindPopWindow.cs

示例6: Measure

		public static void Measure (Activity context)
		{
		Resources resources = context.Resources;

			ScreenWidth = resources.DisplayMetrics.WidthPixels;
			RealSize = new Android.Graphics.Point ();
			context.Window.WindowManager.DefaultDisplay.GetRealSize (RealSize);

			ScreenHeight = resources.DisplayMetrics.HeightPixels;

			int navBarId = resources.GetIdentifier("navigation_bar_height", "dimen", "android");
			int statusbarId = resources.GetIdentifier("status_bar_height", "dimen", "android");

			NavigationBarHeight = resources.GetDimensionPixelSize(navBarId);

			StatusBarHeight = resources.GetDimensionPixelSize(statusbarId);

			TrueScreenHeight = ScreenHeight - NavigationBarHeight - StatusBarHeight;

			Density = resources.DisplayMetrics.Density;

			// memory
			const string ActivityService = global::Android.Content.Context.ActivityService;
			ActivityManager manager = (ActivityManager)context.GetSystemService(ActivityService);
			ActivityManager.MemoryInfo outInfo = new ActivityManager.MemoryInfo();
			manager.GetMemoryInfo(outInfo);
			Memory = outInfo.TotalMem;

			RuntimeMemory = Java.Lang.Runtime.GetRuntime().MaxMemory();

		}
开发者ID:Gerhic,项目名称:Need2Park,代码行数:31,代码来源:DeviceInfo.cs

示例7: HideKeyboard

		public static void HideKeyboard(Activity activity, EditText field)
		{
			if (activity != null && field != null)
			{
				InputMethodManager imm = (InputMethodManager)activity.GetSystemService(Context.InputMethodService);
				imm.HideSoftInputFromWindow(field.WindowToken, 0);
			}
		}
开发者ID:natevarghese,项目名称:XamarinTen,代码行数:8,代码来源:ViewUtils.cs

示例8: Locator

 public Locator(Activity ctx)
 {
     this.ctx = ctx;
     locationManager = (LocationManager)ctx.GetSystemService (Context.LocationService);
     locationManager.RequestLocationUpdates (LocationManager.PassiveProvider, 5 * 60 * 1000, 2, this);
     if (Geocoder.IsPresent)
         geocoder = new Geocoder (ctx);
 }
开发者ID:Andrea,项目名称:FriendTab,代码行数:8,代码来源:Locator.cs

示例9: AndroidDevice

        public AndroidDevice(Activity activity, ConnectionType connectionType, string connectionString)
            : base(connectionType, connectionString, new JsonProvider())
        {
            // Setup the WebView/Browser
            _activity = activity;
            Browser = new AndroidBrowser(new WebView(activity));
            _activity.SetContentView(WebView);

            // Populate device info
            Wifi = (WifiManager)activity.GetSystemService(Context.WifiService);
            DeviceInfo = new DeviceInfo();
            DeviceInfo.MobileOs = MobileOs.Android;
            DeviceInfo.DeviceModel = Build.Model;
            DeviceInfo.OsVersion = Build.VERSION.Release;
            DeviceInfo.IP = IP;
            var tm = (TelephonyManager)activity.GetSystemService(Context.TelephonyService);
            DeviceInfo.UniqueId = tm.DeviceId;
        }
开发者ID:vistaprint,项目名称:automobile,代码行数:18,代码来源:AndroidDevice.cs

示例10: MEID

 /// <summary>
 /// 获取手机序列号
 /// </summary>
 /// <param name="active"></param>
 /// <returns></returns>
 public static String MEID(Activity active)
 {
     if (!string.IsNullOrEmpty(_MEID))
     {
         return _MEID;
     }
     Android.Telephony.TelephonyManager tm = (Android.Telephony.TelephonyManager)active.GetSystemService(Context.TelephonyService); ;
     _MEID = tm.DeviceId;
     return tm.DeviceId;
 }
开发者ID:eatage,项目名称:AppTest.bak,代码行数:15,代码来源:SysVisitor.cs

示例11: Show

 public static void Show(Activity activity)
 {
     if (activity != null)
     {
         InputMethodManager inputManager = (InputMethodManager)activity.GetSystemService(Context.InputMethodService);
         var currentFocus = activity.CurrentFocus;
         if(currentFocus!=null)
             inputManager.ShowSoftInput(currentFocus, ShowFlags.Implicit);
     }
 }
开发者ID:gromozeka07b9,项目名称:TranslateHelperV2,代码行数:10,代码来源:TogglesSoftKeyboard.cs

示例12: Hide

 public static void Hide(Activity activity)
 {
     if(activity!=null)
     {
         InputMethodManager inputManager = (InputMethodManager)activity.GetSystemService(Context.InputMethodService);
         var currentFocus = activity.CurrentFocus;
         if(currentFocus!=null)
             inputManager.HideSoftInputFromWindow(currentFocus.WindowToken, HideSoftInputFlags.None);
     }
 }
开发者ID:gromozeka07b9,项目名称:TranslateHelperV2,代码行数:10,代码来源:TogglesSoftKeyboard.cs

示例13: CreateView

        public static View CreateView (Activity context, int iconResourceStringId)
        {
            var inflater = (LayoutInflater) context.GetSystemService (Context.LayoutInflaterService);
            var tabView = inflater.Inflate (Resource.Layout.Tab, null, false);

            var tabIcon = tabView.FindViewById<TextView> (Resource.Id.TabIcon);
            tabIcon.Text = context.ApplicationContext.GetString(iconResourceStringId);
            IconProvider.ConvertTextViewToIcon (context.Assets, tabIcon);

            return tabView;
        }
开发者ID:puncsky,项目名称:DrunkAudible,代码行数:11,代码来源:IconProvider.cs

示例14: DismissKeyboardInternal

        private static void DismissKeyboardInternal(Activity activity)
        {
            if (activity == null)
                return;

            var inputManager = activity.GetSystemService(Context.InputMethodService) as InputMethodManager;

            if (inputManager == null || activity.CurrentFocus == null)
                return;

            inputManager.HideSoftInputFromWindow(activity.CurrentFocus.WindowToken, HideSoftInputFlags.NotAlways);
        }
开发者ID:ehill8624,项目名称:ValkreRender,代码行数:12,代码来源:Utilities.cs

示例15: IsOnline

		public static bool IsOnline (Activity context,int close)
		{
			//for checking internet is on 
			ConnectivityManager connectivityManager = (ConnectivityManager)context.GetSystemService("connectivity");
			var activeConnection = connectivityManager.ActiveNetworkInfo;

			//internet is on
			if ((activeConnection != null) && activeConnection.IsConnected) {

				Console.Error.WriteLine ("1st level checking");
				var client1 = new TcpClient();
				try{
					if (!client1.ConnectAsync (host1, port).Wait (timeout)) {
						client1.Close ();
					} 
					return true;
				}
				catch {
					try{
						Console.Error.WriteLine ("2nd level checking");
						var client2 = new TcpClient();
						if (!client2.ConnectAsync (host2, port).Wait (timeout)) {
							client2.Close ();
						}
						return true;
					}
					catch {
						try{
							Console.Error.WriteLine ("3rd level checking");
							var client3 = new TcpClient();
							if (!client3.ConnectAsync (host3, port).Wait (timeout)) {
								dialogErrorInternet (context, errorInternet, close);
								client3.Close ();
								return false;
							}
							return true;
						}
						catch {
							Console.Error.WriteLine ("internet off");
							dialogErrorInternet (context, errorInternet, close);
							return false;
						}
					}
				}

			} else {
				Console.Error.WriteLine ("internet off");
				dialogErrorInternet (context, errorInternet, close);
				return false;

			}

		}
开发者ID:kktanpiya,项目名称:pyongPyaa048,代码行数:53,代码来源:Commonlib.cs


注:本文中的Android.App.Activity.GetSystemService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。