Not sure if this is know behavior or what, but here's the logical flow:
onResume() is not called, neither is onActivityResult(). I even commented out all the code in onActivityResult and it still happens. Any ideas what would cause this?
Here is code from onCreate() in the main activity
ImageButton profilePictureButton = (ImageButton) findViewById(R.id.change_profile_picture);
profilePictureButton.requestFocus();
profilePictureButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, 1);
}
});
And here's the handler:
@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
if(resultCode == RESULT_OK) {
if(requestCode == 1) {
ImageView view = ((ImageView) findViewById(R.id.nav_profile_picture));
if(data != null) {
/*Picasso.with(this).load(data.getData()).into(view);
UsersCache.getInstance().GetUser("", new Response.Listener<UserItem>() {
@Override
public void onResponse(UserItem response) {
String pictureName = response.username + UUID.randomUUID().toString();
String url = "<redacted>";
JSONObject requestBody = new JSONObject();
try {
requestBody.put("profilePicture", "<redacted>/media/profile_pictures/" + pictureName);
} catch(JSONException e) {
e.printStackTrace();
return;
}
FlareJsonObjectRequest request = new FlareJsonObjectRequest(Method.POST, url, requestBody, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
String tet = null;
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
String tet = null;
}
});
new AmazonS3Uploader(data.getData(), "profile_pictures/" + pictureName);
VolleyQueue.getInstance().getQueue().add(request);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
String tet = null;
}
});*/
}
}
我认为您缺少清单中的读取访问权限-
android:name="android.permission.READ_EXTERNAL_STORAGE" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.