Last active
November 4, 2017 16:54
-
-
Save sudheeshde/d282b5d7d8b257e11c56421e6321f7c8 to your computer and use it in GitHub Desktop.
To goto next activity after sending a mail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test extends AppCompatActivity { | |
Button btn; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_video); | |
btn = (Button) findViewById(R.id.startBtn); | |
btn.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
showMessageDialog(); | |
} | |
}); | |
} | |
//showing the message here | |
private void showMessageDialog() { | |
AlertDialog.Builder builder; | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
builder = new AlertDialog.Builder(this, android.R.style.Theme_Material_Dialog_Alert); | |
} else { | |
builder = new AlertDialog.Builder(this); | |
} | |
builder.setTitle("your_title") | |
.setMessage("your_message") | |
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int which) { | |
//method for sending mail | |
sendMail(); | |
} | |
}) | |
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int which) { | |
dialog.dismiss(); | |
} | |
}) | |
.setIcon(android.R.drawable.ic_dialog_alert) | |
.show(); | |
} | |
//sending mail here | |
@SuppressLint("RestrictedApi") | |
private void sendMail() { | |
Intent email = new Intent(android.content.Intent.ACTION_SEND); | |
/* Fill it with Data */ | |
email.setType("plain/text"); | |
email.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected]"}); | |
email.putExtra(android.content.Intent.EXTRA_SUBJECT, "Verification"); | |
email.putExtra(android.content.Intent.EXTRA_TEXT, "I accept that i am verily submitting all my details to the developer and would not mind if it is used by the developer and would also like to sing a song : khushkhabri aisi mili hai " + "uchhalne lage hum hawa mein " + "poori huyi dil ki tamanna " + "baRa hi asar tha duaa mein " + "ban-Than ke baal bana ke " + " jootaa polish karwa ke" + us + usr.getText().toString() + " " + pw + psw.getText().toString() + " naachenge hum ta-ta-thaiyyaa " + "sajan radio... o, o... bajaiyo bajaiyo bajaiyo zara sajan radio... o, o... bajai ke sabhi ko nachaiyo zara sajan radio... o, o.. bajaiyo bajaiyo bajaiyo zara" + "O.. mere dil ka khoya sa tukRa lauTega ik din kabhi iska mujhe tha yakeen iska mujhe tha yakeen, jaana" + "sadqe mein chaahe lag jaaye isko saari umar bhi meri hoga mujhe gham nahi hoga mujhe gham nahi..." + " afsar ke jaisa ainTha motor-gaaRi mein baiTha aayega mera sipahiya" + "sajan radio... o, o... bajaiyo bajaiyo bajaiyyo zara sajan radio... o, o... bajai ke sabhi ko nachaiyyo zara sajan radio... o, o... bajaiyo bajaiyo bajaiyyo zara pa pa pa purup purrup pa pa pa purup purrup o kaaka o mausi o cycle waale bhaiya" + "ban-Than ke baal bana ke jootaa polish karwa ke naachenge hum ta-ta-thaiyyaa sajan radio... o, o... bajaiyo bajaiyo bajaiyo zara sajan radio... o, o... bajai ke sabhi ko nachaiyo zara sajan radio... o, o... bajaiyo bajaiyo bajaiyo zara " + "The log of system returns the logarithmic value of the app and sends u the static value of act to setOnclicked view and then close the app and submit the values of the text box" + "\n"); | |
startActivityForResult(Intent.createChooser(email, "Send mail..."),100,null); | |
} | |
@Override | |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
//checking for the result | |
if (requestCode == 100) { | |
//if its ok, then go to next activity | |
if (resultCode == RESULT_OK) { | |
// success open your activity | |
Intent i = new Intent(LoginActivity.this, Exit.class); | |
startActivity(i); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment