11.07.2015 Views

A first look at Google Android

A first look at Google Android

A first look at Google Android

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A <strong>first</strong> <strong>look</strong> <strong>at</strong> <strong>Google</strong> <strong>Android</strong>EditText mRecipient;Button mSend;Button mSetup;// Called with the activity is <strong>first</strong> cre<strong>at</strong>ed.@Overridepublic void onCre<strong>at</strong>e(Bundle icicle) {super.onCre<strong>at</strong>e(icicle);setContentView(R.layout.main);// g<strong>at</strong>her the troopsmSendText = (EditText) findViewById(R.id.sendText);mListMessages = (ListView) findViewById(R.id.listMessages);mRecipient = (EditText) findViewById(R.id.recipient);mSend = (Button) findViewById(R.id.send);mSetup = (Button) findViewById(R.id.setup);// set up handler for on clickmSetup.setOnClickListener(this);mSend.setOnClickListener(this);bindService((new Intent()).setComponent(com.google.android.xmppService.XmppConstants.XMPP_SERVICE_COMPONENT),null, mConnection, 0);}// Let the user know there was an issuepriv<strong>at</strong>e void logMessage(CharSequence msg) {Notific<strong>at</strong>ionManager nm = (Notific<strong>at</strong>ionManager) getSystemService(Context.NOTIFICATION_SERVICE);}nm.notifyWithText(123, msg, Notific<strong>at</strong>ionManager.LENGTH_LONG, null);// Here’s the code th<strong>at</strong> gets a XMPP session using a service connectionpriv<strong>at</strong>e ServiceConnection mConnection = new ServiceConnection() {public void onServiceConnected(ComponentName className, IBinder service) {// This is called when the connection with the XmppService has been// established, giving us the service object we can use to// interact with the service. We are communic<strong>at</strong>ing with our// service through an IDL interface, so get a client-side// represent<strong>at</strong>ion of th<strong>at</strong> from the raw service object.Tomas K<strong>at</strong>ysovas Page 11 1/19/2008

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!