Forum Xamarin Xamarin.Android

BroadcastReceiver not getting triggered

I am trying to clear data on app upgrade but it seemed like the broadcast receiver is not getting the call back

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Java.Lang;

namespace sample..Android
    [BroadcastReceiver(Enabled = true, Exported = true)]
    [IntentFilter(new[] { Intent.ActionPackageReplaced })]
    public class AppUpdateBroadcastReceiver : BroadcastReceiver
        public override void OnReceive(Context context, Intent intent)
            string packageName = context.ApplicationContext.PackageName;
            Runtime runtime = Runtime.GetRuntime();
            runtime.Exec("pm clear " + packageName);

Did I miss something? Do I need to put the receiver in the manifest file manually or does xamarin android do it automatically.


Sign In or Register to comment.