我正在尝试通过从手机的图片库中选择图片来上传图片。但是选择它后根本不执行任何操作,甚至不上传它。我已经尝试了干净的构建并重新构建仍然没有帮助。它只是通过说出以下内容自动断开连接:V / FA:正在进行连接尝试D / FA:已连接到远程服务V / FA:正在处理排队的服务任务:2 V / FA:不活动,正在与服务断开连接public class MainActivity extends AppCompatActivity { Button uploadButton; ImageView downloadedImage; private static final int CAMERA_REQUEST_CODE=1; private StorageReference storageReference; //private ProgressDialog progressDialog; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); uploadButton = findViewById(R.id.button); downloadedImage = findViewById(R.id.imageView); storageReference = FirebaseStorage.getInstance().getReference(); //progressDialog = new ProgressDialog(this); uploadButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); startActivityForResult(intent,CAMERA_REQUEST_CODE); Log.i("Done","Till here"); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode == CAMERA_REQUEST_CODE && requestCode == RESULT_OK) { Log.i("Not Done","This log is not visible");我得到的错误是:I / art:拒绝对先前失败的类java.lang.Class:java.lang.NoClassDefFoundError进行重新初始化:无法解决以下问题:Landroid / view / View $ OnUnhandledKeyEventListener;
1 回答
![?](http://img1.sycdn.imooc.com/54584ee0000179f302200220-100-100.jpg)
隔江千里
TA贡献1906条经验 获得超10个赞
在&&之后将requestCode更改为resultCode,它将起作用。
if(requestCode == CAMERA_REQUEST_CODE && resultCode == RESULT_OK)
{
}
添加回答
举报
0/150
提交
取消