简体   繁体   English

如何发送将在Android屏幕上弹出的短信?

[英]How to send SMS that will pop up on screen in Android?

是否可以这样做,当我发送SMS时,它会在屏幕上弹出/提示,以便使用此消息可以很容易地提醒接收者。

You can use following customized method to send SMS, 您可以使用以下自定义方法发送短信,

public static void sendsms( String address,String msgContent )
{
    try
    {
        SmsManager sms = SmsManager.getDefault();
        ArrayList<String> smsString = sms.divideMessage(msgContent); 
        sms.sendMultipartTextMessage(address, null, smsString, null, null);
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
}

and use following code to display AlertDialog, 并使用以下代码显示AlertDialog,

// Sending SMS 
sendSMS ( "9898989898","hello this is sms" );

// showing alertdialog
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle( "SMS" );
alertDialog.setMessage( "Sending SMS" );
alertDialog.setButton( "OK", getDialogListener());
alertDialog.show();

您可以使用广播接收器,并在收到新消息时显示通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM