我正在开发一个图像编辑器。
当我在画廊时,我想编辑我的照片。我按下编辑按钮,一些编辑器出现,android要求我选择。我选择了我的编辑器,但我的应用程序没有显示ImageView
中的图片。 ACTION_VIEW
也不起作用。我不想使用ACTION_SEND
。你有代码可以帮助我吗?
<activity
android:name=".Insta"
android:label="@string/title_activity_instag"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize" >
<intent-filter android:label="عکس کامل اینستاگرام" >
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
Intent receivedIntent = getIntent();
//get the action
String receivedAction = receivedIntent.getAction();
Uri uri2 = getIntent() != null ? getIntent().getData() : null;
if(receivedAction.equals(Intent.ACTION_SEND)){
//content is being shared
//get the uri of the received image
Uri receivedUri = (Uri)receivedIntent.getParcelableExtra(Intent.EXTRA_STREAM);
if (receivedUri != null) {
//set the picture
//RESAMPLE YOUR IMAGE DATA BEFORE DISPLAYING
img.setImageURI(receivedUri);//just for demonstration
}
}
if(receivedAction.equals(Intent.ACTION_EDIT)){
img.setImageResource(R.drawable.bg4);
//content is being shared
//get the uri of the received image
if (uri2 != null) {
//set the picture
//RESAMPLE YOUR IMAGE DATA BEFORE DISPLAYING
img.setImageURI(uri2);//just for demonstration
}else{}
}
if(uri2.equals(Intent.ACTION_VIEW)){
//content is being shared
//get the uri of the received image
if (uri2 != null) {
//set the picture
//RESAMPLE YOUR IMAGE DATA BEFORE DISPLAYING
img.setImageURI(uri2);//just for demonstration
}else{}
}else{}
}