赢无翳
赢无翳
  • 发布:2024-11-20 18:11
  • 更新:2024-11-20 20:33
  • 阅读:76

UTSAndroid.onAppActivityResult没有执行是怎么回事呢?UTS调用AAR返回没有执行

分类:uts

这里是UTS代码

import Manifest from 'android.Manifest';  
import TargetApi from 'android.annotation.TargetApi';  
import Activity from 'android.app.Activity';  
import Intent from 'android.content.Intent';  
import PackageManager from 'android.content.pm.PackageManager';  
import Bitmap from 'android.graphics.Bitmap';  
import Uri from 'android.net.Uri';  
import AsyncTask from 'android.os.AsyncTask';  
import Build from 'android.os.Build';  
import Bundle from 'android.os.Bundle';  
import MediaStore from 'android.provider.MediaStore';  
import ActivityCompat from 'androidx.core.app.ActivityCompat';  
import FileProvider from 'androidx.core.content.FileProvider';  
import AppCompatActivity from 'androidx.appcompat.app.AppCompatActivity';  
import DisplayMetrics from 'android.util.DisplayMetrics';  
import Log from 'android.util.Log';  
import View from 'android.view.View';  
import ImageView from 'android.widget.ImageView';  
import Toast from 'android.widget.Toast';  
import R from 'uts.sdk.modules.fzImageEdit.R';  

import EditImageActivity from 'com.xinlan.imageeditlibrary.editimage.EditImageActivity';  
import BitmapUtils from 'com.xinlan.imageeditlibrary.editimage.utils.BitmapUtils';  

import File from 'java.io.File';  

export class RHFimage {  
    static getEdit(options : UTSJSONObject, callback : (res: UTSJSONObject ) => void) {  
    let ACTION_REQUEST_EDITIMAGE:Int = 9;  
    let path = options['path'] as string;  
     console.log(path)  
    let outputFile:File = new FileUtils.genEditFile();  
    let savepath = outputFile.getAbsolutePath()  
    console.log(savepath)  
    EditImageActivity.start(UTSAndroid.getUniActivity()!.startActivityForResult,path,savepath,ACTION_REQUEST_EDITIMAGE);  

}  
 }  
 UTSAndroid.onAppActivityResult((requestCode: Int, resultCode: Int, data?: Intent) => {  
     console.log("测试数据")  
     console.log(data)  
     console.log(requestCode)  
     console.log(resultCode)  
    // super.onAppActivityResult(requestCode, resultCode, data);  
    // if(requestCode == RESULT_OK){  
    //   handleEditorImage(data as Intent);  
    // }else{  
        // console.log("保存失败")  
    //  // 别的代码发起的请求,不要处理  
    // }  

 });

下面是JAVA代码:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
// System.out.println("RESULT_OK");
switch (requestCode) {
case SELECT_GALLERY_IMAGE_CODE://
handleSelectFromAblum(data);
break;
case TAKE_PHOTO_CODE://拍照返回
handleTakePhoto(data);
break;
case ACTION_REQUEST_EDITIMAGE://
handleEditorImage(data);
break;
}// end switch
}
}

2024-11-20 18:11 负责人:无 分享
已邀请:
DCloud_Android_DQQ

DCloud_Android_DQQ

应该是 startActivityForResult

参考 hello uts 调用系统相机的示例:

https://gitcode.net/dcloud/hello-uts/-/blob/master/uni_modules/uts-advance/utssdk/app-android/index.uts

  • 赢无翳 (作者)

    EditImageActivity.start类里已经封装了startActivityForResult了怎么办呢?EditImageActivity类是封装在AAR里的我看到EditImageActivity类里有这个方法public static void start(Activity context, final String editImagePath, final String outputPath, final int requestCode) {

    if (TextUtils.isEmpty(editImagePath)) {

    Toast.makeText(context, R.string.no_choose, Toast.LENGTH_SHORT).show();

    return;

    }


        Intent it = new Intent(context, EditImageActivity.class);  
    it.putExtra(EditImageActivity.FILE_PATH, editImagePath);
    it.putExtra(EditImageActivity.EXTRA_OUTPUT, outputPath);
    context.startActivityForResult(it, requestCode);
    }

    2024-11-20 20:31

赢无翳

赢无翳 (作者) - 学无止境

public class EditImageActivity extends BaseActivity {  
    public static final String FILE_PATH = "file_path";  
    public static final String EXTRA_OUTPUT = "extra_output";  
    public static final String SAVE_FILE_PATH = "save_file_path";  

    public static final String IMAGE_IS_EDIT = "image_is_edit";  

    public static final int MODE_NONE = 0;  
    public static final int MODE_STICKERS = 1;// 贴图模式  
    public static final int MODE_FILTER = 2;// 滤镜模式  
    public static final int MODE_CROP = 3;// 剪裁模式  
    public static final int MODE_ROTATE = 4;// 旋转模式  
    public static final int MODE_TEXT = 5;// 文字模式  
    public static final int MODE_PAINT = 6;//绘制模式  
    public static final int MODE_BEAUTY = 7;//美颜模式  

    public String filePath;// 需要编辑图片路径  
    public String saveFilePath;// 生成的新图片路径  
    private int imageWidth, imageHeight;// 展示图片控件 宽 高  
    private LoadImageTask mLoadImageTask;  

    public int mode = MODE_NONE;// 当前操作模式  

    protected int mOpTimes = 0;  
    protected boolean isBeenSaved = false;  

    private EditImageActivity mContext;  
    private Bitmap mainBitmap;// 底层显示Bitmap  
    public ImageViewTouch mainImage;  
    private View backBtn;  

    public ViewFlipper bannerFlipper;  
    private View applyBtn;// 应用按钮  
    private View saveBtn;// 保存按钮  

    public StickerView mStickerView;// 贴图层View  
    public CropImageView mCropPanel;// 剪切操作控件  
    public RotateImageView mRotatePanel;// 旋转操作控件  
    public TextStickerView mTextStickerView;//文本贴图显示View  
    public CustomPaintView mPaintView;//涂鸦模式画板  

    public CustomViewPager bottomGallery;// 底部gallery  
    private BottomGalleryAdapter mBottomGalleryAdapter;// 底部gallery  
    private MainMenuFragment mMainMenuFragment;// Menu  
    public StickerFragment mStickerFragment;// 贴图Fragment  
    public FilterListFragment mFilterListFragment;// 滤镜FliterListFragment  
    public CropFragment mCropFragment;// 图片剪裁Fragment  
    public RotateFragment mRotateFragment;// 图片旋转Fragment  
    public AddTextFragment mAddTextFragment;//图片添加文字  
    public PaintFragment mPaintFragment;//绘制模式Fragment  
    public BeautyFragment mBeautyFragment;//美颜模式Fragment  
    private SaveImageTask mSaveImageTask;  

    private RedoUndoController mRedoUndoController;//撤销操作  

    /**  
     * @param context  
     * @param editImagePath  
     * @param outputPath  
     * @param requestCode  
     */  
    public static void start(Activity context, final String editImagePath, final String outputPath, final int requestCode) {  
        if (TextUtils.isEmpty(editImagePath)) {  
            Toast.makeText(context, R.string.no_choose, Toast.LENGTH_SHORT).show();  
            return;  
        }  

        Intent it = new Intent(context, EditImageActivity.class);  
        it.putExtra(EditImageActivity.FILE_PATH, editImagePath);  
        it.putExtra(EditImageActivity.EXTRA_OUTPUT, outputPath);  
        context.startActivityForResult(it, requestCode);  
    }  

要回复问题请先登录注册