2

试图观察 - 当我点击确定按钮(删除)时,应用程序是否被删除它返回结果代码 0 取消与取消按钮相同

 activityResultLaunch = registerForActivityResult(
new  ActivityResultContracts.StartActivityForResult(),
 new ActivityResultCallback<ActivityResult>() {
                   @Override
                   public void onActivityResult(ActivityResult result) {
                       if (result.getResultCode() == RESULT_OK) {
                           Log.d("tag", "ok");
                       }
                       else if(result.getResultCode() == RESULT_CANCELED){
                           Log.d("tag", "cancelled");
                       }
                       else if(result.getResultCode() == RESULT_FIRST_USER){

                           Log.d("tag", "uninstallfail");
                       }
                   }
               });
        Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, uri);

        activityResultLaunch.launch(uninstallIntent);
4

0 回答 0