Skip to content

Instantly share code, notes, and snippets.

@luck-alex13
Created March 28, 2018 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luck-alex13/6e5cb40e868d0cee04b4cc412b5e961a to your computer and use it in GitHub Desktop.
Save luck-alex13/6e5cb40e868d0cee04b4cc412b5e961a to your computer and use it in GitHub Desktop.
Отправляет кастомный броадкаст (для Android 8)
private static void sendImplicitBroadcast(Context ctxt, Intent i) {
PackageManager pm = ctxt.getPackageManager();
List<ResolveInfo> matches = pm.queryBroadcastReceivers(i, 0);
for (ResolveInfo resolveInfo : matches) {
Intent explicit = new Intent(i);
ComponentName cn =
new ComponentName(resolveInfo.activityInfo.applicationInfo.packageName,
resolveInfo.activityInfo.name);
explicit.setComponent(cn);
ctxt.sendBroadcast(explicit);
}
}
//sowewhere in class
Intent intent = new Intent();
intent.setAction(CUSTOM_EVENT);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
intent.putExtra(KEY_NAME, binding.eventEt.getText().toString());
intent.putExtra(KEY_BUNDLE_ID, binding.bundleIdEt.getText().toString());
sendImplicitBroadcast(MainActivity.this, intent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment