android P 【蓝牙】查看蓝牙接收的图片,屏幕会抖动一次

问题描述:

android P 【蓝牙】查看蓝牙接收的图片,屏幕会抖动一次

分析过程

分析的平台时高通 android p
通过log可以知道,蓝牙再接受到外部图片后,会启动BluetoothOppTransferHistory.java。

    /**
     * Open the selected finished transfer. mDownloadCursor must be moved to
     * appropriate position before calling this function
     */
    private void openCompleteTransfer() {
        int sessionId = mTransferCursor.getInt(mIdColumnId);
        Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + sessionId);
        BluetoothOppTransferInfo transInfo = BluetoothOppUtility.queryRecord(this, contentUri);
        if (transInfo == null) {
            Log.e(TAG, "Error: Can not get data from db");
            return;
        }
        if (transInfo.mDirection == BluetoothShare.DIRECTION_INBOUND
                && BluetoothShare.isStatusSuccess(transInfo.mStatus)) {
            // if received file successfully, open this file
            Log.e(TAG, "wangjicong open bt 0000");
            BluetoothOppUtility.updateVisibilityToHidden(this, contentUri);
            BluetoothOppUtility.openReceivedFile(this, transInfo.mFileName, transInfo.mFileType,
                    transInfo.mTimeStamp, contentUri);
        } else {
            Log.e(TAG, "wangjicong open bt 11111");
            Intent in = new Intent(this, BluetoothOppTransferActivity.class);
            in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            in.setDataAndNormalize(contentUri);
            this.startActivity(in);
        }
    }

BluetoothOppUtility.java

    public static void openReceivedFile(Context context, String fileName, String mimetype,
            Long timeStamp, Uri uri) {
            ...
            Intent activityIntent = new Intent(Intent.ACTION_VIEW);
            activityIntent.setDataAndTypeAndNormalize(path, mimetype);
            activityIntent.setDataAndType(path, mimetype);

            List<ResolveInfo> resInfoList = context.getPackageManager()
                    .queryIntentActivities(activityIntent, PackageManager.MATCH_DEFAULT_ONLY);

            activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            activityIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            context.startActivity(activityIntent);
            ...
   }                                                        
            

上面的过程就是bluetooth 应用调用系统ACTION_VIEW来显示图片的过程。
最后打开图片的应用是google photo
photo 再加载图片时,做了优化。

1.首先加载指定uri 图片的缩略图
2.等待图片加载完成后,再刷新view。

上面的步骤就造成了,图片加载过程会抖动的问题。

问题解决

1.可以使用平台的gallery 应用来打开图片。

	    Intent activityIntent = new Intent(Intent.ACTION_VIEW);
	    activityIntent.setDataAndTypeAndNormalize(path, mimetype);
	    activityIntent.setDataAndType(path, mimetype);
	    activityIntent.setPackage("org.codeaurora.gallery");//modify 
            //List<ResolveInfo> resInfoList = context.getPackageManager()
            //        .queryIntentActivities(activityIntent, PackageManager.MATCH_DEFAULT_ONLY);    
    

结论

google photo 不知上述情况有问题,所以的加载图片都由此问题,问题并不明显。

发布了376 篇原创文章 · 获赞 40 · 访问量 46万+

猜你喜欢

转载自blog.csdn.net/wangjicong_215/article/details/104040549