当我选择图像时,我在没有任何通知的情况下阻止了我的应用程序退出,但是当我选择论坛照片或画廊时没有崩溃。我creativesdk
用于照片编辑。
package com.lamba.selfie;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.widget.ImageView;
import com.aviary.android.feather.sdk.AviaryIntent;
public class MainActivity extends AppCompatActivity {
private ImageView mResultImageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mResultImageView = (ImageView) findViewById(R.id.resultImageView);
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), 0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
switch (requestCode) {
case 0:
Uri selectedImageUri = data.getData();
Uri imageUri = Uri.parse(getPath(selectedImageUri));
Intent imageEditorIntent = new AviaryIntent.Builder(this)
.setData(imageUri)
.build();
startActivity(imageEditorIntent);
/*case 1:
startActivityForResult(imageEditorIntent, 1);
Uri mImageUri = data.getData();
mResultImageView.setImageURI(mImageUri);
break;*/
}
}
}
public String getPath(Uri uri) {
// just some safety built in
if (uri == null) {
// TODO perform some logging or show user feedback
return null;
}
// try to retrieve the image from the media store first
// this will only work for images selected from gallery
String[] projection = {MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery(uri, projection, null, null, null);
if (cursor != null) {
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
// this is our fallback here
return uri.getPath();
}
}
我该如何解决?