mardi 5 mai 2015

Sending Image via Intent.ACTION_SENDTO

I tried to send gif file with Intent.Action_SEND and it works perfectly here

   Uri fileUri = Uri.fromFile(file);
        Log.d(TAG, " PATH : "+ fileUri.toString());
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        shareIntent.setType("*/*");
        shareIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
        Intent new_intent = Intent.createChooser(shareIntent, "Share via");
        new_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        getApplicationContext().startActivity(new_intent);    

Now I wish to do the same but with Intent.ACTION_SENDTO to send it to current windows. For example I am writing to my friend on hangouts and I wish to share my gif without having to pick application and user that will get it.

As far as I understand code would be similar something like

      Uri fileUri = Uri.fromFile(file);
        Log.d(TAG, " PATH : "+ fileUri.toString());
        Intent shareIntent = new Intent(Intent.ACTION_SENDTO);
        shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        shareIntent.setType("*/*");
        shareIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
        getApplicationContext().startActivity(shareIntent);    

Thanks in advance I am really stuck on this one.

Aucun commentaire:

Enregistrer un commentaire