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


C# Context.StartService方法代码示例

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


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

示例1: PayPalManager

		public PayPalManager (Context context, PayPal.Forms.Abstractions.PayPalConfiguration xfconfig)
		{
			Context = context;

			switch (xfconfig.Environment) {
			case PayPal.Forms.Abstractions.Enum.Environment.NoNetwork:
				CONFIG_ENVIRONMENT = PayPalConfiguration.EnvironmentNoNetwork;
				break;
			case PayPal.Forms.Abstractions.Enum.Environment.Production:
				CONFIG_ENVIRONMENT = PayPalConfiguration.EnvironmentProduction;
				break;
			case PayPal.Forms.Abstractions.Enum.Environment.Sandbox:
				CONFIG_ENVIRONMENT = PayPalConfiguration.EnvironmentSandbox;
				break;
			}

			CONFIG_CLIENT_ID = xfconfig.PayPalKey;

			config = new PayPalConfiguration ()
				.Environment (CONFIG_ENVIRONMENT)
				.ClientId (CONFIG_CLIENT_ID)
				.AcceptCreditCards (xfconfig.AcceptCreditCards)
			// The following are only used in PayPalFuturePaymentActivity.
				.MerchantName (xfconfig.MerchantName)
				.MerchantPrivacyPolicyUri (global::Android.Net.Uri.Parse (xfconfig.MerchantPrivacyPolicyUri))
				.MerchantUserAgreementUri (global::Android.Net.Uri.Parse (xfconfig.MerchantUserAgreementUri));

			Intent intent = new Intent (Context, typeof(PayPalService));
			intent.PutExtra (PayPalService.ExtraPaypalConfiguration, config);
			Context.StartService (intent);
		}
开发者ID:15mgm15,项目名称:PayPal.Forms,代码行数:31,代码来源:PayPalManager.cs

示例2: OnReceive

		public override void OnReceive (Context context, Intent intent)
		{
			if (WiFiHelper.IsWiFiAvailable()) {
				//connected to wifi let's do sync
				Intent DbServiceIntent = new Intent ("com.ETCTimeApp.DbSyncService");
				new Thread (() => context.StartService (DbServiceIntent)).Start ();
			}
		}
开发者ID:pablomferrari,项目名称:ETCTimeApp,代码行数:8,代码来源:ConnectivityReceiverService.cs

示例3: OnReceive

        public override void OnReceive(Context context, Intent intent)
        {
            if (intent.Action != AudioManager.ActionAudioBecomingNoisy)
                return;

            //signal the service to stop!
            var stopIntent = new Intent(StreamingBackgroundService.ActionStop);
            context.StartService(stopIntent);
        }
开发者ID:helmsb,项目名称:AndroidStreamingAudio,代码行数:9,代码来源:MusicBroadcastReceiver.cs

示例4: OnReceive

 public override void OnReceive(Context context, Intent intent)
 {
     if (intent.Action == Intent.ActionBootCompleted)
     {
         Intent serviceIntent = new Intent(context, typeof(AndroidSensusService));
         serviceIntent.PutExtra(AndroidSensusServiceHelper.MAIN_ACTIVITY_WILL_BE_SET, false);
         context.StartService(serviceIntent);
     }
 }
开发者ID:trishalaneeraj,项目名称:sensus,代码行数:9,代码来源:AndroidSensusServiceBootStarter.cs

示例5: OnReceive

		public override void OnReceive (Context context, Intent intent)
		{
			Log.Debug ("PhoneBootedBroadcastReceiver", "ActionBootCompleted received");

			var activeAlarms = new DBManager ().GetAll ().Where (alarm => alarm.Enabled).ToList ();

			if (activeAlarms != null && activeAlarms.Count > 0) {
				context.StartService (new Intent (context, typeof(RestoreAfterRebootService)));
			}
		}
开发者ID:foxanna,项目名称:SimpleLocationAlarm,代码行数:10,代码来源:RestoreAfterRebootService.cs

示例6: Register

        /// <summary>
        /// Register's the Device for C2DM Messages
        /// </summary>
        /// <param name="context">Context</param>
        /// <param name="senderIdEmail">Email address whitelisted as the Sender ID for your App</param>
        public static void Register(Context context, string senderIdEmail)
        {
            //Create our intent, with a pending intent to our app's broadcast
            Intent registrationIntent = new Intent(GOOGLE_ACTION_C2DM_INTENT_REGISTER);
            registrationIntent.PutExtra("app", PendingIntent.GetBroadcast(context, 0, new Intent(), 0));
            registrationIntent.PutExtra("sender", senderIdEmail);

            //Start intent
            context.StartService(registrationIntent);
        }
开发者ID:nuttapol,项目名称:PushSharp,代码行数:15,代码来源:C2dmClient.cs

示例7: OnReceive

		public override void OnReceive(Context context, Intent intent)
		{
			Toast.MakeText(context,"Repeating alarm received.", ToastLength.Short).Show();

			WakeReminderIntentService.acquireStaticLock(context);

			Intent i = new Intent(context, typeof(ReminderService));

			context.StartService(i);
		}
开发者ID:jfreakz,项目名称:AlarmManager_Demo,代码行数:10,代码来源:RepeatingAlarm.cs

示例8: OnReceive

        public override void OnReceive(Context context, Intent intent)
        {
            if (intent.Action != AudioManager.ActionAudioBecomingNoisy)
                return;

            //signal the service to pause!
            var pauseIntent = new Intent(MediaServiceBase.ActionPause);
            pauseIntent.SetPackage(context.PackageName);
            context.StartService(pauseIntent);
        }
开发者ID:martijn00,项目名称:XamarinMediaManager,代码行数:10,代码来源:AudioPlayerBroadcastReceiver.cs

示例9: StartService

		private void StartService(Context context)
		{
			try {
				Intent serviceStartIntent = new Intent (context, typeof(com.tarabel.bluetoothnotify.BluetoothLowEnergySearchService));
				serviceStartIntent.AddFlags (ActivityFlags.NewTask);
				context.StartService (serviceStartIntent);
			} catch (Exception ex) {
				Log.Info ("com.tarabel.bluetoothnotify", "error while starting service " + ex.ToString());
			}
		}
开发者ID:valtarakanov,项目名称:BluetoothNotify,代码行数:10,代码来源:IntentReceiver.cs

示例10: OnReceive

        public override void OnReceive (Context context, Intent intent)
        {
            if (intent.Action != AudioManager.ActionAudioBecomingNoisy)
            {
                return;
            }

            //signal the service to stop!
            var stopIntent = new Intent (PlayerService.ACTION_STOP);
            context.StartService (stopIntent);
        }
开发者ID:puncsky,项目名称:DrunkAudible,代码行数:11,代码来源:MusicBroadcastReceiver.cs

示例11: OnUpdate

        public override void OnUpdate (Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
        {
            // Request widget update.
            var serviceIntent = new Intent (context, typeof (InitWidgetService));
            context.StartService (serviceIntent);

            // Setup widget UI.
            SetupWidget (context);

            base.OnUpdate (context, appWidgetManager, appWidgetIds);
        }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:11,代码来源:WidgetProvider.cs

示例12: OnReceive

        //   private BackgroundService bs;
        //  private Context cont;
        /// <summary>
        /// Invoked by OS when device is rebooted Permisssion is being given
        /// in manifest . When device rebooted OS broadcast it to all 
        /// applications and receiver with this permisssion willbe invoked 
        /// </summary>
        /// <param name="context"></param>
        /// <param name="intent"></param>
        public override void OnReceive(Context context, Intent intent)
        {
            try
            {
                Toast.MakeText(context, "Broadcast Receive: ", ToastLength.Long).Show();
                context.StartService(new Intent(context, typeof(BackgroundService)));
            }
            catch (Exception ex)
            {

            }
        }
开发者ID:mdhammad313,项目名称:GPS-Tracker,代码行数:21,代码来源:BroadCastReceiver.cs

示例13: RunIntentInService

        static void RunIntentInService(Context context, Intent intent)
        {
            lock (LOCK)
            {
                if (wakeLock == null)
                {
                    var pm = PowerManager.FromContext(context);
                    wakeLock = pm.NewWakeLock(WakeLockFlags.Partial, "Woken lock");
                }
            }

            wakeLock.Acquire();
            intent.SetClass(context, typeof(GPSDroidService));
            context.StartService(intent);
        }
开发者ID:nodoid,项目名称:GPSPush,代码行数:15,代码来源:GPSDroidService.cs

示例14: PayPalManager

		public PayPalManager (Context context)
		{
			Context = context;
			config = new PayPalConfiguration ()
				.Environment (CONFIG_ENVIRONMENT)
				.ClientId (CONFIG_CLIENT_ID)
			// The following are only used in PayPalFuturePaymentActivity.
				.MerchantName ("Example Merchant")
				.MerchantPrivacyPolicyUri (Android.Net.Uri.Parse ("https://www.example.com/privacy"))
				.MerchantUserAgreementUri (Android.Net.Uri.Parse ("https://www.example.com/legal"));

			Intent intent = new Intent (Context, typeof(PayPalService));
			intent.PutExtra (PayPalService.ExtraPaypalConfiguration, config);
			Context.StartService (intent);
		}
开发者ID:15mgm15,项目名称:PayPal.Forms,代码行数:15,代码来源:PayPalManager.cs

示例15: RunIntentInService

            public static void RunIntentInService(Context context, Intent intent)
            {
                lock (LOCK)
                {
                    if (sWakeLock == null)
                    {
                        // This is called from BroadcastReceiver, there is no init.
                        var pm = Android.OS.PowerManager.FromContext(context);
                        sWakeLock = pm.NewWakeLock(Android.OS.WakeLockFlags.Partial, "My WakeLock Tag");
                    }
                }

                sWakeLock.Acquire();
                intent.SetClass(context, typeof(PNIntentService));
                context.StartService(intent);
            }
开发者ID:knezik,项目名称:gina-api-examples2,代码行数:16,代码来源:DroidPushNotificationService.cs


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