Date post: | 14-Apr-2017 |
Category: |
Documents |
Upload: | eman-magdy |
View: | 212 times |
Download: | 2 times |
what is Message delayer ?!
Its an android application that make user to send message after a small delay that can
make the user easy to send a message during his meeting or
while driving…etc.
Choose a blank activity to work on and click next then you can find these window to rename your activity
Click here to write the code
Insert component
APP GUI Your java project
Click here to show GUI code
Click here to show Xml file
GUI Code file
Text field you can choose up to what you want to write on it
Widgets to make a text to
put like an outline
In the layout we can put name to every view we use like (text ,text field,button,…etc.) and although we can give it an ID to make it easy to get to it when want to use it
final Button sender = (Button) findViewById(R.id.button1); final EditText no= (EditText) findViewById(R.id.tn); final EditText msg = (EditText) findViewById(R.id.tm); final EditText delay = (EditText) findViewById(R.id.ed); sender.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Runnable clickButton = new Runnable() { @Override public void run() { SmsManager manager=SmsManager.getDefault(); String message=msg.getText().toString(); String number=no.getText().toString(); manager.sendTextMessage(number, null, message, null, null); Toast.makeText(getApplicationContext(), "send succesfully", Toast.LENGTH_LONG).show(); } }; int v1= Integer.parseInt(delay.getText().toString()) ; sender.postDelayed(clickButton, v1*1000); //Delay for v seconds to show the result }});
To get ids of layout As variable to use it in code
This a function that happen When click on Button
Code of access message
Toast is function to show Message to user
Number to send it message Note : it is string
Your message string
Delay variable
Delay in seconds
This file to add permissions to access Android services
Open it to add message access permission In our case
Important