Well, yesterday I tested something I thought would not work... but it
worked.
If at this code:
1: Intent i = new Intent(Intent.ACTION_SEND);
2: i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
5: startActivity(i);
You add at least that lines before starting activity:
3: i.setType("image/jpg");
4: i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/Pictures/
image.jpg"));
It will work.
Why? This is now my question
Anyway, I wanted to add an image at the message, but.... if I
wouldn't?
Thanks again :)
On 17 jul, 12:52, Luc <[email protected]> wrote:
> Hi all AndroidDev (begginers and not so begginers) !
>
> I've tested separated two diferent projects that once I've merged
> doesn't work.
> 1. In one side, a BroadcastReciever listens for a SMS and gets the
> phone number of the sender, and starts a Service.
> The application works until here.
> 2. In other side, the Service should create an Intent to start the
> Email native application, but it doesn't work. In the previously
> project test this Intent was created by an Activity and worked
> perfectly.
>
> This code >>
> 1: Intent i = new Intent(Intent.ACTION_SEND);
> 2: i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
> 3: startActivity(Intent.createChooser(i, "Email file"));
>
> Throws < 07-17 12:01:20.759: ERROR/AndroidRuntime(2630): Caused by:
> android.util.AndroidRuntimeException: Calling startActivity() from
> outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK
> flag. Is this really what you want? >
> But the setFlags is already in the code.
>
> Moreover, if in line 3 I put >>
> 3: startActivity(i);
>
> Throws < 07-17 12:27:28.199: ERROR/AndroidRuntime(3237): Caused by:
> android.content.ActivityNotFoundException: No Activity found to handle
> Intent { action=android.intent.action.SEND flags=0x10000000 } >
>
> Finally, if I code the next on the other hand >>
> 1: Intent i = new Intent(Intent.ACTION_VIEW);
> 2: i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
> 3: startActivity(i);
>
> Where is the problem? A manifest one?
>
> Thanks to all
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---