Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.student.newone;
- import android.content.Intent;
- import android.net.Uri;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.Toast;
- import com.example.student.newone.actiivity.LoginPage;
- public class MainActivity extends AppCompatActivity {
- Button btnLoginPage,btnCamera,btnDial,btnURL;
- EditText editText;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- initCompoments();
- setComponents();
- }
- private void initCompoments() {
- editText = (EditText) findViewById(R.id.edtText);
- btnLoginPage = (Button) findViewById(R.id.btnGotoLogin);
- btnCamera=(Button)findViewById(R.id.btnCamera);
- btnURL=(Button)findViewById(R.id.btnURL);
- btnDial=(Button)findViewById(R.id.btnDial);
- }
- private void setComponents() {
- btnLoginPage.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Toast.makeText(MainActivity.this, "Click", Toast.LENGTH_SHORT).show();
- Intent intent = new Intent(MainActivity.this, LoginPage.class);
- intent.putExtra("TAG_NAME",editText.getText().toString());
- startActivity(intent);
- }
- });
- btnDial.setOnClickListener(v->{
- Uri uri= Uri.parse("tel:+38971458777");
- Intent intent=new Intent(Intent.ACTION_DIAL,uri);
- if(intent.resolveActivity(getPackageManager())!=null) {
- startActivity(intent);
- }
- });
- btnCamera.setOnClickListener(v->
- {
- Intent intents=new Intent("android.media.action.IMAGE_CAPTURE");
- if(intents.resolveActivity(getPackageManager())!=null) {
- startActivity(intents);
- }
- }
- );
- btnURL.setOnClickListener(v->
- {
- Uri uris=Uri.parse();
- Intent int=new Intent(Intent.ACTION_VIEW,uris);
- if(int.resolveActivity(getPackageManager())!=null) {
- startActivity(int);
- }
- }
- );
- }
- }
- Login_PAGE
- package com.example.student.newone.actiivity;
- import android.os.Bundle;
- import android.support.annotation.Nullable;
- import android.support.v7.app.AppCompatActivity;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.Toast;
- import com.example.student.newone.MainActivity;
- import com.example.student.newone.R;
- /**
- * Created by Student on 2/21/2018.
- */
- public class LoginPage extends AppCompatActivity {
- Button btn;
- EditText edtUserName,edtUserPassword;
- @Override
- protected void onCreate( Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.login_page);
- initComponents();
- setComponents();
- }
- private void initComponents()
- {
- edtUserName=(EditText) findViewById(R.id.edtUserName);
- edtUserPassword=(EditText)findViewById(R.id.edtUserPassword);
- btn=(Button) findViewById(R.id.btnGoBack);
- }
- private void setComponents() {
- Bundle bundle=getIntent().getExtras();
- if(bundle!=null ){
- String text=bundle.getString("TAG_NAME");
- edtUserName.setText(text);
- // Toast.makeText(this,text,Toast.LENGTH_SHORT).show();
- btn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- onBackPressed();
- }
- });
- }
- }
- @Override
- public void onBackPressed() {
- super.onBackPressed();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement