android.app.Activity.sendOrderedBroadcast()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(220)

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

Activity.sendOrderedBroadcast介绍

暂无

代码示例

代码示例来源:origin: com.uphyca/android-junit4-robolectric

/**
 * @param intent
 * @param receiverPermission
 * @see android.content.ContextWrapper#sendOrderedBroadcast(android.content.Intent,
 *      java.lang.String)
 */
public void sendOrderedBroadcast(Intent intent,
                 String receiverPermission) {
  mActivity.sendOrderedBroadcast(intent, receiverPermission);
}

代码示例来源:origin: com.uphyca/android-junit4-robolectric

/**
 * @param intent
 * @param receiverPermission
 * @param resultReceiver
 * @param scheduler
 * @param initialCode
 * @param initialData
 * @param initialExtras
 * @see android.content.ContextWrapper#sendOrderedBroadcast(android.content.Intent,
 *      java.lang.String, android.content.BroadcastReceiver,
 *      android.os.Handler, int, java.lang.String, android.os.Bundle)
 */
public void sendOrderedBroadcast(Intent intent,
                 String receiverPermission,
                 BroadcastReceiver resultReceiver,
                 Handler scheduler,
                 int initialCode,
                 String initialData,
                 Bundle initialExtras) {
  mActivity.sendOrderedBroadcast(intent, receiverPermission, resultReceiver, scheduler, initialCode, initialData, initialExtras);
}

代码示例来源:origin: penglu20/AcceptOrRejectCallDemo

private void broadcastHeadsetConnected(boolean connected) {
  Intent i = new Intent(Intent.ACTION_HEADSET_PLUG);
  i.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
  i.putExtra("state", connected ? 1 : 0);
  i.putExtra("name", "mysms");
  try {
    view.getActivity().sendOrderedBroadcast(i, null);
  } catch (Exception e) {
  }
}

代码示例来源:origin: penglu20/AcceptOrRejectCallDemo

public void acceptCall_4_1() {
  //模拟无线耳机的按键来接听电话
  // for HTC devices we need to broadcast a connected headset
  boolean broadcastConnected = MANUFACTURER_HTC.equalsIgnoreCase(Build.MANUFACTURER)
      && !audioManager.isWiredHeadsetOn();
  if (broadcastConnected) {
    broadcastHeadsetConnected(false);
  }
  try {
    try {
      Runtime.getRuntime().exec("input keyevent " +
          Integer.toString(KeyEvent.KEYCODE_HEADSETHOOK));
    } catch (IOException e) {
      // Runtime.exec(String) had an I/O problem, try to fall back
      String enforcedPerm = "android.permission.CALL_PRIVILEGED";
      Intent btnDown = new Intent(Intent.ACTION_MEDIA_BUTTON).putExtra(
          Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN,
              KeyEvent.KEYCODE_HEADSETHOOK));
      Intent btnUp = new Intent(Intent.ACTION_MEDIA_BUTTON).putExtra(
          Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP,
              KeyEvent.KEYCODE_HEADSETHOOK));
      view.getActivity().sendOrderedBroadcast(btnDown, enforcedPerm);
      view.getActivity().sendOrderedBroadcast(btnUp, enforcedPerm);
    }
  } finally {
    if (broadcastConnected) {
      broadcastHeadsetConnected(false);
    }
  }
}

相关文章

Activity类方法