screen rotation android source code
Hello Guys. Welcome to our new tutorial of android screen rotation using android studio. simple click button for change screen
Read MoreOnline Education
Hello Guys. Welcome to our new tutorial of android screen rotation using android studio. simple click button for change screen
Read MoreHello Guys. Welcome to our new tutorial of audio recorder android source code example using android studio. using this source
Read MoreHello Guys. Welcome to our new tutorial of android popup menu example using android studio. basically android pop up menu shows
Read MoreHello Guys. Welcome to our new tutorial of how to create option menu in android studio. option menu are the
Read MoreHello android developer. in this article, you will learn how to set an image as wallpaper in android studio using
Read MoreHello Guys. Welcome to our new tutorial of ImageSwitcher Tutorial With Example In Android Studio.basically imageswitcher is used to smooth
Read MoreJAVA (MainActivity.java)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.telephony.SmsManager; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import android.Manifest; import android.content.pm.PackageManager; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import com.tutorial.personal.androidstudiopro.R; public class SendSMSactivity extends AppCompatActivity { private static final int MY_PERMISSIONS_REQUEST_SEND_SMS =0 ; Button send; EditText mobilenumber; EditText txtMessage; String phoneNo; String message; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_send_smsactivity); send = (Button) findViewById(R.id.btnSendSMS); mobilenumber = (EditText) findViewById(R.id.editText); txtMessage = (EditText) findViewById(R.id.editText2); send.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { sendSMSMessage(); } }); } protected void sendSMSMessage() { phoneNo = mobilenumber.getText().toString(); message = txtMessage.getText().toString(); if (ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.SEND_SMS)) { } else { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.SEND_SMS}, MY_PERMISSIONS_REQUEST_SEND_SMS); } } } @Override public void onRequestPermissionsResult(int requestCode,String permissions[], int[] grantResults) { switch (requestCode) { case MY_PERMISSIONS_REQUEST_SEND_SMS: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(phoneNo, null, message, null, null); Toast.makeText(getApplicationContext(), "SMS sent.", Toast.LENGTH_LONG).show(); } else { Toast.makeText(getApplicationContext(), "SMS faild, please try again.", Toast.LENGTH_LONG).show(); return; } } } } } |
XML (activity_main.xml)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" > <EditText android:id="@+id/editText" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:hint="Enter Phone Number" android:phoneNumber="true" app:layout_constraintBottom_toTopOf="@+id/editText2" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <EditText android:id="@+id/editText2" android:layout_width="match_parent" android:layout_height="212dp" android:layout_below="@+id/editText" android:layout_alignStart="@+id/editText" android:layout_alignLeft="@+id/editText" android:hint="Enter SMS" app:layout_constraintBottom_toTopOf="@+id/btnSendSMS" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/editText" /> <Button android:id="@+id/btnSendSMS" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/editText2" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:text="Send Sms" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/editText2" /> </android.support.constraint.ConstraintLayout> |
1 |
JAVA (MainActivity.java)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.content.Intent; import android.view.View; import android.widget.Button; import android.widget.EditText; public class SendEmail extends AppCompatActivity { private EditText eTo; private EditText eSubject; private EditText eMsg; private Button btn; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_send_email); eTo = (EditText)findViewById(R.id.txtTo); eSubject = (EditText)findViewById(R.id.txtSub); eMsg = (EditText)findViewById(R.id.txtMsg); btn = (Button)findViewById(R.id.btnSend); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent it = new Intent(Intent.ACTION_SEND); it.putExtra(Intent.EXTRA_EMAIL, new String[]{eTo.getText().toString()}); it.putExtra(Intent.EXTRA_SUBJECT,eSubject.getText().toString()); it.putExtra(Intent.EXTRA_TEXT,eMsg.getText()); it.setType("message/rfc822"); startActivity(Intent.createChooser(it,"Choose Mail App")); } }); } } |
XML (activity_main.xml)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="20dp" android:paddingRight="20dp" android:orientation="vertical" > <EditText android:id="@+id/txtTo" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="To" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <EditText android:id="@+id/txtSub" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:hint="Subject" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/txtTo" /> <EditText android:id="@+id/txtMsg" android:layout_width="match_parent" android:layout_height="280dp" android:layout_marginTop="8dp" android:layout_weight="1" android:gravity="top" android:hint="Message" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/txtSub" /> <Button android:id="@+id/btnSend" android:layout_width="100dp" android:layout_height="wrap_content" android:layout_gravity="right" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:text="Send" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/txtMsg" /> </android.support.constraint.ConstraintLayout> |
Hello Guys. Welcome to our new tutorial available Android Sensor Tutorial using android studio. this source code will help you
Read MoreHello Guys. Welcome to our new tutorial of how to share app link in android programmatically using android studio. this article
Read More