对于收到的短信,我希望能够将发件人的手机号码与号码所有者名称相匹配。是否有人使用Twilio这样做?他们可以选择语音通话,但不能选择短信。谢谢。
答案 0 :(得分:1)
在twilio查找api中。 https://www.twilio.com/docs/api/lookups
private Bitmap decodeBitmapUri(Context ctx, Uri uri) throws FileNotFoundException {
Log.d(TAG, "decodeBitmapUri: ");
//Toast.makeText(this, "1o" , Toast.LENGTH_LONG).show();
Log.d(TAG, "initViews1: face detector is ============================ " + detector.isOperational());
int targetW = 300;
int targetH = 300;
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
bmOptions.inPreferredConfig=Bitmap.Config.RGB_565;
BitmapFactory.decodeStream(ctx.getContentResolver().openInputStream(uri), null, bmOptions);
android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(Camera.CameraInfo.CAMERA_FACING_FRONT, info);
int rotation = this.getWindowManager().getDefaultDisplay().getRotation();
int orientation = this.getResources().getConfiguration().orientation;
Log.d(TAG, "decodeBitmapUri: OREINTATION is ==================== " + orientation);
Log.d(TAG, "decodeBitmapUri: CAMERA ROTATION ========================= " + rotation);
//Camera.Size size = android.hardware.Camera.get
int photoW = bmOptions.outWidth;
Log.d(TAG, "decodeBitmapUri: width: " + photoW );
int photoH = bmOptions.outHeight;
Log.d(TAG, "decodeBitmapUri: height: " + photoH);
Log.d(TAG, "decodeBitmapUri: 4");
//Toast.makeText(this, "11" , Toast.LENGTH_LONG).show();
int scaleFactor = Math.min(photoW / targetW, photoH / targetH);
bmOptions.inJustDecodeBounds = false;
bmOptions.inSampleSize = scaleFactor;
/*this is because some phones default a camera Intent to landscape no matter how the phone is held
* so we check for camera orienatation, then check to see if width is greater than height
* */
if(orientation == 1 && (photoW > photoH)){
return rotate(BitmapFactory.decodeStream(ctx.getContentResolver()
.openInputStream(uri), null, bmOptions));
}
return BitmapFactory.decodeStream(ctx.getContentResolver()
.openInputStream(uri), null, bmOptions);
}
public static Bitmap rotate(Bitmap bitmap){
int w = bitmap.getWidth();
int h = bitmap.getHeight();
Matrix mtx = new Matrix();
mtx.postRotate(270);
return Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true);
}
您想要检索来电者名称,这取决于您是否使用了nodejs,但是发布了其他示例。