Saturday, 30 April 2016

BLUETOOTH IN ANDROID

  1. package com.example.bluetooth;  
  2. import android.os.Bundle;  
  3. import android.app.Activity;  
  4. import android.view.Menu;  
  5. import android.app.Activity;  
  6. import android.bluetooth.BluetoothAdapter;  
  7. import android.content.Context;  
  8. import android.content.Intent;  
  9. import android.os.Bundle;  
  10. import android.util.Log;  
  11. import android.view.View;  
  12. import android.widget.Button;  
  13. import android.widget.TextView;  
  14. import android.widget.Toast;  
  15.   
  16. public class MainActivity extends Activity {  
  17.       private static final int REQUEST_ENABLE_BT = 0;  
  18.       private static final int REQUEST_DISCOVERABLE_BT = 0;  
  19.     @Override  
  20.     protected void onCreate(Bundle savedInstanceState) {  
  21.         super.onCreate(savedInstanceState);  
  22.         setContentView(R.layout.activity_main);  
  23.     final TextView out=(TextView)findViewById(R.id.out);  
  24.     final Button button1 = (Button) findViewById(R.id.button1);  
  25.     final Button button2 = (Button) findViewById(R.id.button2);  
  26.     final Button button3 = (Button) findViewById(R.id.button3);  
  27.     final BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();  
  28.     if (mBluetoothAdapter == null) {  
  29.        out.append("device not supported");  
  30.     }  
  31.     button1.setOnClickListener(new View.OnClickListener() {  
  32.         public void onClick(View v) {  
  33.             if (!mBluetoothAdapter.isEnabled()) {  
  34.                 Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);  
  35.                 startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);  
  36.             }  
  37.         }  
  38.     });  
  39.     button2.setOnClickListener(new View.OnClickListener() {  
  40.      @Override  
  41.         public void onClick(View arg0) {  
  42.             if (!mBluetoothAdapter.isDiscovering()) {  
  43.                   //out.append("MAKING YOUR DEVICE DISCOVERABLE");  
  44.                    Toast.makeText(getApplicationContext(), "MAKING YOUR DEVICE DISCOVERABLE",  
  45.              Toast.LENGTH_LONG);  
  46.   
  47.                 Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);  
  48.                 startActivityForResult(enableBtIntent, REQUEST_DISCOVERABLE_BT);  
  49.                     
  50.             }  
  51.         }  
  52.     });  
  53.     button3.setOnClickListener(new View.OnClickListener() {  
  54.         @Override  
  55.         public void onClick(View arg0) {     
  56.             mBluetoothAdapter.disable();  
  57.             //out.append("TURN_OFF BLUETOOTH");  
  58.             Toast.makeText(getApplicationContext(), "TURNING_OFF BLUETOOTH", Toast.LENGTH_LONG);  
  59.            
  60.             }  
  61.     });  
  62. }  
  63.   
  64.     @Override  
  65.     public boolean onCreateOptionsMenu(Menu menu) {  
  66.         // Inflate the menu; this adds items to the action bar if it is present.  
  67.         getMenuInflater().inflate(R.menu.activity_main, menu);  
  68.         return true;  
  69.     }  
  70.   

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;
        }
       
    }

    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...