android.content.Intent.getShortExtra()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(256)

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

Intent.getShortExtra介绍

暂无

代码示例

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

private final BroadcastReceiver receiver = new BroadcastReceiver(){
  @Override
  public void onReceive(Context context, Intent intent) {

    String action = intent.getAction();
    if(BluetoothDevice.ACTION_FOUND.equals(action)) {
      int  rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE);
      Toast.makeText(getApplicationContext(),"  RSSI: " + rssi + "dBm", Toast.LENGTH_SHORT).show();
    }
  }
};

代码示例来源:origin: kibotu/net.kibotu.android.deviceinfo

@Override
  public void onReceive(Context context, Intent intent) {
    final String action = intent.getAction();

    if (BluetoothDevice.ACTION_FOUND.equals(action)) {
      RSSI = intent.getShortExtra(BluetoothDevice.ACTION_BOND_STATE_CHANGED, Short.MIN_VALUE);
    }
//            rssi = intent.getShortExtra(BluetoothDevice.EXTRA_NAME, Short.MIN_VALUE);
//            rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, Short.MIN_VALUE);
//            rssi = intent.getShortExtra(BluetoothDevice.EXTRA_CLASS, Short.MIN_VALUE);
//            rssi = intent.getShortExtra(BluetoothDevice.EXTRA_BOND_STATE, Short.MIN_VALUE);
//            rssi = intent.getShortExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, Short.MIN_VALUE);

//            public static final java.lang.String EXTRA_DEVICE = "android.bluetooth.device.extra.DEVICE";
//            public static final java.lang.String EXTRA_NAME = "android.bluetooth.device.extra.NAME";
//            public static final java.lang.String EXTRA_RSSI = "android.bluetooth.device.extra.RSSI";
//            public static final java.lang.String EXTRA_CLASS = "android.bluetooth.device.extra.CLASS";
//            public static final java.lang.String EXTRA_BOND_STATE = "android.bluetooth.device.extra.BOND_STATE";
//            public static final java.lang.String EXTRA_PREVIOUS_BOND_STATE = "android.bluetooth.device.extra.PREVIOUS_BOND_STATE";

  }

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

private final BroadcastReceiver receiver = new BroadcastReceiver(){
  @Override
  public void onReceive(Context context, Intent intent) {

    String action = intent.getAction();
    if(BluetoothDevice.ACTION_FOUND.equals(action)) {
      int  rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE);
      Toast.makeText(getApplicationContext(),"  RSSI: " + rssi + "dBm", Toast.LENGTH_SHORT).show();
    }
  }
};

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

private final BroadcastReceiver receiver = new BroadcastReceiver(){
  @Override
  public void onReceive(Context context, Intent intent) {

    String action = intent.getAction();
    if(BluetoothDevice.ACTION_FOUND.equals(action)) {
      short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE);
      Toast.makeText(getApplicationContext(),"  RSSI: " + rssi + "dBm", Toast.LENGTH_SHORT).show();
    }
  }
};

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

private final BroadcastReceiver receiver = new BroadcastReceiver(){
  @Override
  public void onReceive(Context context, Intent intent) {

    if(BluetoothDevice.ACTION_FOUND.equals(intent.getAction())) {
    //Get the RSSI value here
      int rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE);
    }

  }
};

代码示例来源:origin: JackWHLiu/jackknife

public static short getShortExtra(Intent intent, String name, short defaultValue) {
  if (intent != null || !hasExtra(intent, name)) return defaultValue;
  return intent.getShortExtra(name, defaultValue);
}

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

private final BroadcastReceiver receiver = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {

  String action = intent.getAction();
  if(BluetoothDevice.ACTION_FOUND.equals(action)) {
    int  rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE);
     // Use this as signal(device is near or Far)
    Toast.makeText(getApplicationContext(),"  RSSI: " + rssi + "dBm", Toast.LENGTH_SHORT).show();
  }
}
};

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

@Override
public void onCreate(Bundle savedInstanceState) {
  .....
  // Registering Broadcast. this will fire when Bluetoothdevice Found
  registerReceiver(receiver, new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED));
}

private final BroadcastReceiver BroadcastReceiver = new BroadcastReceiver(){
  @Override
  public void onReceive(Context context, Intent intent) {
    String mIntentAction = intent.getAction();
    if(BluetoothDevice.ACTION_ACL_CONNECTED.equals(mIntentAction)) {
      int RSSI = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE);
      String mDeviceName = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
    }
  }
};

代码示例来源:origin: schollz/find3-android-scanner

@Override
  public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (BluetoothDevice.ACTION_FOUND.equals(action)) {
      int rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, Short.MIN_VALUE);
      BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
      String name = device.getAddress().toLowerCase();
      Log.v(TAG, "bluetooth: " + name + " => " + rssi + "dBm");
      try {
        bluetoothResults.put(name, rssi);
      } catch (Exception e) {
        Log.e(TAG, e.toString());
      }
    }
  }
}

代码示例来源:origin: xiaolongonly/Ticket-Analysis

public static short getShortExtra(Intent intent, String name, short defaultValue) {
  if (!hasIntent(intent) || !hasExtra(intent, name)) return defaultValue;
  return intent.getShortExtra(name, defaultValue);
}

代码示例来源:origin: lifegh/Bluetooth

short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, Short.MAX_VALUE);
Log.i(TAG, "EXTRA_RSSI:" + rssi);
mListener.foundDev(dev);

代码示例来源:origin: Meituan-Dianping/Shield

public static short getShortParam(String name, short defaultValue, Fragment fragment) {
  if (fragment.getArguments() != null && fragment.getArguments().containsKey(name)) {
    return fragment.getArguments().getShort(name);
  }
  Intent i = fragment.getActivity().getIntent();
  try {
    Uri uri = i.getData();
    if (uri != null) {
      String val = uri.getQueryParameter(name);
      if (!TextUtils.isEmpty(val))
        return Short.parseShort(val);
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
  return i.getShortExtra(name, defaultValue);
}

代码示例来源:origin: adafruit/Bluefruit_LE_Connect_Android

setContentView(R.layout.activity_neopixel_boardtype);
mCurrentType = getIntent().getShortExtra(kActivityParameter_CurrentType, NeopixelBoard.kDefaultType);

代码示例来源:origin: whilu/LMBluetoothSdk

short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, (short) 0);
mBluetoothListener.onActionDeviceFound(device, rssi);
break;

代码示例来源:origin: adafruit/Bluefruit_LE_Connect_Android

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent intent) {
  if (resultCode == RESULT_OK) {
    if (requestCode == kActivityRequestCode_NeopixelColorPickerActivity && intent != null) {
      final int color = intent.getIntExtra(NeopixelColorPickerActivity.kActivityResult_SelectedColorResultKey, Color.WHITE);
      mCurrentColor = color;
      updatePickerColorButton(true);
    } else if (requestCode == kActivityRequestCode_NeopixelBoardSelectorActivity && intent != null) {
      final int boardIndex = intent.getIntExtra(NeopixelBoardSelectorActivity.kActivityResult_BoardIndexResultKey, -1);
      if (boardIndex >= 0) {
        NeopixelBoard board = new NeopixelBoard(this, boardIndex, NeopixelBoard.kDefaultType);
        changeBoard(board);
      } else {
        final int lineStripLength = intent.getIntExtra(NeopixelBoardSelectorActivity.kActivityResult_LineStripResultKey, 0);
        if (lineStripLength > 0) {
          NeopixelBoard board = new NeopixelBoard("1x" + lineStripLength, (byte) lineStripLength, (byte) 1, (byte) 3, (byte) lineStripLength, NeopixelBoard.kDefaultType);
          changeBoard(board);
        }
      }
    } else if (requestCode == kActivityRequestCode_NeopixelBoardTypeActivity && intent != null) {
      final short boardType = (short) intent.getShortExtra(NeopixelBoardTypeActivity.kActivityResult_BoardTypeResultKey, NeopixelBoard.kDefaultType);
      if (boardType != mBoard.type) {
        mBoard.type = boardType;
        changeBoard(mBoard);
      }
    }
  }
}

代码示例来源:origin: TellH/AutoGo

return intent.getDoubleExtra(key, (Double) defValue);
} else if ("Short".equals(type)) {
  return intent.getShortExtra(key, (Short) defValue);
} else if ("Long".equals(type)) {
  return intent.getLongExtra(key, (Long) defValue);

代码示例来源:origin: wiglenet/wigle-wifi-wardriving

int  rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE);

相关文章

Intent类方法