main activity
package com.example.lenovo.sms;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
Button gonder;
EditText telno,mesaj;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final EditText mesaj=findViewById(R.id.editText2);
final EditText telno=findViewById(R.id.editText);
Button gonder=findViewById(R.id.button);
gonder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
android.telephony.SmsManager smsManager=android.telephony.SmsManager.getDefault(); smsManager.sendTextMessage(telno.getText().toString(),null,mesaj.getText().toString(),null,null); telno.setText("");
mesaj.setText("");
}
});
}
}
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lenovo.sms">
<uses-permission android:name="android.permission.SEND_SMS"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android