lundi 7 avril 2014

Sending SMS with Android


This is a quick example on how to integrate the SMS your app. Threre are two ways to do it:
  • Programmatically
public void SendSms(string phoneNumber, string smsMessage){

         SmsManager mySmsManager = SmsManager.getDefault();

         mySmsManager .sendTextMessage(phoneNumber, null, smsMessage, null, null);

}
  • Using the built in Android SMS Application 

public void builtINSMS(string phoneNumber,string message) {

        Intent intentSMS = new Intent(Intent.ACTION_VIEW);



        intentSMS.putExtra("sms_body", message);

        intentSMS.putExtra("address", phoneNumber);

        intentSMS.setType("vnd.android-dir/mms-sms");

        startActivity(intentSMS );

}


Don't forget to add Sending SMS permission in your manifest file

<uses-permission android:name="android.permission.SEND_SMS" />

mercredi 2 avril 2014

Arduino and Android ADK


Smartphones gives us a wide range of applications that help us organize our selves, play and wake up on time, but if only there is a way to connect our phones to the real world to control hardware stuff like house lighting system or the garage door. Smartphones have a bunch of possibilities including sensors like GPS, accelerometers and temperature, a decent cpu for processing data but the most important feature a smartphone can give is its portability.




In 2011 Google starts a project called Android ADK: http://accessories.android.com/ the Android accessory kit, that can make your phone communicate to devices (accessories) by make a bridge between the power of android devices and the real world through a simple USB communication. This bridge can solve so many problems :D



So I thought to try it out with an arduino ADK board. The project I've done is to control a led and a DC motor From the Android to the arduino passing by xbee modules.
The next diagram explains entities communication:


The code has three sides:

  • The Android side : sending commands through ADK
  • The Arduino ADK Side: Receiving commands and send it wirelessly to other arduino boards with xbee
  • The Arduino Uno Side: Receiving commands from xbee and control the DC motor and the led.
The hole project:

I'll  be happy to answer questions in the comments
Thanks.