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


C# Context.getSystemService方法代码示例

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


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

示例1: CustomVideoCapturer

		public CustomVideoCapturer(Context context)
		{

			// Initialize front camera by default
			this.mCameraIndex = FrontCameraIndex;

			// Get current display to query UI orientation
			WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
			mCurrentDisplay = windowManager.DefaultDisplay;

		}
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:11,代码来源:CustomVideoCapturer.cs

示例2: showDirectIoDialog

//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: static void showDirectIoDialog(android.app.AlertDialog dialog, final android.content.Context context)
		internal static void showDirectIoDialog(AlertDialog dialog, Context context)
		{
			if (dialog == null)
			{
				LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.view.View view = inflater.inflate(R.layout.dialog_direct_io, null);
				View view = inflater.inflate(R.layout.dialog_direct_io, null);

				dialog = (new AlertDialog.Builder(context)).setView(view).setTitle("Direct IO").setPositiveButton("OK", new OnClickListenerAnonymousInnerClassHelper20(dialog, context, view))
					   .setNegativeButton("Cancel", new OnClickListenerAnonymousInnerClassHelper21(dialog))
					   .create();
			}
			dialog.show();
		}
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:17,代码来源:DialogManager.cs

示例3: CityAdapter

		public CityAdapter(Context context)
		{
			inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		}
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:4,代码来源:CityAdapter.cs

示例4: showAutoCutterDialog

		internal static void showAutoCutterDialog(AlertDialog dialog, Context context)
		{
			if (dialog == null)
			{
				LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				View view = inflater.inflate(R.layout.dialog_set_auto_cutter, null);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.widget.EditText editText = (android.widget.EditText) view.findViewById(R.id.editText1);
				EditText editText = (EditText) view.findViewById(R.id.editText1);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.widget.RadioGroup radioGroup = (android.widget.RadioGroup) view.findViewById(R.id.radioGroup1);
				RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.radioGroup1);
				radioGroup.OnCheckedChangeListener = new OnCheckedChangeListenerAnonymousInnerClassHelper2(editText);

				dialog = (new AlertDialog.Builder(context)).setTitle([email protected]_action).setView(view).setPositiveButton("OK", new OnClickListenerAnonymousInnerClassHelper33(dialog, editText, radioGroup))
						   .setNegativeButton("Cancel", new OnClickListenerAnonymousInnerClassHelper34(dialog))
						   .create();
			}
			dialog.show();
		}
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:22,代码来源:DialogManager.cs

示例5: showWifiDialog

//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: static void showWifiDialog(android.app.AlertDialog dialog, android.content.Context context, final com.bixolon.labelprinter.BixolonLabelPrinter printer)
		internal static void showWifiDialog(AlertDialog dialog, Context context, BixolonLabelPrinter printer)
		{
			if (dialog == null)
			{
				LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.view.View layout = inflater.inflate(R.layout.dialog_wifi, null);
				View layout = inflater.inflate(R.layout.dialog_wifi, null);

				dialog = (new AlertDialog.Builder(context)).setView(layout).setTitle("Wi-Fi Connect").setPositiveButton("OK", new OnClickListenerAnonymousInnerClassHelper4(dialog, printer, layout))
					   .setNegativeButton("Cancel", new OnClickListenerAnonymousInnerClassHelper5(dialog))
					   .create();
			}
			dialog.show();
		}
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:17,代码来源:DialogManager.cs

示例6: CustomAudioDevice

		public CustomAudioDevice(Context context)
		{
			if (!InstanceFieldsInitialized)
			{
				InitializeInstanceFields();
				InstanceFieldsInitialized = true;
			}
			this.m_context = context;

			try
			{
				m_playBuffer = ByteBuffer.allocateDirect(MAX_SAMPLES);
				m_recBuffer = ByteBuffer.allocateDirect(MAX_SAMPLES);
			}
			catch (Exception e)
			{
				Log.e(LOG_TAG, e.Message);
			}

			m_tempBufPlay = new sbyte[MAX_SAMPLES];
			m_tempBufRec = new sbyte[MAX_SAMPLES];

			m_captureSettings = new AudioSettings(SAMPLING_RATE, NUM_CHANNELS_CAPTURING);
			m_rendererSettings = new AudioSettings(SAMPLING_RATE, NUM_CHANNELS_RENDERING);

			m_audioManager = (AudioManager) m_context.getSystemService(Context.AUDIO_SERVICE);

			m_audioManager.Mode = AudioManager.MODE_IN_COMMUNICATION;
		}
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:29,代码来源:CustomAudioDevice.cs

示例7: isInDedicatedEngagementProcess

	  /// <summary>
	  /// Return <tt>true</tt> if the caller runs in a process dedicated to the Engagement service.<br/>
	  /// Return <tt>false</tt> otherwise, e.g. if it's the application process (even if the Engagement
	  /// service is running in it) or another process.<br/>
	  /// This method is useful when the <b>android:process</b> attribute has been set on the Engagement
	  /// service, if this method return <tt>true</tt>, application initialization must not be done in
	  /// that process. This method is used by <seealso cref="EngagementApplication"/>. </summary>
	  /// <param name="context"> the application context. </param>
	  /// <returns> <tt>true</tt> if the caller is running in a process dedicated to the Engagement
	  ///         service, <tt>false</tt> otherwise. </returns>
	  /// <seealso cref= EngagementApplication </seealso>
	  public static bool isInDedicatedEngagementProcess(Context context)
	  {
		/* Get our package info */
		PackageInfo packageInfo;
		try
		{
	  packageInfo = context.PackageManager.getPackageInfo(context.PackageName, PackageManager.GET_SERVICES);
		}
		catch (Exception)
		{
		  /*
		   * NameNotFoundException (uninstalling?) or in some rare scenario an undocumented
		   * "RuntimeException: Package manager has died.", probably caused by a system app process
		   * crash.
		   */
		  return false;
		}

		/* Get main process name */
		string mainProcess = packageInfo.applicationInfo.processName;

		/* Get embedded Engagement process name */
		string engagementProcess = null;
		if (packageInfo.services != null)
		{
		  foreach (ServiceInfo serviceInfo in packageInfo.services)
		  {
			if (SERVICE_CLASS.Equals(serviceInfo.name))
			{
			  engagementProcess = serviceInfo.processName;
			  break;
			}
		  }
		}

		/* If the embedded Engagement service runs on its own process */
		if (engagementProcess != null && !engagementProcess.Equals(mainProcess))
		{
		  /* The result is to check if the current process is the engagement process */
		  ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
		  foreach (ActivityManager.RunningAppProcessInfo rapInfo in activityManager.RunningAppProcesses)
		  {
			if (rapInfo.pid == Process.myPid())
			{
			  return rapInfo.processName.Equals(engagementProcess);
			}
		  }
		}

		/* Otherwise engagement is not running in a separate process (or not running at all) */
		return false;
	  }
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:63,代码来源:EngagementAgentUtils.cs

示例8: EngagementDefaultNotifier

	  /// <summary>
	  /// Init default notifier. </summary>
	  /// <param name="context"> any application context. </param>
	  public EngagementDefaultNotifier(Context context)
	  {
		/* Init */
		mContext = context.ApplicationContext;
		mNotificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);

		/* Get icon identifiers from AndroidManifest.xml */
		Bundle appMetaData = EngagementUtils.getMetaData(context);
		mNotificationIcon = getIcon(appMetaData, METADATA_NOTIFICATION_ICON);
	  }
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:13,代码来源:EngagementDefaultNotifier.cs

示例9: downloadBigPicture

	  /// <summary>
	  /// Schedule the download of the big picture associated with the content. </summary>
	  /// <param name="context"> any application context. </param>
	  /// <param name="content"> content with big picture notification. </param>
	  public static void downloadBigPicture(Context context, EngagementReachInteractiveContent content)
	  {
		/* Set up download request */
		DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
		Uri uri = Uri.parse(content.NotificationBigPicture);
		DownloadManager.Request request = new DownloadManager.Request(uri);
		request.NotificationVisibility = DownloadManager.Request.VISIBILITY_HIDDEN;
		request.VisibleInDownloadsUi = false;

		/* Create intermediate directories */
		File dir = context.getExternalFilesDir("engagement");
		dir = new File(dir, "big-picture");
		dir.mkdirs();

		/* Set destination */
		long contentId = content.LocalId;
		request.DestinationUri = Uri.fromFile(new File(dir, contentId.ToString()));

		/* Submit download */
		long id = downloadManager.enqueue(request);
		content.setDownloadId(context, id);

		/* Set up timeout on download */
		Intent intent = new Intent(EngagementReachAgent.INTENT_ACTION_DOWNLOAD_TIMEOUT);
		intent.putExtra(EngagementReachAgent.INTENT_EXTRA_CONTENT_ID, contentId);
		intent.Package = context.PackageName;
		PendingIntent operation = PendingIntent.getBroadcast(context, (int) contentId, intent, 0);
		long triggerAtMillis = SystemClock.elapsedRealtime() + DOWNLOAD_TIMEOUT;
		AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
		alarmManager.set(ELAPSED_REALTIME_WAKEUP, triggerAtMillis, operation);
	  }
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:35,代码来源:EngagementNotificationUtilsV11.cs

示例10: deleteDownload

	  /// <summary>
	  /// Cancel download or erase already downloaded file for the specified content. </summary>
	  /// <param name="context"> any application context. </param>
	  /// <param name="downloadId"> download identifier. </param>
	  public static void deleteDownload(Context context, long downloadId)
	  {
		DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
		downloadManager.remove(downloadId);
	  }
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:9,代码来源:EngagementNotificationUtilsV11.cs

示例11: getBigPicture

	  /// <summary>
	  /// Decode downloaded big picture. </summary>
	  /// <param name="context"> any application context. </param>
	  /// <param name="downloadId"> downloaded picture identifier. </param>
	  /// <returns> decoded bitmap if successful, null on error. </returns>
	  public static Bitmap getBigPicture(Context context, long downloadId)
	  {
		/* Decode bitmap */
		System.IO.Stream stream = null;
		try
		{
		  /*
		   * Query download manager to get file. FIXME For an unknown reason, using the file descriptor
		   * fails after APK build with ProGuard, we use stream instead.
		   */
		  DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
		  Uri uri = downloadManager.getUriForDownloadedFile(downloadId);
		  ContentResolver contentResolver = context.ContentResolver;
		  stream = contentResolver.openInputStream(uri);

		  /*
		   * Bitmaps larger than 2048 in any dimension are likely to cause OutOfMemoryError in the
		   * NotificationManager or even here. Plus some devices simply don't accept such images: the
		   * notification manager can drop the notification without any way to check that via API. To
		   * avoid the problem, sub sample the image in an efficient way (not using Bitmap matrix
		   * scaling after decoding the bitmap with original size: it could run out of memory when
		   * decoding the full image). FIXME There is center cropping applied by the NotificationManager
		   * on the bitmap we provide, we can't avoid it, see
		   * https://code.google.com/p/android/issues/detail?id=58318.
		   */
		  BitmapFactory.Options options = new BitmapFactory.Options();
		  options.inJustDecodeBounds = true;
		  options.inSampleSize = 1;
		  options.inPreferQualityOverSpeed = true;

		  /* Decode dimensions */
		  BitmapFactory.decodeStream(stream, null, options);
		  int maxDim = Math.Max(options.outWidth, options.outHeight);

		  /* Compute sub sample size (it must be a power of 2) */
		  while (maxDim > 2048)
		  {
			options.inSampleSize <<= 1;
			maxDim >>= 1;
		  }

		  /* Decode actual bitmap */
		  options.inJustDecodeBounds = false;
		  stream.Close();
		  stream = contentResolver.openInputStream(uri);
		  return BitmapFactory.decodeStream(stream, null, options);
		}
		catch (Exception)
		{
		  /* Abort, causes are likely FileNotFoundException or OutOfMemoryError */
		  return null;
		}
		finally
		{
		  /* Silently close stream */
		  if (stream != null)
		  {
			try
			{
			  stream.Close();
			}
			catch (IOException)
			{
			}
		  }
		}
	  }
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:72,代码来源:EngagementNotificationUtilsV11.cs


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