private void CreateNotification(Intent intent) {
			recipe = Recipe.FromBundle(intent.GetBundleExtra(Constants.ExtraRecipe));
			List<Notification> notificationPages = new List<Notification> ();

			int stepCount = recipe.RecipeSteps.Count;

			for (int i = 0; i < stepCount; i++) {
				Recipe.RecipeStep recipeStep = recipe.RecipeSteps [i];
				var style = new NotificationCompat.BigTextStyle ();
				style.BigText (recipeStep.StepText);
				style.SetBigContentTitle (String.Format (Resources.GetString (Resource.String.step_count), i + 1, stepCount));
				style.SetSummaryText ("");
				var builder = new NotificationCompat.Builder (this);
				builder.SetStyle (style);
				notificationPages.Add (builder.Build ());
			}

			var notifBuilder = new NotificationCompat.Builder(this);

			if (recipe.RecipeImage != null) {
				Bitmap recipeImage = Bitmap.CreateScaledBitmap(
					AssetUtils.LoadBitmapAsset(this, recipe.RecipeImage),
					Constants.NotificationImageWidth, Constants.NotificationImageHeight, false);
				notifBuilder.SetLargeIcon(recipeImage);
			}
			notifBuilder.SetContentTitle (recipe.TitleText);
			notifBuilder.SetContentText (recipe.SummaryText);
			notifBuilder.SetSmallIcon (Resource.Mipmap.ic_notification_recipe);

			Notification notification = notifBuilder.Extend(new NotificationCompat.WearableExtender().AddPages(notificationPages)).Build();
			notificationManager.Notify (Constants.NotificationId, notification);
		}
        protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (requestCode == 0 && data != null)
            {
                // TestDialog
                var result = data.GetBundleExtra("Result");
                var image  = result.GetString("ImageName");
                Toast.MakeText(this, image, ToastLength.Long).Show();
                _filePath = image;
            }
        }
		public override void OnReceive (Context context, Intent intent)
		{
			PendingResult result = GoAsync ();

			// If app restriction settings are already created, they will be included in the Bundle
			// as key/value pairs.
			Bundle existingRestrictions = intent.GetBundleExtra (Intent.ExtraRestrictionsBundle);
			Log.Info (TAG, "existingRestrictions = " + existingRestrictions);

			Thread thread = new Thread (new ThreadStart (delegate {
				CreateRestrictions (context, result, existingRestrictions);
			}));

			thread.Start ();	
		}
        private void HandleIntent(Intent intent)
        {
            if (intent.Action.Equals(Intent.ActionSearch)) {
                var query = intent.GetStringExtra(SearchManager.Query);
                Toast.MakeText(this, query, ToastLength.Short).Show();

                if (this.T1 != null) {
                    this.T1.Text = query;
                }

                var bundle = intent.GetBundleExtra(SearchManager.AppData);
                if (bundle != null) {
                    var key1 = bundle.GetBoolean("Key1");
                    var key2 = bundle.GetBoolean("Key2");
                }
            }
        }
        protected override async void OnHandleIntent(Android.Content.Intent intent)
        {
            try
            {
                if (!Boolean.Parse(Java.Lang.JavaSystem.GetProperty("com.mobileiron.wrapped", "false")) &&
                    !this.PackageName.Equals(PackageManager.GetPermissionInfo("com.mobileiron.CONFIG_PERMISSION", 0).PackageName))
                {
                    Log.Debug(TAG, "Refusing intent as we don't own our permission?!");
                }
            }

            catch (PackageManager.NameNotFoundException ex)
            {
                Log.Debug(TAG, ex.Message + " " + "Refusing intent as we can't find our permission?!");
                return;
            }

            if ("com.mobileiron.HANDLE_CONFIG".Equals(intent.Action))
            {
                Log.Debug(TAG, "Received intent : " + intent + " from package " + intent.GetStringExtra("packageName"));

                Bundle config = intent.GetBundleExtra("config");

                if (config != null)
                {
                    Log.Debug(TAG, "Config Received");
                    foreach (var key in config.KeySet())
                    {
                        if (key == "alias")
                        {
                            Log.Debug(TAG, "Alias = " + config.GetString(key));
                        }
                    }
                    MessagingCenter.Send <IMobileIron>(this, "ConfigParsed");

                    HttpClient client = new HttpClient(new NativeMessageHandler {
                        DisableCaching = true
                    });
                    var response = await client.GetAsync("https://teamspace.slb.com/sites/ingwellmaps/_vti_bin/listdata.svc");

                    GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(new NotificationMessage(await response.Content.ReadAsStringAsync()));
                }
            }
        }
Example #6
0
 public override void OnReceive(Context context, Intent intent)
 {
     var pluginPackage = intent.GetStringExtra(Strings.ExtraSender);
     if (new PluginDatabase(context).IsValidAccessToken(pluginPackage,
                                                        intent.GetStringExtra(Strings.ExtraAccessToken),
                                                        Strings.ScopeCurrentEntry))
     {
         if (intent.GetStringExtra(Strings.ExtraEntryId) != _activity.Entry.Uuid.ToHexString())
         {
             Kp2aLog.Log("received action for wrong entry " + intent.GetStringExtra(Strings.ExtraEntryId));
             return;
         }
         _activity.AddPluginAction(pluginPackage,
                                   intent.GetStringExtra(Strings.ExtraFieldId),
                                   intent.GetStringExtra(Strings.ExtraActionId),
                                   intent.GetStringExtra(Strings.ExtraActionDisplayText),
                                   intent.GetIntExtra(Strings.ExtraActionIconResId, -1),
                                   intent.GetBundleExtra(Strings.ExtraActionData));
     }
     else
     {
         Kp2aLog.Log("received invalid request. Plugin not authorized.");
     }
 }