Created
March 28, 2018 03:17
-
-
Save luck-alex13/6e5cb40e868d0cee04b4cc412b5e961a to your computer and use it in GitHub Desktop.
Отправляет кастомный броадкаст (для Android 8)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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