implicit intent in android example
Create and Login application as above . On successful login , open browser with any URL.
File Name : E4Activity.java
package bsr.exa;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class E4Activity extends Activity {
/** @author Bipin S Rupadiya , www.gtu-android.blogspot.com
*
* 3) Create login application where you will have to validate EmailID(UserName).
* Till the user name and password is not validated , login button should remain disabled.
*
* 4) Create and Login application as above . On successful login , open browser with any URL.
*
**/
String uname="rupadiyabipin@gmail.com";
String pwd="bipin";
boolean usrStatus=false;
boolean pwdStatus=false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button cmdLogin = (Button) findViewById(R.id.cmdLogin);
final EditText txtUsr = (EditText)findViewById(R.id.txtUsr);
final EditText txtPwd = (EditText)findViewById(R.id.txtPwd);
cmdLogin.setEnabled(false);
cmdLogin.setOnClickListener(new Button.OnClickListener()
{
@Override
public void onClick(View v)
{
EditText fldu=(EditText)findViewById(R.id.txtUsr);
EditText fldp=(EditText)findViewById(R.id.txtPwd);
String un= fldu.getText().toString();
if((fldu.getText().toString().equals(uname))&&(fldp.getText().toString().equals(pwd)))
{
Uri myUri=Uri.parse("http://BipinRupadiya.blogspot.com");
Intent intent=new Intent(Intent.ACTION_VIEW,myUri);
startActivity(intent);
}
else
{
Toast.makeText(E4Activity.this, "sorry ".concat(un).toString().concat(" you are unauthenticated user! "), Toast.LENGTH_LONG).show();
}
}
});
//------------------------------------------------
//clear event
final Button btnClear = (Button)findViewById(R.id.cmdClear);
btnClear.setOnClickListener(new Button.OnClickListener()
{
@Override
public void onClick(View v)
{
EditText fldu=(EditText)findViewById(R.id.txtUsr);
EditText fldp=(EditText)findViewById(R.id.txtPwd);
fldu.setText("");
fldp.setText("");
}
});
//------------------------------------------------
txtUsr.addTextChangedListener(new TextWatcher()
{
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
if(uname.equals(txtUsr.getText().toString()))
{
usrStatus=true;
}
else
{
usrStatus=false;
}
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,int arg3) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
if(usrStatus && pwdStatus)
{
cmdLogin.setEnabled(true);
}
else
{
cmdLogin.setEnabled(false);
}
}
});
txtPwd.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
if(pwd.equals(txtPwd.getText().toString()))
{
pwdStatus=true;
}
else
{
pwdStatus=false;
}
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
if(usrStatus && pwdStatus)
{
cmdLogin.setEnabled(true);
}
else
{
cmdLogin.setEnabled(false);
}
}
});
}
}
Labels:
Android,
Mobile Computing
Subjects
- WordPress
- Mobile Computing-4649303 Practical Solution
- Android Programming New Syllabus Theory
- PHP LAMP Question Bank
- PHP LAMP Theory
- Step by Step Android Example
- Android Practical
- Android Theory
- Android Question Bank
- Networking FON Practical
- Networking FON Theory
- OS Practical
- OS Theory
- HTML
- JavaScript
- J2EE WTAD Theory
- J2EE WTAD Question Bank
- J2EE WTAD Quick Guide
- J2EE WTAD GTU Papers
- J2EE WTAD Practical
- Python
- JAVA Theory
- JAVA Practical
- MIS
Categories
- Android (55)
- c (11)
- Configure Tomcat7 (2)
- CSS (3)
- Decryption (16)
- Difference (1)
- Encryption (16)
- Error Detection and Correction Techniques (3)
- FON (27)
- Framing Technic (2)
- install Tomcat (2)
- J2EE (29)
- JAVA (13)
- JavaScript (19)
- linux (8)
- OS (17)
- PHP (11)
- Protocol (3)
- SERVER SOCKET PROGRAMING (7)
- Servlet (13)
- shell script (33)
- unix (22)
- WTAD (34)
Blog Archive
-
▼
2012
(79)
-
▼
September
(22)
- Chapter 7, Memory Management
- Chapter 6, Concurrency: Deadlock and Starvation
- Chapter 5, Concurrency: Mutual Exclusion and Sync...
- Chapter 4, Threads, SMP, and Micro kernels
- Chapter 3, Process Description and Control
- Chapter 2, Operating System Overview
- Chapter 1, Computer System Overview
- menu in android tutorial
- android animation example
- android chronometer example
- spinner in android example
- listview in android
- implicit intent in android example
- addTextChangedListener in Android example
- Be a Freelances and earn $$$$
- View SQLite Database
- Write a shell script to delete zero sized files fr...
- Android Intent Example
- Hello World in Android
- SQLite Android Tutorial
- Happy Teachers' Day
- Thank you GOD
-
▼
September
(22)
Total Pageviews
© BipinRupadiya.com. Powered by Blogger.