views:

728

answers:

1

hey! I have a question about an intent... I try to launch the sms app...

Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setType("vnd.android-dir/mms-sms");
        int flags =
              Intent.FLAG_ACTIVITY_NEW_TASK |
              Intent.FLAG_ACTIVITY_SINGLE_TOP |
              Intent.FLAG_ACTIVITY_CLEAR_TOP;
            intent.setFlags(flags);
        intent.setData(Uri.parse("content://sms/inbox"));
        context.startActivity(intent);

so, you can see that I put too much things in my intent, but that's because I don't know how I can do... Thank's

+1  A: 

To start launch the sms activity all you need is this:

Intent sendIntent = new Intent(Intent.ACTION_VIEW);         
sendIntent.setData(Uri.parse("sms:"));

You can add extras to populate your own message and such like this

sendIntent.putExtra("sms_body", x); 

then just startActivity with the intent.

jqpubliq
I tried, but when I write exactly what you give, eclipse console return (when compiling) "No Launcher activity found!"
Olivier69
The button don't work on the emulator
Olivier69
is it a warning or an error?
jqpubliq
okay, do you have an activity with the following attributes in its intent filter in your manifest? <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
jqpubliq
in fact, the launch come from an appwidgetactivity. Perh'aps it coms from here, I put what you've done in the manifest and nothing happen... I have test my button with an other function et this one don't want to go!!
Olivier69
I correct myself, I am in a widget, logcat want me to put FLAG_ACTIVITY_NEW_TASK flag... but I don't no where, can you help me?
Olivier69
Sorry, I understood what I have to write:Intent sendIntent = new Intent(Intent.ACTION_VIEW);sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);sendIntent.setData(Uri.parse("sms:"));context.startActivity(sendIntent);But "sms:" permit me to write a new sms but I want to show sms/inbox. please help!
Olivier69
that I dont really know. My suggestion would be to check around to see if you can find the package or intent type to call. The mms client might be part of the available source.
jqpubliq