content: /*
   * Copyright 2022 Andrey Novikov
   *
   * This program is free software: you can redistribute it and/or modify it under the
   * terms of the GNU Lesser General Public License as published by the Free Software
   * Foundation, either version 3 of the License, or (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful, but WITHOUT ANY
   * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
   * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public License along with
   * this program. If not, see <http://www.gnu.org/licenses/>.
   *
   */
  
  package mobi.maptrek.util;
  
  import android.content.Context;
  import android.content.Intent;
  import android.content.pm.PackageManager;
  import android.content.pm.ResolveInfo;
  
  import java.util.List;
  
  public class ContextUtils {
      public static void sendExplicitBroadcast(Context context, String action) {
          PackageManager packageManager = context.getPackageManager();
          Intent intent = new Intent(action);
          List<ResolveInfo> plugins = packageManager.queryBroadcastReceivers(intent, 0);
          for (ResolveInfo plugin : plugins) {
              intent = new Intent(action);
              intent.setClassName(plugin.activityInfo.packageName, plugin.activityInfo.name);
              intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
              context.sendBroadcast(intent);
          }
      }
  }
  