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


C# Intent.ResolveActivity方法代码示例

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


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

示例1: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);
            var button = FindViewById<Button>(Resource.Id.MyButton);

            button.Click += delegate
            {
                PackageManager pm = this.PackageManager;
                bool permission = (Permission.Granted == pm.CheckPermission("android.permission.CAMERA", this.PackageName));
                if (permission)
                {
                    Toast.MakeText(this, "有这个权限", ToastLength.Long).Show();
                }
                else
                {
                    Toast.MakeText(this, "木有这个权限", ToastLength.Long).Show();
                }

                string dirPath = System.IO.Path.Combine(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures).AbsolutePath, "GreatGateApp");
                if (!System.IO.Directory.Exists(dirPath))
                    System.IO.Directory.CreateDirectory(dirPath);
                var _tmepCameraPath = System.IO.Path.Combine(dirPath, DateTime.UtcNow.ToString("yyyyMMddHHmmssffff") + ".png");
                Intent i = new Intent(MediaStore.ActionImageCapture);
                i.PutExtra(Android.Provider.MediaStore.ExtraOutput, Android.Net.Uri.FromFile(new Java.IO.File(_tmepCameraPath)));
                if (i.ResolveActivity(this.PackageManager) != null)
                {
                    TaskCompletionSource<string> _onTakePictureBack = new TaskCompletionSource<string>();
                    this.StartActivityForResult(i, requestImageCapture);
                }
            };
        }
开发者ID:Yi-shion,项目名称:Xamarin,代码行数:32,代码来源:MainActivity.cs

示例2: OnOptionsItemSelected

        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (_drawerToggle.OnOptionsItemSelected(item))
                return true;

            switch (item.ItemId)
            {
                case Resource.Id.action_websearch:
                    {
                        var intent = new Intent(Intent.ActionWebSearch);
                        intent.PutExtra(SearchManager.Query, ActionBar.Title);

                        if ((intent.ResolveActivity(PackageManager)) != null)
                            StartActivity(intent);
                        else
                            Toast.MakeText(this, Resource.String.app_not_available, ToastLength.Long).Show();
                        return true;
                    }
                case Resource.Id.action_slidingpane:
                    {
                        var intent = new Intent(this, typeof(SlidingPaneLayoutActivity));
                        intent.AddFlags(ActivityFlags.ClearTop);
                        StartActivity(intent);
                        return true;
                    }
                default:
                    return base.OnOptionsItemSelected(item);
            }
        }
开发者ID:Cheesebaron,项目名称:DrawerSample,代码行数:29,代码来源:DrawerSampleActivity.cs

示例3: CanOpenUrl

 public bool CanOpenUrl(Uri uri)
 {
     var pm = Forms.Context.ApplicationContext.PackageManager;
     var intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri.AbsoluteUri));
     if (intent.ResolveActivity(pm) != null)
     {
         return true;
     }
     return false;
 }
开发者ID:MattHarrington,项目名称:XFStreamingAudio,代码行数:10,代码来源:DeviceExtensionAndroid.cs

示例4: OnCreate

        /// <summary>
        /// Override default OnCreate
        /// </summary>
        /// <param name="bundle"></param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            Button browseButton = FindViewById<Button>(Resource.Id.ButtonBrowse);

            //When "Browse" button clicked, fire an intent to select image
            browseButton.Click += delegate
            {
                Intent imageIntent = new Intent();
                imageIntent.SetType(FileType_Image);
                imageIntent.SetAction(Intent.ActionGetContent);
                StartActivityForResult(
                    Intent.CreateChooser(imageIntent, PromptText_SelectImage), PICK_IMAGE);
            };

            Button takePictureButton = FindViewById<Button>(Resource.Id.ButtonTakePicture);

            //When "Take a picture" button clicked, fire an intent to take picture
            takePictureButton.Click += delegate
            {
                Intent takePictureIntent = new Intent(MediaStore.ActionImageCapture);
                if (takePictureIntent.ResolveActivity(PackageManager) != null)
                {
                    // Create the File where the photo should go
                    Java.IO.File photoFile = null;
                    try
                    {
                        photoFile = createImageFile();
                    }
                    catch (Java.IO.IOException)
                    {
                        //TODO: Error handling
                    }  
                    // Continue only if the File was successfully created
                    if (photoFile != null)
                    {
                        takePictureIntent.PutExtra(MediaStore.ExtraOutput, 
                            Android.Net.Uri.FromFile(photoFile));

                        //Delete this temp file, only keey its Uri information
                        photoFile.Delete();

                        TempFileUri = Android.Net.Uri.FromFile(photoFile);
                        StartActivityForResult(takePictureIntent, TAKE_PICTURE);
                    }
                }
            };
                    
        }
开发者ID:aweeesome,项目名称:faceit,代码行数:56,代码来源:MainActivity.cs

示例5: StartRouting

		public void StartRouting(string name, Position pos) 
		{
			// TODO: Conversion from lat/lon to string should be on all devices with point "." instead of ","
			string uri = String.Format("google.navigation:q={0},{1}({2})", pos.Latitude.ToString().Replace(",", "."), pos.Longitude.ToString().Replace(",", "."), name);

			Intent intent = new Intent(Intent.ActionView, global::Android.Net.Uri.Parse("google.navigation:q=0,0"));

			// Do we have a navigation app?
			if (intent.ResolveActivity(Forms.Context.PackageManager) == null)
				return;

			Forms.Context.StartActivity(intent);
		}
开发者ID:Surfoo,项目名称:WF.Player,代码行数:13,代码来源:Routing.cs

示例6: StartMap

        public static void StartMap(Context context)
        {
            var locationIntent = new Intent(Intent.ActionView);
            var prefs = PreferenceManager.GetDefaultSharedPreferences(context);
            var location = prefs.GetString(context.GetString(Resource.String.LocationPrefKey), context.GetString(Resource.String.LocationPrefDefault));

            var geoLocation = Uri.Parse("geo:0,0?").BuildUpon().AppendQueryParameter("q", location).Build();
            locationIntent.SetData(geoLocation);

            if (locationIntent.ResolveActivity(context.PackageManager) != null)
            {
                context.StartActivity(locationIntent);
            }
            else
            {
                Log.Debug("SpringTime", "Could not open activity with location: " + location);
            }
        }
开发者ID:chadsmith12,项目名称:Spring-Time,代码行数:18,代码来源:Intents.cs

示例7: Send

        /// <summary>
        /// Creates the share <see cref="Intent"/> and launches it.
        /// </summary>
        /// <returns>Returns <see cref="bool"/> with <value>true</value> if sucessful or <value>false</value> if not.</returns>
        /// <exception cref="!:NoType:ActivityNotFoundException">May throw if any email activities not found.</exception>
        public bool Send()
        {
            var shareIntent = new Intent(Intent.ActionSend);
            shareIntent.SetType(_mimeType);

            shareIntent.PutExtra(Intent.ExtraText, BuildText());

            if (_uri != null)
                shareIntent.PutExtra(Intent.ExtraStream, _uri);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                shareIntent.AddFlags(ActivityFlags.NewDocument);
            else
                shareIntent.AddFlags(ActivityFlags.ClearWhenTaskReset);

            if (shareIntent.ResolveActivity(_context.PackageManager) == null) return false;

            _context.StartActivity(shareIntent);
            return true;
        }
开发者ID:Cheesebaron,项目名称:Chelle,代码行数:25,代码来源:SocialShare.cs

示例8: Send

        /// <summary>
        /// Creates the email <see cref="Intent"/> and launches it.
        /// </summary>
        /// <returns>Returns <see cref="bool"/> with <value>true</value> if sucessful or <value>false</value> if not.</returns>
        /// <exception cref="!:NoType:ActivityNotFoundException">May throw if any email activities not found.</exception>
        public bool Send()
        {
            var emailIntent = new Intent(Intent.ActionSend);
            emailIntent.SetType(Mime.Email);
            emailIntent.SetData(Uri.Parse("mailto:"));

            if (_toList.Any())
                emailIntent.PutExtra(Intent.ExtraEmail, _toList.ToArray());

            if (_ccList.Any())
                emailIntent.PutExtra(Intent.ExtraCc, _ccList.ToArray());

            if (_bccList.Any())
                emailIntent.PutExtra(Intent.ExtraBcc, _bccList.ToArray());

            emailIntent.PutExtra(Intent.ExtraSubject, _subject);
            emailIntent.PutExtra(Intent.ExtraText, _body);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                emailIntent.AddFlags(ActivityFlags.NewDocument);
            else
                emailIntent.AddFlags(ActivityFlags.ClearWhenTaskReset);

            if (emailIntent.ResolveActivity(_context.PackageManager) == null) return false;

            _context.StartActivity(emailIntent);
            return true;
        }
开发者ID:Cheesebaron,项目名称:Chelle,代码行数:33,代码来源:Email.cs

示例9: OpenPreferredLocationInMap

        private void OpenPreferredLocationInMap()
        {
            ISharedPreferences sharedPrefs =
                PreferenceManager.GetDefaultSharedPreferences(this);
            string location = sharedPrefs.GetString(
                "city",
                "Thessaloniki");

            // Using the URI scheme for showing a location found on a map. This super-handy
            // intent can is detailed in the "Common Intents" page of Android's developer site:
            // http://developer.android.com/guide/components/intents-common.html#Maps

            Android.Net.Uri geoLocation = Android.Net.Uri.Parse("geo:0,0?").BuildUpon()
                .AppendQueryParameter("q", location)
                .Build();

            Intent intent = new Intent(Intent.ActionView);
            intent.SetData(geoLocation);

            if (intent.ResolveActivity(PackageManager) != null)
            {
                StartActivity(intent);
            }
            else
            {
                Log.Debug("SunshineX", "Couldn't call " + location + ", no receiving apps installed!");
            }
        }
开发者ID:aeleftheriadis,项目名称:Presentations,代码行数:28,代码来源:MainActivity.cs

示例10: StartRouting

		void StartRouting(double lat, double lon)
		{
			// TODO: Conversion from lat/lon to string should be on all devices with point "." instead of ","
			string uri = String.Format("google.navigation:q={0},{1}", lat.ToString().Replace(",", "."), lon.ToString().Replace(",", "."));
			Intent intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(uri));
			if (intent.ResolveActivity(this.PackageManager) != null) {
				this.StartActivity(intent);
			}
		}
开发者ID:WFoundation,项目名称:WF.Player.Android,代码行数:9,代码来源:DetailActivity.cs

示例11: HasRouting

		bool HasRouting()
		{
			Intent intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse("google.navigation:q=0,0"));

			return intent.ResolveActivity(this.PackageManager) != null;
		}
开发者ID:WFoundation,项目名称:WF.Player.Android,代码行数:6,代码来源:DetailActivity.cs

示例12: OpenNotification

//		private void OpenNotification(Context context,Bundle bundle)
//		{
//			//清除通知
//			//JPushInterface.ClearNotificationById(context,bundle.GetInt(JPushInterface.ExtraNotificationId));//根据通知id
//			String extras = bundle.GetString(JPushInterface.ExtraExtra);
//			JPushInterface.ClearAllNotifications(context);//清除所有通知
//			Intent intent = new Intent(context,typeof(AlarmDetailInfoActivity));
//			bundle.PutString("alarmOrigin","Jpush");
//			intent.PutExtras (bundle);
//			intent.SetFlags (ActivityFlags.NewTask);
//			context.StartActivity (intent);
//		}


		private void OpenNotification(Context context,Bundle bundle)
		{
			//清除所有通知
			JPushInterface.ClearAllNotifications(context);
			//判断app进程是否存活
			if (EldYoungUtil.IsApplive (context, "com.eldyoung.lelaozuandroidapp")) {
				//如果存活的话,就直接启动报警DetailActivity,但要考虑一种情况,就是app的进程虽然仍然在
				//但Task栈已经空了,比如用户点击Back键退出应用,但进程还没有被系统回收,如果直接启动
				//DetailActivity,再按Back键就不会返回任何界面了。所以在启动DetailActivity前,要先启动splash界面。
				Log.Info("NotificationReceiver", "the app process is alive");
				bool mainActivityexistflag = false;
				Intent mainIntent = new Intent(context, typeof(MainFragActivity));
				var cmpName = mainIntent.ResolveActivity (context.PackageManager);
				if (cmpName != null) {
					//系统存在此activity
					ActivityManager _activityManager = (ActivityManager)context.GetSystemService (Context.ActivityService);
					var taskInfoLists = _activityManager.GetRunningTasks (20);
					foreach (ActivityManager.RunningTaskInfo taskInfo in taskInfoLists) {
						if (taskInfo.BaseActivity.Equals (cmpName)) {
							mainActivityexistflag = true;
							break;
						}

					}
				}

				//堆栈中不存在主界面活动,进入splash界面
				if (!mainActivityexistflag) {
					Intent launchIntent = context.PackageManager.GetLaunchIntentForPackage ("com.eldyoung.lelaozuandroidapp");
					launchIntent.SetFlags (
						ActivityFlags.NewTask | ActivityFlags.ResetTaskIfNeeded);
					bundle.PutString ("alarmOrigin", "Jpush");
					launchIntent.PutExtras (bundle);
					context.StartActivity (launchIntent);

				} else {
					//堆栈中存在主界面活动
					Intent alarmDetailInfoIntent = new Intent(context, typeof(AlarmDetailInfoActivity));
					alarmDetailInfoIntent.SetFlags (ActivityFlags.NewTask | ActivityFlags.SingleTop);
					bundle.PutString("alarmOrigin","Jpush");
					alarmDetailInfoIntent.PutExtras (bundle);
					context.StartActivity (alarmDetailInfoIntent);
				}
				   
			} else {
				//如果app进程已经被杀死,先重新启动app,将alarmDetailActivity的启动参数传入Intent中,参数经过
				//SplashActivity传入MainActivity,此时app的初始化已经完成,在MainActivity中就可以根据传入,参数跳转到DetailActivity中去了
				Log.Info("NotificationReceiver", "the app process is dead");
				Intent launchIntent = context.PackageManager.GetLaunchIntentForPackage ("com.eldyoung.lelaozuandroidapp");
				launchIntent.SetFlags(
					ActivityFlags.NewTask|ActivityFlags.ResetTaskIfNeeded);
				bundle.PutString("alarmOrigin","Jpush");
				launchIntent.PutExtras (bundle);
				context.StartActivity(launchIntent);

					
			}
				
		}
开发者ID:lq-ever,项目名称:EldYoungAndroidApp,代码行数:73,代码来源:CustomJPushReceiver.cs

示例13: openPreferredLocationInMap

        private void openPreferredLocationInMap()
        {
            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences (this);
            var zipCode = prefs.GetString (Resources.GetString (Resource.String.pref_location_key), Resources.GetString (Resource.String.pref_location_default));

            var geoLocation = Android.Net.Uri.Parse ("geo:0,0?")
                    .BuildUpon ()
                    .AppendQueryParameter ("q", zipCode)
                    .Build ();
            var mapIntent = new Intent (Intent.ActionView, geoLocation);
            if (mapIntent.ResolveActivity (this.PackageManager) != null) {
                StartActivity (mapIntent);
            } else {
                Toast.MakeText (this, "No Map App found", ToastLength.Long).Show ();
                Log.Debug ("Main Activity", "Couldn't call " + zipCode + ", No Maps App");
            }

            //Alternative way of calling the activity but not a fully implicint intent
            //			var geoLocation = Android.Net.Uri.Parse("http://maps.google.com/maps/place/"+zipCode);
            //
            //			var mapIntent = new Intent(Intent.ActionView,geoLocation);
            //			mapIntent.SetClassName ("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
            //			try
            //			{
            //				StartActivity (mapIntent);
            //
            //			}
            //			catch(ActivityNotFoundException ex)
            //			{
            //				try
            //				{
            //					Intent unrestrictedIntent = new Intent(Intent.ActionView, geoLocation);
            //					StartActivity(unrestrictedIntent);
            //				}
            //				catch(ActivityNotFoundException innerEx)
            //				{
            //					Toast.MakeText(this, "Please install a maps application", ToastLength.Long).Show();
            //				}
            //			}
        }
开发者ID:Screech129,项目名称:WeatherApp,代码行数:40,代码来源:MainActivity.cs

示例14: MButtonTakePicture_Click

		private void MButtonTakePicture_Click(object sender, EventArgs e) {
			Intent takePictureIntent = new Intent(MediaStore.ActionImageCapture);
			if (takePictureIntent.ResolveActivity(PackageManager) != null) {
				Java.IO.File photoFile = null;
				try {
					photoFile = CreateImageFile();
				} catch (Java.IO.IOException ex) {
					Toast.MakeText(this, "Coœ sie zjeba³o ze zdjeciem", ToastLength.Long).Show();
				}
				if (photoFile != null) {
					photoIsTaking = true;
					takePictureIntent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(photoFile));
					StartActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
				}
			}
		}
开发者ID:MarcinSzyszka,项目名称:MobileSecondHand,代码行数:16,代码来源:AddNewAdvertisementActivity.cs

示例15: OnOptionsItemSelected

		public override bool OnOptionsItemSelected (IMenuItem item)
		{
			// The action bar home/up action should open or close the drawer.
			// ActionBarDrawerToggle will take care of this.
			if (mDrawerToggle.OnOptionsItemSelected (item)) {
				return true;
			}
			// Handle action buttons
			switch (item.ItemId) {
			case Resource.Id.action_websearch:
				// create intent to perform web search for this planet
				Intent intent = new Intent (Intent.ActionWebSearch);
				intent.PutExtra (SearchManager.Query, this.ActionBar.Title);
				// catch event that there's no activity to handle intent
				if (intent.ResolveActivity (this.PackageManager) != null) {
					StartActivity (intent);
				} else {
					Toast.MakeText (this, Resource.String.app_not_available, ToastLength.Long).Show ();
				}
				return true;
			default:
				return base.OnOptionsItemSelected (item);
			}
		}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:24,代码来源:NavigationDrawerActivity.cs


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