本文整理汇总了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);
}
示例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 ();
}
}
示例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);
}
示例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);
}
}
示例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)));
}
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
}
示例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);
}
示例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);
}
示例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)
{
}
}
示例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);
}
示例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);
}
示例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);
}