In the manifest filter is registered:

<intent-filter> <action android:name="android.intent.action.SEND"/> <category android:name="android.intent.category.DEFAULT"/> <data android:mimeType="image/*"/> </intent-filter> 

OnCreate:

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if( Intent.ACTION_SEND.equals( getIntent().getAction().toString() ) ){ ImageView image = ( ImageView )findViewById( R.id.imageView ); image.setImageURI( ( Uri )getIntent().getExtras().get( Intent.EXTRA_STREAM ) ); } } 

But it does not work. Run on Android 4.0. Just open, or open through a sample of possible applications when sending an image - there is no difference. Changed the string

 image.setImageURI( ( Uri )getIntent().getExtras().get( Intent.EXTRA_STREAM ) ); 

On

 image.setImageResource( R.drawable.ic_launcher ); 

And it works accordingly. Those. the question is that I am not pulling the image out of the external flow correctly? If so, how to pull it out correctly?

Thanks for attention.

  • gave the right to the Internet? is the picture coming? You need to debug - Gorets
  • Internet is not used. The picture is already on the device. I open the picture, go to the menu, send it to the application, select my application. Just as you can send to VK, BlogSpot etc + MyApplication - Alexey Danchin
  • And cho wanted that? Not quite clear what you want? - Barmaley
  • You click on a photo, click to send it to such an application, you select your application and this image is displayed there. - Alexey Danchin
  • Then why ACTION_SEND ? Need ACTION_VIEW - Barmaley


1 answer 1

Specified where would you try to send ... If you need to open a picture in your application from any file manager - then everything is trivial:

  <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <data android:mimeType="*/*"/> </intent-filter> image.setImageURI(getIntent().getData()); 
  • Yeah, that's exactly the way it should be - Barmaley