launch sms application with an intent

2019-01-01 03:45发布

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

18条回答
梦该遗忘
2楼-- · 2019-01-01 03:53

You can open default sms App and pass details as below :
Note : If u want to send to many numbers, separate each number with ";" inside string

String mblNumVar = "9876543210;9123456789";
Intent smsMsgAppVar = new Intent(Intent.ACTION_VIEW);
smsMsgAppVar.setData(Uri.parse("sms:" +  mblNumVar));
smsMsgAppVar.putExtra("sms_body", "Hello Msg Tst Txt");
startActivity(smsMsgAppVar);

|Or| Use this function :

void openSmsMsgAppFnc(String mblNumVar, String smsMsgVar)
{
    Intent smsMsgAppVar = new Intent(Intent.ACTION_VIEW);
    smsMsgAppVar.setData(Uri.parse("sms:" +  mblNumVar));
    smsMsgAppVar.putExtra("sms_body", smsMsgVar);
    startActivity(smsMsgAppVar); 
}
查看更多
何处买醉
3楼-- · 2019-01-01 03:54

Use

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setClassName("com.android.mms", "com.android.mms.ui.ConversationList");
查看更多
千与千寻千般痛.
4楼-- · 2019-01-01 03:54

Sms Intent :

Intent intent = new Intent("android.intent.action.VIEW");
        /** creates an sms uri */
        Uri data = Uri.parse("sms:");
        intent.setData(data);
查看更多
残风、尘缘若梦
5楼-- · 2019-01-01 03:56
Intent eventIntentMessage =getPackageManager()
 .getLaunchIntentForPackage(Telephony.Sms.getDefaultSmsPackage(getApplicationContext));
startActivity(eventIntentMessage);
查看更多
时光乱了年华
6楼-- · 2019-01-01 03:56

I use:

Intent sendIntent = new Intent(Intent.ACTION_MAIN);
sendIntent.putExtra("sms_body", "text");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
查看更多
情到深处是孤独
7楼-- · 2019-01-01 03:57

If you want to launch SMS Composing activity from some of your other activity and you also have to pass a phone number and SMS text, then use this code:

Uri sms_uri = Uri.parse("smsto:+92xxxxxxxx"); 
Intent sms_intent = new Intent(Intent.ACTION_SENDTO, sms_uri); 
sms_intent.putExtra("sms_body", "Good Morning ! how r U ?"); 
startActivity(sms_intent); 

Note: here the sms_body and smsto: is keys for recognizing the text and phone no at SMS compose activity, so be careful here.

查看更多
登录 后发表回答