android.content.Context.sendOrderedBroadcast()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(198)

本文整理了Java中android.content.Context.sendOrderedBroadcast()方法的一些代码示例,展示了Context.sendOrderedBroadcast()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.sendOrderedBroadcast()方法的具体详情如下:
包路径:android.content.Context
类名称:Context
方法名:sendOrderedBroadcast

Context.sendOrderedBroadcast介绍

暂无

代码示例

代码示例来源:origin: oasisfeng/condom

@Override public void sendOrderedBroadcast(Intent intent, String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler,
    int initialCode, String initialData, Bundle initialExtras) {
  mBase.sendOrderedBroadcast(intent, receiverPermission, resultReceiver, scheduler, initialCode, initialData, initialExtras);
}

代码示例来源:origin: oasisfeng/condom

@Override public void sendOrderedBroadcast(Intent intent, String receiverPermission) {
  mBase.sendOrderedBroadcast(intent, receiverPermission);
}

代码示例来源:origin: k9mail/k-9

public static void fetchAccounts(Context context, K9AccountReceptor receptor) {
  Intent accountFetchIntent = new Intent();
  accountFetchIntent.setAction(K9RemoteControl.K9_REQUEST_ACCOUNTS);
  AccountReceiver receiver = new AccountReceiver(receptor);
  context.sendOrderedBroadcast(accountFetchIntent, K9RemoteControl.K9_REMOTE_CONTROL_PERMISSION, receiver, null, Activity.RESULT_OK, null, null);
}

代码示例来源:origin: oasisfeng/condom

tests.add(new Consumer<Intent>() { @Override public void accept(final Intent intent) { condom.sendOrderedBroadcast(intent, permission.DUMP, null, null, 0, null, null); }});
tests.add(new Consumer<Intent>() { @Override public void accept(final Intent intent) { condom.sendStickyBroadcast(intent); }});

代码示例来源:origin: oasisfeng/condom

tests.add(new Consumer<Intent>() { @Override public void accept(final Intent intent) { condom.sendOrderedBroadcast(intent, permission.DUMP); }});
tests.add(new Consumer<Intent>() { @Override public void accept(final Intent intent) { condom.sendOrderedBroadcast(intent, permission.DUMP, null, null, 0, null, null); }});

代码示例来源:origin: android-hacker/VirtualXposed

public void sendOrderedBroadcastAsUser(Intent intent, VUserHandle user, String receiverPermission,
                    BroadcastReceiver resultReceiver, Handler scheduler, int initialCode,
                    String initialData, Bundle initialExtras) {
  Context context = VirtualCore.get().getContext();
  if (user != null) {
    intent.putExtra("_VA_|_user_id_", user.getIdentifier());
  }
  // TODO: checkPermission
  context.sendOrderedBroadcast(intent, null/* permission */, resultReceiver, scheduler, initialCode, initialData,
      initialExtras);
}

代码示例来源:origin: oasisfeng/condom

private static void testOrderedBroadcast(final Context context, final Intent intent, final boolean expected_pass) {
  final BroadcastReceiver responder = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) {
    setResultCode(Activity.RESULT_OK);
  }};
  if (intent.getAction() != null) context.registerReceiver(responder, new IntentFilter(intent.getAction()));
  try {
    final SettableFuture<Integer> future = new SettableFuture<>();
    context.sendOrderedBroadcast(intent, null, new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) {
      future.set(getResultCode());
    }}, null, Activity.RESULT_CANCELED, null, null);
    final int result = waitForCompletion(future);
    assertEquals(expected_pass ? Activity.RESULT_OK : Activity.RESULT_CANCELED, result);
  } finally {
    if (intent.getAction() != null) context.unregisterReceiver(responder);
  }
}

代码示例来源:origin: Trumeet/MiPushFramework

@Override public void sendOrderedBroadcast(Intent intent, String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler,
    int initialCode, String initialData, Bundle initialExtras) {
  mBase.sendOrderedBroadcast(intent, receiverPermission, resultReceiver, scheduler, initialCode, initialData, initialExtras);
}

代码示例来源:origin: Trumeet/MiPushFramework

@Override public void sendOrderedBroadcast(Intent intent, String receiverPermission) {
  mBase.sendOrderedBroadcast(intent, receiverPermission);
}

代码示例来源:origin: stackoverflow.com

final Intent intent = new Intent("com.example.app.REQUEST_RECEIVER");
context.sendOrderedBroadcast(intent, "com.example.app.permission.CONTROL_EXAMPLE_APP", new BroadcastReceiver() {
    @Override
    public void onReceive(final Context context, final Intent intent) {
      // getResultCode();
    }
  }, null, Activity.RESULT_CANCELED, null, null);

代码示例来源:origin: iqiyi/Neptune

/**
   * 通知 Service 绑定成功
   */
  public static void notifyServiceConnected(Context context, Class<? extends Service> service) {
    Intent intent = new Intent(IntentConstant.ACTION_SERVICE_CONNECTED);
    intent.putExtra(IntentConstant.EXTRA_SERVICE_CLASS, service);
    // 在插件 activity 进程被回收以后恢复过程中,需要保证有序,具体参见恢复逻辑
    context.sendOrderedBroadcast(intent, null);
  }
}

代码示例来源:origin: stackoverflow.com

public static void getLanguageDetails(Context context,
    OnLanguageDetailsListener andThen)
{
  Intent detailsIntent = new Intent(
      RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
  LanguageDetailsChecker checker = new LanguageDetailsChecker(andThen);
  context.sendOrderedBroadcast(detailsIntent, null, checker, null,
      Activity.RESULT_OK, null, null);
}

代码示例来源:origin: stackoverflow.com

public static void answerCall(Context context) {

   Intent buttonDown = new Intent(Intent.ACTION_MEDIA_BUTTON);       
   buttonDown.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK));
   context.sendOrderedBroadcast(buttonDown, "android.permission.CALL_PRIVILEGED");             

  // froyo and beyond trigger on buttonUp instead of buttonDown
  Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);
  buttonUp.putExtra(Intent.EXTRA_KEY_EVENT,
   new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK));
  context.sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");  
}

代码示例来源:origin: stackoverflow.com

public static void answerPhoneHeadsethook(Context context) {
  // Simulate a press of the headset button to pick up the call
  // SettingsClass.logMe(tag, "Simulating headset button");
  Intent buttonDown = new Intent(Intent.ACTION_MEDIA_BUTTON);
  buttonDown.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK));
  context.sendOrderedBroadcast(buttonDown, "android.permission.CALL_PRIVILEGED");

  // froyo and beyond trigger on buttonUp instead of buttonDown
  Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);
  buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK));
  context.sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
}

代码示例来源:origin: stackoverflow.com

private static void sendMediaButton(Context context, int keyCode) {
  KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
  Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
  intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
  context.sendOrderedBroadcast(intent);

  keyEvent = new KeyEvent(KeyEvent.ACTION_UP, keyCode);
  intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
  intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
  context.sendOrderedBroadcast(intent);
}

代码示例来源:origin: stackoverflow.com

public static void acceptCall(Context context) 
{
  Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);
  buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, 
   new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK));
  context.sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
}

代码示例来源:origin: renyuneyun/Easer

private void emitMediaButton(int keyCode) {
  KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
  Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
  intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
  context.sendOrderedBroadcast(intent, null);
  keyEvent = new KeyEvent(KeyEvent.ACTION_UP, keyCode);
  intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
  intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
  context.sendOrderedBroadcast(intent, null);
}

代码示例来源:origin: stackoverflow.com

public class OrderedBroadcastForwarder extends BroadcastReceiver
{
  public static final String ACTION_NAME = "action";

  @Override
  public void onReceive(Context context, Intent intent)
  {
    Intent forwardIntent = new Intent(intent.getStringExtra(ACTION_NAME));
    forwardIntent.putExtras(intent);
    forwardIntent.removeExtra(ACTION_NAME);

    context.sendOrderedBroadcast(forwardIntent, null);
  }
}

代码示例来源:origin: bzsome/VirtualApp-x326

public void sendOrderedBroadcastAsUser(Intent intent, VUserHandle user, String receiverPermission,
                    BroadcastReceiver resultReceiver, Handler scheduler, int initialCode,
                    String initialData, Bundle initialExtras) {
  Context context = VirtualCore.get().getContext();
  if (user != null) {
    intent.putExtra("_VA_|_user_id_", user.getIdentifier());
  }
  // TODO: checkPermission
  context.sendOrderedBroadcast(intent, null/* permission */, resultReceiver, scheduler, initialCode, initialData,
      initialExtras);
}

代码示例来源:origin: darkskygit/VirtualApp

public void sendOrderedBroadcastAsUser(Intent intent, VUserHandle user, String receiverPermission,
                    BroadcastReceiver resultReceiver, Handler scheduler, int initialCode,
                    String initialData, Bundle initialExtras) {
  Context context = VirtualCore.get().getContext();
  if (user != null) {
    intent.putExtra("_VA_|_user_id_", user.getIdentifier());
  }
  // TODO: checkPermission
  context.sendOrderedBroadcast(intent, null/* permission */, resultReceiver, scheduler, initialCode, initialData,
      initialExtras);
}

相关文章

Context类方法