Saturday, 5 December 2015

ANDROID GUI ARCHITECTURE

Android GUI Architecture

The Android environment adds yet another Graphical User Interface (GUI) toolkit to the Java ecosphere, joining AWT, Swing, SWT, and J2ME (leaving aside the web UI toolkits). If you’ve worked with any of these, the Android framework will look familiar. Like them, it is single-threaded, event-driven, and built on a library of nestable components.
The Android UI framework is, like the other UI frameworks, organized around the common Model-View-Controller pattern illustrated in Figure. It provides structure and tools for building a Controller that handles user input (like key presses and screen taps) and a View that renders graphical information to the screen.


The Model
The Model is the guts of your application: what it actually does. It might be, for instance, the database of tunes on your device and the code for playing them. It might be your list of contacts and the code that places phone calls or sends IMs to them.


While a particular application’s View and Controller will necessarily reflect the Model they manipulate, a single Model might be used by several different applications. Think, for instance, of an MP3 player and an application that converts MP3 files into WAV files. For both applications, the Model includes the MP3 file format and codecs for it. The former application, however, has the familiar Stop, Start, and Pause controls, and plays the track. The latter may not produce any sound at all; instead, it will have controls for setting bitrate, etc. The Model is all about the data.

The View
The View is the application’s feedback to the user. It is the portion of the application responsible for rendering the display, sending audio to speakers, generating tactile feedback, and so on. The graphical portion of the Android UI framework’s View, is implemented as a tree of subclasses of the View class. Graphically, each of these objects represents a rectangular area on the screen that is completely within the rectangular area represented by its parent in the tree. The root of this tree is the application window.

The Controller
The Controller is the portion of an application that responds to external actions: a keystroke, a screen tap, an incoming call, etc. It is implemented as an event queue. Each external action is represented as a unique event in the queue. The framework removes each event from the queue in order and dispatches it.

Monday, 28 September 2015

HOW TO LOGIN


     
  • SIGN UP
  • SIGN IN
  • BACK

  • SUMEET 
  •  
     
     
     
     
    package com.sumeetmca;

    import android.os.Bundle;
    import android.app.Activity;
    import android.content.Intent;

    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.Toast;

    public class Login extends Activity implements OnClickListener{
    @Override
    public void onClick(View arg0) {
    // TODO Auto-generated method stub
    if (arg0.getId()==R.id.signin)
    {
    username=mail.getText().toString();
    password=paswd.getText().toString();
    if(username.equals("sumeet")&& password.equals("123"))
    {
    Toast toast=Toast.makeText(getApplicationContext(),"success",Toast.LENGTH_SHORT);
    toast.setMargin(50,50);
    toast.show();
    Intent aa=new Intent(getApplicationContext(), Welcome.class);
    startActivity(aa);
    finish();

    mail.setText("*******");
    paswd.setText("*******");

    }
    else
    {
    Toast.makeText(getApplicationContext(),"warning wrong password",Toast.LENGTH_SHORT).show();

    }}
    else
    {
    if(arg0.getId()==R.id.signup)
    {
    Toast.makeText(getApplicationContext(),"SORRY SIGNUP REGISTATION WAS CLOSED",Toast.LENGTH_SHORT).show();

    }
    else
    {
    finish();
    }
    }
    }





    Button cancel,sigin,signup;
    String username,password;
    EditText mail,paswd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    cancel=(Button) findViewById(R.id.cancel);
    sigin=(Button) findViewById(R.id.signin);
    signup=(Button) findViewById(R.id.signup);
    mail=(EditText) findViewById(R.id.email);
    paswd=(EditText) findViewById(R.id.password);
    cancel.setOnClickListener(this);
    sigin.setOnClickListener(this);
    cancel.setOnClickListener(this);
    mail.setOnClickListener(this);
    paswd.setOnClickListener(this);
    signup.setOnClickListener(this);
    }



    }

    HOW TO CREATE LIST VIEW /CONTEXT MENU WITH DIAOG BOX.

    package com.example.listview1;

    import android.os.Bundle;
    import android.app.Activity;
    import android.content.Intent;
    import android.view.ContextMenu;
    import android.view.ContextMenu.ContextMenuInfo;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.widget.ArrayAdapter;
    import android.widget.ListView;
    import android.widget.Toast;

    public class MainActivity extends Activity {
        ListView L1;
        String Contact[]={"MCA","MTECH","MBA","BCA","BBA"};

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            L1=(ListView) findViewById(R.id.listView1);
            ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,Contact); 
            L1.setAdapter(adapter);
            registerForContextMenu(L1);
        }

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v,
                ContextMenuInfo menuInfo) {
            // TODO Auto-generated method stub
            super.onCreateContextMenu(menu, v, menuInfo);
       

          menu.setHeaderTitle("DO YOU WANT TO PROCCESED");   
          menu.add(0, v.getId(), 0, "YES");//groupId, itemId, order, title  
          menu.add(0, v.getId(), 0, "NO");
        }

        @Override
        public boolean onContextItemSelected(MenuItem item) {
            // TODO Auto-generated method stub
             if(item.getTitle()=="YES"){ 
                 Intent i = new Intent(getApplicationContext(), Login.class); 
                 startActivity(i);
             }   
             else {
                 Intent i = new Intent(getApplicationContext(), MainActivity.class); 
                 startActivity(i); 
          
            return false;
             }
             return true;
       
       
    }
        }

    Thursday, 24 September 2015

    how to desidn login form and jump into website using implict intent

    package com.example.sum;

    import android.net.Uri;
    import android.os.Bundle;
    import android.app.Activity;
    import android.content.Intent;
    import android.view.Menu;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.Toast;

    public class MainActivity extends Activity implements OnClickListener{
    @Override
    public void onClick(View arg0) {
    // TODO Auto-generated method stub
    if (arg0.getId()==R.id.button2)
    {
    username=et1.getText().toString();
    paswd=et2.getText().toString();
    if(username.equals("sumeet")&& paswd.equals("123"))
    {
    Toast toast=Toast.makeText(getApplicationContext(),"success",Toast.LENGTH_SHORT);
    toast.setMargin(50,50);
    toast.show();
    Intent intent=new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("http://www.facebook.com"));
    startActivity(intent);
    et1.setText("*******");
    et2.setText("*******");

    }
    else
    {
    Toast.makeText(getApplicationContext(),"warning wrong password",Toast.LENGTH_SHORT).show();

    }}
    else
    {
    finish();
    }
    }

    Button b1,b2;
    EditText et1,et2;
    String username,paswd;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            b1=(Button) findViewById(R.id.button1);
            b1.setOnClickListener(this);
            b2=(Button) findViewById(R.id.button2);
            b2.setOnClickListener(this);
            et1=(EditText) findViewById(R.id.editText1);
            et2=(EditText) findViewById(R.id.editText2);
            et1.setOnClickListener(this);
            et2.setOnClickListener(this);
        }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.activity_main, menu);
            return true;
        }
       
    }

    HOW TO ACCESS MAP IN ANDROID WITH DIALOG BOX

    ackage com.dialog;

    import android.location.Location;
    import android.location.LocationListener;
    import android.location.LocationManager;
    import android.os.Bundle;
    import android.provider.Settings;
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.app.AlertDialog.Builder;
    import android.app.Dialog;
    import android.content.Context;
    import android.content.DialogInterface;
    import android.content.DialogInterface.OnClickListener;
    import android.content.Intent;
    import android.view.Menu;
    import android.view.View;
    import android.widget.Button;
    import android.widget.Toast;

    public class MainActivity extends Activity implements LocationListener {
    LocationManager loc;
        @Override
    public void onLocationChanged(Location location) {
    // TODO Auto-generated method stub
        double latitude=location.getLatitude();
        double longitude=location.getLongitude();
        Toast.makeText(getApplicationContext(), "lat"+latitude+ " Long"+longitude,1).show();
    }

    @Override
    public void onProviderDisabled(String provider) {
    // TODO Auto-generated method stub
    Toast.makeText(getApplicationContext(),"Disable", 2000).show();

    }

    @Override
    public void onProviderEnabled(String provider) {
    // TODO Auto-generated method stub
    Toast.makeText(getApplicationContext(),"Enable", 2000).show();
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
    // TODO Auto-generated method stub

    }

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            loc=(LocationManager) getSystemService(Context.LOCATION_SERVICE);
            loc.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, MainActivity.this);
            loc.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, MainActivity.this);
            loc.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 0, 0, MainActivity.this);
        }
       
            public void dialog(View v)
            {
           Builder aa=new AlertDialog.Builder(MainActivity.this);
            aa.setTitle("internet not working");
            aa.setMessage("press ok to open internet setting else press no");
            aa.setPositiveButton("hlo",new OnClickListener() {

    @Override
    public void onClick(DialogInterface dialog, int which) {
    // TODO Auto-generated method stub
    Intent aa=new Intent (Settings.ACTION_WIRELESS_SETTINGS);
    startActivity(aa);
    }
    });
           
            Dialog ab=aa.create();
            ab.show();


       

     


     Dialog d=new Dialog (MainActivity.this);
     d.setContentView(R.layout.activity_main);
     Button b1=(Button) d.findViewById(R.id.button1);
     b1.setOnClickListener(new View .OnClickListener() {

    @Override
    public void onClick(View v) {
    // TODO Auto-generated method stub

    }
    });
     d.setTitle("internet not working");
     d.show();
            }
    }
            

    Wednesday, 23 September 2015

    how to customize dialog box

    mport android.os.Bundle;
    import android.provider.Settings;
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.app.AlertDialog.Builder;
    import android.app.Dialog;
    import android.content.DialogInterface;
    import android.content.DialogInterface.OnClickListener;
    import android.content.Intent;
    import android.view.Menu;
    import android.view.View;

    public class MainActivity extends Activity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
       
            public void dialog(View v)
            {
    Dialog d=new Dialog (MainActivity.this);
     d.setContentView(R.layout.activity_main);
     d.setTitle("internet not working");
     d.show();
            }
    }

    how to create dialog box and jump into mobile setting or wifi/gps

    package com.dialog;

    import android.os.Bundle;
    import android.provider.Settings;
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.app.AlertDialog.Builder;
    import android.app.Dialog;
    import android.content.DialogInterface;
    import android.content.DialogInterface.OnClickListener;
    import android.content.Intent;
    import android.view.Menu;
    import android.view.View;

    public class MainActivity extends Activity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
       
            public void dialog(View v)
            {
            Builder aa=new AlertDialog.Builder(MainActivity.this);
            aa.setTitle("internet not working");
            aa.setMessage("press ok to open internet setting else press no");
            aa.setPositiveButton("hlo",new OnClickListener() {

    @Override
    public void onClick(DialogInterface dialog, int which) {
    // TODO Auto-generated method stub
    Intent aa=new Intent (Settings.ACTION_SETTINGS);
    startActivity(aa);
    }
    });
           
            Dialog ab=aa.create();
            ab.show();
    }

       

     
    }

    Tuesday, 22 September 2015

    ADD TWO NUMBER IN ANDROID AND SHOW IN TOAST


    1. package com.example.sumof2numbers;  
    2.   
    3. import android.os.Bundle;  
    4. import android.app.Activity;  
    5. import android.view.Menu;  
    6. import android.view.View;  
    7. import android.view.View.OnClickListener;  
    8. import android.widget.Button;  
    9. import android.widget.EditText;  
    10. import android.widget.Toast;  
    11.   
    12. public class MainActivity extends Activity {  
    13.     private EditText edittext1,edittext2;  
    14.     private Button buttonSum;  
    15.     @Override  
    16.     protected void onCreate(Bundle savedInstanceState) {  
    17.         super.onCreate(savedInstanceState);  
    18.         setContentView(R.layout.activity_main);  
    19.           
    20.         addListenerOnButton();  
    21.           
    22.     }  
    23.     public void addListenerOnButton(){  
    24.         edittext1=(EditText)findViewById(R.id.editText1);  
    25.         edittext2=(EditText)findViewById(R.id.editText2);  
    26.         buttonSum=(Button)findViewById(R.id.button1);  
    27.           
    28.         buttonSum.setOnClickListener(new OnClickListener(){  
    29.   
    30.             @Override  
    31.             public void onClick(View view) {  
    32.                 String value1=edittext1.getText().toString();  
    33.                 String value2=edittext2.getText().toString();  
    34.                 int a=Integer.parseInt(value1);  
    35.                 int b=Integer.parseInt(value2);  
    36.                 int sum=a+b;  
    37.     Toast.makeText(getApplicationContext(),String.valueOf(sum),Toast.LENGTH_LONG).show();  
    38.             }  
    39.               
    40.         });  
    41.           
    42.     }  
    43.     @Override  
    44.     public boolean onCreateOptionsMenu(Menu menu) {  
    45.         // Inflate the menu; this adds items to the action bar if it is present.  
    46.         getMenuInflater().inflate(R.menu.activity_main, menu);  
    47.         return true;  
    48.     }  
    49.   
    50. }  

    Earn money online through app sign up

    Hey, I just transferred some money to a friend using Chillr. Its super quick and easy. Check it out. https://m.chillr.in/invite Hey! I...