send.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
sendSms("9500518057","message");
}
private void sendSms(String phno, String message) {
// TODO Auto-generated method stub
Log.v("PhoneNumber",phno);
Log.v("MEssage", message);
PendingIntent pi=PendingIntent.getActivity(mContext, 0, new Intent(mContext, Object.class), 0);
SmsManager sms=SmsManager.getDefault();
sms.sendTextMessage(phno, null, message, pi, null);
}
});
在此代码中,当我点击按钮发送消息时,它没有显示任何响应。也可以任何人在点击按钮时告诉它只发送确认消息到特定号码。我没有要求发送消息。我要求提供信息提醒。有什么方法,请帮帮我
答案 0 :(得分:0)
更新
SmsManager sm = SmsManager.getDefault();
sm.sendTextMessage(destinationAddress, null, "Hello world", null, null, null);
答案 1 :(得分:0)
Use this code
private static final int SIMPLE_NOTFICATION_ID = 0;
private NotificationManager mNotificationManager;
send.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
final Notification notifyDetails = new Notification(R.drawable.ic_launcher, "New Alert, Click Me!",
System.currentTimeMillis());
Context context = getApplicationContext();
CharSequence contentTitle = "Open App";
CharSequence contentText = "hi";
Intent notifyIntent = new Intent(getApplicationContext(), YourActivity.class);
PendingIntent intent = PendingIntent.getActivity(YourActivity.this,0,notifyIntent,android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
notifyDetails.setLatestEventInfo(context,contentTitle, contentText, intent);
mNotificationManager.notify(SIMPLE_NOTFICATION_ID,notifyDetails);
}
});
答案 2 :(得分:0)
我认为您在应用程序manifest.xml文件中声明了权限,
<uses-permission android:name="android.permission.SEND_SMS" />