Attempting to provide an image for applications causing the intent GET_CONTET

I’ve been looking for a solution for quite some time, and I'm getting more and more upset.

I want my application to be able to provide content for other applications. For example: when using the GoogleMail application, you can add an attachment. A dialog box opens listing all applications that can provide the file for attachment. My application is already in the dialog box because I defined the action with a filter intent like this:

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

So, when you select my application, it starts its activity. This activity allows the user to select a photo and record it on an SD card. So far, so good. But how can I get it back correctly? Since the application in GoogleMail has never been created. I return it like this:

if(file!=null)
{
  Intent resultIntent=new Intent();
  resultIntent.setType("image/jpg");  

  Uri uri=Uri.fromFile(file);

  //uri=Uri.parse(uri.toString().replace("file", "content"));
  resultIntent.putExtra(Intent.EXTRA_STREAM, uri); 
  resultIntent.putExtra(Intent.EXTRA_UID, uri); 
  resultIntent.setData(uri);
  setResult(RESULT_OK, resultIntent);
  finish();
}

, - . , , , , .: (

+3
1

, , . , , .

+1

All Articles