Android 消息将不会发送到手机

Android 消息将不会发送到手机,android,Android,在这段代码中,当我单击按钮发送消息时,它没有显示任何响应。另外,任何人都可以告诉当点击一个按钮,它将只发送一个确认信息到特定的号码。我没有要求发送消息。我要求留言提醒。有什么办法吗,请帮我更新一下 send.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sendSms("9500518057","message"); } private void sendSms

在这段代码中,当我单击按钮发送消息时,它没有显示任何响应。另外,任何人都可以告诉当点击一个按钮,它将只发送一个确认信息到特定的号码。我没有要求发送消息。我要求留言提醒。有什么办法吗,请帮我更新一下

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);
    }
});

我认为您在apps manifest.xml文件上声明了权限

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);

     }
});


这将打开新消息提示,但是我要求发送消息警报而不询问任何提示您是否在androidmanifest.xml文件中启用了用户权限使用通知管理器发送消息后您可以显示
Toast
AlertBox
。@Madhavi如何使用通知管理器请查看此链接是否可以帮助您。。。。。我发布了代码,检查一下
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);

     }
});
<uses-permission android:name="android.permission.SEND_SMS" />