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


C# Intent.SetPackage方法代码示例

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


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

示例1: OnCreate

		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			// Set our view from the "main" layout resource
			SetContentView (Resource.Layout.Main);

			// Get our button from the layout resource,
			// and attach an event to it
			var registerButton = FindViewById<Button> (Resource.Id.registerButton);
			var unregisterButton = FindViewById<Button> (Resource.Id.unregisterButton);
			
			registerButton.Click += delegate {
				const string senders = "<Google Cloud Messaging Sender ID>";
				var intent = new Intent("com.google.android.c2dm.intent.REGISTER");
				intent.SetPackage("com.google.android.gsf");
				intent.PutExtra("app", PendingIntent.GetBroadcast(this, 0, new Intent(), 0));
				intent.PutExtra("sender", senders);
				StartService(intent);
			};

			unregisterButton.Click += delegate {
				var intent = new Intent("com.google.android.c2dm.intent.UNREGISTER");
				intent.PutExtra("app", PendingIntent.GetBroadcast(this, 0, new Intent(), 0));
				StartService(intent);
			};
		}
开发者ID:codebase2015,项目名称:Xamarin.NotificationHub,代码行数:27,代码来源:MainActivity.cs

示例2: OnWebCheckoutButtonClicked

        // Launch the device browser so the user can complete the checkout.
        private void OnWebCheckoutButtonClicked(object sender, EventArgs e)
        {
            var intent = new Intent(Intent.ActionView);
            intent.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
            intent.SetData(Android.Net.Uri.Parse(SampleApplication.Checkout.WebUrl));

            try
            {
                intent.SetPackage("com.android.chrome");
                StartActivity(intent);
            }
            catch (Exception)
            {
                try
                {
                    // Chrome could not be opened, attempt to us other launcher
                    intent.SetPackage(null);
                    StartActivity(intent);
                }
                catch (Exception)
                {
                    OnError(GetString(Resource.String.checkout_error));
                }
            }
        }
开发者ID:mattleibow,项目名称:shopify-bindings,代码行数:26,代码来源:CheckoutActivity.cs

示例3: initShareItent

 // http://stackoverflow.com/questions/6827407/how-to-customize-share-intent-in-android/9229654#9229654
 private void initShareItent(String type)
 {
     bool found = false;
     Intent share = new Intent(Android.Content.Intent.ActionSend);
     share.SetType("image/jpeg");
     // gets the list of intents that can be loaded.    
     List<ResolveInfo> resInfo = PackageManager.QueryIntentActivities(share, 0).ToList();
     if (resInfo.Count > 0) {
         foreach (ResolveInfo info in resInfo) {
             if (info.ActivityInfo.PackageName.ToLower().Contains(type) ||
                 info.ActivityInfo.Name.ToLower().Contains(type)) {
                 share.PutExtra(Intent.ExtraSubject, "[Corpy] hi");
                 share.PutExtra(Intent.ExtraText, "Hi " + employee.Firstname);
                 //                    share.PutExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(myPath)) );
                 // class atrribute               
                 share.SetPackage(info.ActivityInfo.PackageName);
                 found = true;
                 break;
             }
         }
         if (!found)
             return;
         StartActivity(Intent.CreateChooser(share, "Select"));
     }
 } 
开发者ID:BeardAnnihilator,项目名称:xamarin-samples,代码行数:26,代码来源:DetailActivity.cs

示例4: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button btnGetRegID = FindViewById<Button> (Resource.Id.btnGetRegID);

            string senders = "374823337115";
            Intent intent = new Intent("com.google.android.c2dm.intent.REGISTER");
            intent.SetPackage("com.google.android.gsf");
            intent.PutExtra("app", PendingIntent.GetBroadcast(this, 0, new Intent(), 0));
            intent.PutExtra("sender", senders);
            this.StartService(intent);

            txtRegID = FindViewById<TextView> (Resource.Id.txtRegID);

            btnGetRegID.Click += delegate {

                txtRegID.Text = appRegID;
            };
        }
开发者ID:mamta-bisht,项目名称:VS2013Roadshow,代码行数:25,代码来源:MainActivity.cs

示例5: Connect

 public void Connect()
 {
     var serviceIntent = new Intent ("ir.cafebazaar.pardakht.InAppBillingService.BIND");
     serviceIntent.SetPackage("com.farsitel.bazaar");
     int intentServicesCount = _activity.PackageManager.QueryIntentServices (serviceIntent, 0).Count;
     if (intentServicesCount != 0) {
         _activity.BindService (serviceIntent, this, Bind.AutoCreate);
     }
 }
开发者ID:shakor,项目名称:XamarinInAppBillingForCafeBazaar,代码行数:9,代码来源:InAppBillingServiceConnection.cs

示例6: RegisterForGCM

 private void RegisterForGCM()
 {
     string senders = Constants.GoogleConsoleProjectId;
     Intent intent = new Intent("com.google.android.c2dm.intent.REGISTER");
     intent.SetPackage("com.google.android.gsf");
     intent.PutExtra("app", PendingIntent.GetBroadcast(this, 0, new Intent(), 0));
     intent.PutExtra("sender", senders);
     StartService(intent);
 }
开发者ID:Un1XX388,项目名称:LOSS,代码行数:9,代码来源:MainActivity.cs

示例7: StartService

        // main class
        public void StartService()
        {
            string senders = "922250740088";
            Intent intent = new Intent("com.google.android.c2dm.intent.REGISTER");

            intent.SetPackage("com.google.android.gsf");
            intent.PutExtra("app", PendingIntent.GetBroadcast(Application.Context, 0, new Intent(), 0));
            intent.PutExtra("sender", senders);
            Application.Context.StartService(intent);
        }
开发者ID:knezik,项目名称:gina-api-examples2,代码行数:11,代码来源:DroidPushNotificationService.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: HandleClick

        public void HandleClick()
        {
            Intent i = new Intent(Strings.ActionEntryActionSelected);
            i.SetPackage(_pluginPackage);
            i.PutExtra(Strings.ExtraActionData, _bundleExtra);
            i.PutExtra(Strings.ExtraFieldId, _fieldId);
            i.PutExtra(Strings.ExtraSender, _activity.PackageName);

            _activity.AddEntryToIntent(i);

            _activity.SendBroadcast(i);
        }
开发者ID:pythe,项目名称:wristpass,代码行数:12,代码来源:PluginPopupMenuItem.cs

示例10: BroadcastNewTotp

        private void BroadcastNewTotp(string totp)
        {
            Intent i = new Intent(Strings.ActionSetEntryField);
            i.PutExtra(Strings.ExtraAccessToken,new PluginDatabase(_context).GetInternalToken());
            i.SetPackage(_context.PackageName);
            i.PutExtra(Strings.ExtraSender, _context.PackageName);
            i.PutExtra(Strings.ExtraFieldValue, totp);
            i.PutExtra(Strings.ExtraEntryId, App.Kp2a.GetDb().LastOpenedEntry.Entry.Uuid.ToHexString());
            i.PutExtra(Strings.ExtraFieldId, _totp);
            i.PutExtra(Strings.ExtraFieldProtected, true);

            _context.SendBroadcast(i);
        }
开发者ID:pythe,项目名称:wristpass,代码行数:13,代码来源:UpdateTotpTimerTask.cs

示例11: RegisterForRemoteNotificationsAsync

		public async Task RegisterForRemoteNotificationsAsync()
		{
			var context = Application.Context;

			var senderId = DonkyAndroid.Settings.GcmSenderId 
				?? _configurationManager.GetValue<string>("DefaultGCMSenderId");
			Logger.Instance.LogInformation("Registering for GCM with SenderId {0}", senderId);
			var senders = senderId;
			var intent = new Intent("com.google.android.c2dm.intent.REGISTER");
			intent.SetPackage("com.google.android.gsf");
			intent.PutExtra("app", PendingIntent.GetBroadcast(context, 0, new Intent(), 0));
			intent.PutExtra("sender", senders);
			context.StartService(intent);
		}
开发者ID:Donky-Network,项目名称:DonkySDK-Xamarin-Modular,代码行数:14,代码来源:GcmRemoteNotificationChannel.cs

示例12: OnViewCreated

 public override void OnViewCreated(View view, Bundle savedInstanceState)
 {
     base.OnViewCreated (view, savedInstanceState);
     ListView.ItemLongClick += (sender, e) => {
         var artist = ((ArtistAdapter)ListAdapter).GetArtistData (e.Position);
         var name = artist.Name.Replace (' ', '_');
         name = Android.Net.Uri.Encode (name);
         var uri = "http://www.rdio.com/artist/" + name;
         var intent = new Intent (Intent.ActionView,
                                  Android.Net.Uri.Parse (uri));
         intent.SetPackage ("com.rdio.android.ui");
         StartActivity (intent);
     };
 }
开发者ID:phaufe,项目名称:Similardio,代码行数:14,代码来源:RdioListFragment.cs

示例13: RegisterService

        public static void RegisterService()
        {
            var keyStore = new LocalStore();
            var interval = keyStore.GetString(Constants.Keys.Interval);
            if (string.IsNullOrEmpty(interval))
                interval = "1";

            var intervalTime = 60000 * int.Parse(interval);

            var serviceIntent = new Intent(Constants.GPSServiceIntent);
            serviceIntent.SetPackage(Application.Context.PackageName);

            var alarm = (AlarmManager)Application.Context.GetSystemService(Context.AlarmService);
            var pendingServiceIntent = PendingIntent.GetService(Application.Context, 0, serviceIntent, PendingIntentFlags.CancelCurrent);
            alarm.SetRepeating(AlarmType.Rtc, 0, intervalTime, pendingServiceIntent);
        }
开发者ID:nihanli,项目名称:AndroidExperiments,代码行数:16,代码来源:ServiceHelper.cs

示例14: Connect

 public void Connect()
 {
     Intent intent = new Intent("ir.cafebazaar.pardakht.InAppBillingService.BIND");
     intent.SetPackage("com.farsitel.bazaar");
     IList<ResolveInfo> list = this._activity.PackageManager.QueryIntentServices(intent, 0);
     if (list == null)
     {
         this.RaiseOnInAppBillingError(InAppBillingErrorType.BillingNotSupported, "Unable to bind with com.android.vending.billing.InAppBillingService API.");
         this.Connected = false;
     }
     else if (list.Count != 0)
     {
         this._activity.BindService(intent, this, Bind.AutoCreate);
     }
     else
     {
         this.RaiseOnInAppBillingError(InAppBillingErrorType.BillingNotSupported, "Unable to access the com.android.vending service.");
         this.Connected = false;
     }
 }
开发者ID:hamishebahar,项目名称:Xamarin.InAppBilling,代码行数:20,代码来源:InAppBillingServiceConnection.cs

示例15: OnHandleIntent

        protected override void OnHandleIntent(Intent intent)
        {
            try
            {
                var context = ApplicationContext;
                var action = intent.Action;

                switch (action)
                {
                    case "com.google.android.c2dm.intent.REGISTRATION":
                        var senders = "MySenderID";
                        var regIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
                        regIntent.SetPackage("com.google.android.gsf");
                        regIntent.PutExtra("app", PendingIntent.GetBroadcast(context, 0, new Intent(), 0));
                        regIntent.PutExtra("sender", senders);
                        context.StartService(regIntent);
                        break;
                    case "com.google.android.c2dm.UNREGISTER":
                        var unregIntent = new Intent("com.google.android.c2dm.intent.UNREGISTER");
                        unregIntent.PutExtra("app", PendingIntent.GetBroadcast(context, 0, new Intent(), 0));
                        context.StartService(regIntent);
                        break;
                    case "com.google.android.c2dm.intent.RECEIVE":
                        var eventid = intent.GetStringExtra("eventid");
                        var eventname = intent.GetStringExtra("eventname");
                        if (!string.IsNullOrEmpty(eventname) &&)
                            App.Self.ChangedClass.BroadcastIt(eventname);
                        break;
                }
            }
            finally
            {
                lock (LOCK)
                {
                    if (wakeLock != null)
                        wakeLock.Release();
                }
            }
        }
开发者ID:nodoid,项目名称:GPSPush,代码行数:39,代码来源:GPSDroidService.cs


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