Welcome Android Developpers

Welcome Android Developpers
My name is Mathias Séguy, I am an Android Expert and Trainer and created the Android2EE company.

For full information, it’s here : Android2EE's Training
You can meet me on Google+, follow me on Twitter or on LinkedIn
Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Friday, July 5, 2013

Bluetooth Tutorial by Android2EE available on GitHub

Hello,

Good news for those who bought the book "A Quick Course Android" or "Android A Complete Course," the Bluetooth Android2EE's  tutorial is finally available. I drop it on GitHub at the following address:

https://github.com/MathiasSeguy-Android2EE/BlueToothTuto

This tutorial explains thoroughly the establishment of a communication between two Bluetooth devices. It contains three activities and a service which aims to set up a chat between two devices.

The EnableActivity activity can detect if the Bluetooth is turned on or off and engage otherwise.

The DiscoveryActivity activity can set device discoverable, detect others Bluetooth devices and then connect to the one selected.

Once the connection is established, the Application object holds the socket, launches communication  service between the two devices and also launching the communication activity.

Communication activity binds with the communication service, receives and sends messages to the other device. It also stops, starts or kills the service. Murder service also frees the socket.

The simplified class diagram:
couvFormationInit_web
Mathias Séguy
mathias.seguy@android2ee.com
Android2EE
Android Training, Consulting and Expertise.
AndroidEvolution
Meet me on Google+
Follow me on Twitter
Join my LinkedIn network

Thursday, June 28, 2012

What's New in Android available on YouTube ! yes :o)

Bandeau Conference
Hey,
But it's the Google IO 2012 !!!
Good news, Jelly bean (4.1) is here, Nexus 7 too
and you can see the video of the talk, one of my favorite:
Google I/O 2012 - What's New in Android?
Just enjoy Romain Guy and Chet Haase talk :o)
So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)

Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
AndroidEvolution
Meet me on Google+
Follow me on Twitter
Join my LinkedIn network ou Viadeo

Monday, April 23, 2012

LearnComputer publish a Review of the ebook "Android a Complete Course"

Bandeau Conference



A review of my ebook "Android a Complete Course" from learncomputer.com can be found here. And i am proud of it. Thanks to LearnComputer.com for it.
http://www.learncomputer.com/android-a-complete-course-ebook-review/


So, Thanks who?
Thanks, "LearnComputer.Com, Your Information Technology Trainers" :o)




Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
AndroidEvolution
Meet me on Google+
Follow me on Twitter
Join my LinkedIn network ou Viadeo

Monday, April 9, 2012

AdMobs Part 2: The real test and it's small problem

Bandeau Conference
Ok, back to AdMobs.
Sometimes it's not so obvious than it looks like especillay when you're tired.
So for AdMobs, first download the Jar here :
https://developers.google.com/mobile-ads-sdk/download
Then unzip it (beside to your Android SDK is a good idea).
Then include it into your project:
1) Include the jar within your project properly
Copy paste the jar within your project (create a lib folder and paste it there)
Open your Build Path and:
  1. First add the Jar to your librairies (use the "Add Jar" button and choose the one in your \lib folder)
  2. Second, add the lib folder as a Source of your project
If you don't do that you'll have:
->Either an build error (the class can't be found)
->Either a run Time error (the class can't be found, the exact sentence looks like: ERROR/AndroidRuntime(2339): Caused by: java.lang.ClassNotFoundException: com.admob.ads.AdView in loader dalvik.system.PathClassLoader@ )

2)When adding to a layout.xml take care about the xmlns:ads.
In fact the parent container of your adMobs banner must declare the namespace of your adMobs.
So insure that the layout container is the following:
LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

If your don't do that you'll have an error in your layout/main.xml when trying to build your project that looks like the ads:adSize is missing...

3)And at least in your Manifest if you have an error when pasting the

 android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

try to open your project.properties and target at least
# Project target.
target=android-13
I defines which SDK to use to compile.

But it not seems to me a good idea. If any one understand that, please tell me. I don't want to change my compilation just because of a lib...


Now it should works...


In your build path:

So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)

Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
AndroidEvolution
Meet me on Google+
Follow me on Twitter
Join my LinkedIn network ou Viadeo

Friday, April 6, 2012

Export Aborted because fatal lint errors where found... WTF !!!.

Bandeau Conference
Hello,

So today, you woke up this morning and thought, "I would rebuild my Android application, good idea". You didn't change anything, but when you do "Android Tools-> Export signed application" a strange message appeared on the top of eclipse:
"Export aborted because fatal lint errors were found. These are listed in the Lint View... Blablabla..."

Ok so you took your coffe and now you're back again in front of the computer trying to find the Lint View. And you read in the LintView the following message when you click on the line "Obsolete Proguard File...":
Obsolete ProGuard file; use -keepclasseswithmembers instead of -keepclasseswithmembernames

Issue: Looks for problems in proguard config files
Id: Proguard

Using -keepclasseswithmembernames in a proguard config file is not correct; it can cause some symbols to be renamed which should not be.
Earlier versions of ADT used to create proguard.cfg files with the wrong format. Instead of -keepclasseswithmembernames use -keepclasseswithmembers, since the old flags also implies "allow shrinking" which means symbols only referred to from XML and not Java (such as possibly CustomViews) can get deleted.

http://http://code.google.com/p/android/issues/detail?id=16384


Ok don't panic, open your proguard-project.txt (it's a file at the root of your eclipse project) and just change the words keepclasseswithmembernames by keepclasseswithmember (delete name at the end of the word). (you should have 3 changes to do).
Save the file (it is renammed as proguard.cfg automaticly), relaunch the  "Android Tools-> Export signed application" , it works.

This is due to the ADT update to the version 17.

So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)

Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
AndroidEvolution
Meet me on Google+
Follow me on Twitter
Join my LinkedIn network ou Viadeo

Monday, March 5, 2012

Spring for Android 1.0.0.RC1 Released

Bandeau Conference

The Spring For Android Release Candidate is here, i mean there
http://www.springsource.org/spring-android/news/1.0.0.rc1-released

So, Thanks who?
Thanks, Spring for that :o)

Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
AndroidEvolution
Meet me on Google+
Follow me on Twitter
Join my LinkedIn network ou Viadeo

Thursday, January 19, 2012

Adding AdSens (so called AdMob) to your Android application

Bandeau Conference
Hello,
Want to add AdSense to your application, ok, simple, follow the link:
Google explains AdMob
So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)

Mathias Séguy
mathias.seguy.it@gmail.com
Android2EE Author
Ebooks to learn Android Programming.
AndroidEvolution
Meet me on Google+
Follow me on Twitter
Join my LinkedIn network or Viadeo one

Tuesday, January 17, 2012

CES 2012 News by AndroidCentral

Bandeau Conference
Hello, below a link to the big news of the CES 2012 (done by androidCentral)
http://www.androidcentral.com/week-android-news-ces-recap-style?utm_source=ac&utm_medium=twitter&style_mobile=0
So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)

Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
AndroidEvolution
Retrouvez moi sur Google+
Suivez moi sur Twitter
Rejoignez mon réseau LinkedIn ou Viadeo

Android Design for ICS

Bandeau Conference
Hello and happy new Year :o)
You want to make an Android application, for multiple devices, excellent ! But before take few minutes to read what are the design guide lines. Google just open a web site to explain those guidelines. The article is simple clear and complete. So just read it :
http://developer.android.com/design/index.html
This article is really good for all the GUI stuff, you should read it , even if you are on Froyo, just to have a clear vision on GUI guide line and ressources.

(Anyway, keep in mind 3.9% of the devices have an SDK version greater than 2.3. see Android target, so not all is your concern )
Okay, this is the today news :o)

So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o) Android Training :o)

Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
AndroidEvolution
Meet me on  Google+
Follow me on Twitter
or on LinkedIn ou Viadeo

Saturday, December 17, 2011

Handler and activity's lifecycle available tutorials

Bandeau Conference
Hello,
You can find on Android2ee 3 tutorials that show you:

  • How to use Handler and manage its life cycle using AtomicBooleans
  • How to use Handler and manage its life cycle using onRetainNonConfigurationInstance method
  • A demonstration of the memory leak associated to the non management of the Handler life cycle.
Those Eclipse projects are downlaodable here : Hanlder Tutorials


So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)

Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
Android Trainings for Enterprise
AndroidEvolution
Retrouvez moi sur Google+
Suivez moi sur Twitter
Rejoignez mon réseau LinkedIn ou Viadeo

Thursday, December 15, 2011

Handler And LifeCycle Part III

Bandeau Conference

Hello again,
To continue with the issue of Handler and activity's life cycle, there is a solution, advocated by some, that is to use the public method Object onRetainNonConfigurationInstance () to return a pointer to an object in the activity.
Uh, let me explain, when your activity is to be destroyed and immediately recreates the method onRetainNonConfigurationInstance can send an object from the instance of the dying activity to the instance of new activity.
Example adapted to our problem:


@Override
public Object onRetainNonConfigurationInstance() {
                //Save the thread
                return backgroundThread;
}

to retrieve the object in the onCreate method:

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
//Do something
                backgroundThread = (Thread) getLastNonConfigurationInstance();
//Do something again
}


It is clear that with this method everything seems solved (at least for the change in orientation of the device). And yes, BUT NOT!!!, it's a serious mistake to think that. Indeed, what happens if your activity is killed (without being recreated immediately)? Well, then your thread is an orphan, your handler and your activity become ghosts (because the garbage collector detects them as used). And here, again, Darth Vader mocks.

The solution, and yes, there is one, is somewhat more complex than that. We must re-implement an atomic boolean to kill the thread if your activity is not restarted immediately.

And then, well, I invite you to get the tutorials that I dropped on Android2EE section Example/Tutorials/Handler's Tutorials. I give you 3 tutorials, one with the Atomic booleans, one with the onRetainNonConfigurationInstance instance and the last is a demonstration of the memory leaks.

But if your want the code, here it is:

Handlers, Threads and Activity's life cycle

Bandeau Conference
Hello,
As I said earlier, when managing Handlers or AsynchTasks, you must always make sure to link the life cycle of the thread with the Handler's one which is also linked with the activity's one ... Otherwise, your thread becomes an orphan Thread.
Ok, digging a little bit more (I will drop you on Androi2EE an eclipse project that shows what I'm saying) it's worse, in fact: When passing by OnDestroy and onCreate (short I return the device), not only the thread becomes orphan, but also the Handler (arg, what it is not destroyed o_O ') and worse is that your activity becomes a ghost ... glooops.
And yes it's crazy, the first activity is not destroyed, she is called by the first thread through the first Handler (hence the absence of the raise of a NullPointer exception) and the second activity is created with the new Handler and its new Thread.

I mean, DarkVador, Voldemor and Sauron laughed thinking of the number of threads, Handlers, AsynchTask, and activities ghosts that inhabit the Android devices because developers unaware of the danger.

So: Manage your threads by linking their life cycle with that of the activity.
So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)

Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
AndroidEvolution
Retrouvez moi sur Google+
Suivez moi sur Twitter
Rejoignez mon réseau LinkedIn ou Viadeo

Friday, November 25, 2011

Free Android Icons

Bandeau Conference
Hello,

As developpers, we always look for free icons, some are in the SDK but sometimes it's not enough.
You can find thousand of free icons on icones.pro (of course a lot of them are for a non commercial use, but you can contact the author to ask them).
If you have others sources of free icons, drop a comment.

So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)

Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
AndroidEvolution
Retrouvez moi sur Google+
Suivez moi sur Twitter
Rejoignez mon réseau LinkedIn ou Viadeo

Monday, November 21, 2011

Spinner, Managing size and text


Bandeau Conference

Hello,
Sometimes, when using a spinner, you want to manage its size and the font of the displayed text.
To do that you need to do 3 actions (I do that change on the Android spinner example : http://developer.android.com/guide/tutorials/views/hello-spinner.html
1.      Create a spinnertext.xml in your layout folder and define how the spinner’s title has to be displayed
2.      Change your spinner size in your main.xml (where your spinner is defined)
3.      Change your spinner declaration in your activity

Handler and Activity's life cycle, take care about orphan threads!!


Bandeau Conference
Hello,
You have an Activity which uses a Handler. You create your handler and overwrite the handleMessage method, you launch the handler’s thread and that’s it for the handler management… Most of us do such a thing and it’s a huge mistake!!! What happens to your thread when your activity pauses and resumes and worst when it dies and (re)creates? 
You thread becomes an orphan thread !

So you have written something like that :

Thursday, November 17, 2011

My Sensors (new Tutorial on Android2ee)

Bandeau Conference

Hello,
A new tutorial is available on Android2ee. I give you the ability to list the sensors available on the device. Quite simple.
The tutorial is here:
Tutos Android2EE and is called MySensors.
(All tutorials on this page are not available but RSSReader, DynamicGui and MySensors are).

In preparation some articles on sensors (and so some tutorials), see you soon.
So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)

Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
AndroidEvolution
Retrouvez moi sur Google+
Suivez moi sur Twitter
Rejoignez mon réseau LinkedIn ou Viadeo

Wednesday, November 16, 2011

How to disable sleep mode ?o?

Bandeau Conference
Hello,
It's quite easy,
You should use the PowerManager object to retrieve PowerService, then get the PowerManager.WakeLock object and ask for it. So in your Activity class declare the following attribute:

Tuesday, November 15, 2011

Android push methods




Bandeau Conference
Hello,


Sometimes it is very useful for our applications to be notified from our server (well of your server for your applications). This method is called the push and can send notifications to your application.
There are several "sioux" tricks there (via SMS, with a permanent connection to your http server ...). But the problem of "sioux" tricks is that they are not relevant when a turnkey solution is provided by the Android SDK itself. (In french a "sioux" trick is a ultimate trick, an indian trick, don't know the right translation).
In fact, Google makes available to developers servers designed for push and implementing commands that enable you to implement it in your application. This service Android Cloud to Device Messaging Framework also known as the C2DM allows you to implement this feature. Like many of Google features, you must register to enjoy.
The Google tutorial (still very bright) enables you in a "jiffy and two shots ladles" to implement this service:



http://code.google.com/intl/fr/android/c2dm/index.html
And a good push to you: o)


So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)

Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
AndroidEvolution
Retrouvez moi sur Google+
Suivez moi sur Twitter
Rejoignez mon réseau LinkedIn ou Viadeo

Initialize your application when first launched on the device.




Bandeau Conference
Hello,

Today I submit a simple way to implement actions at the first launch of your application on a phone. In other words, how to customize the first launch of your application?

The idea is quite simple and relies on the use of the object SharedPreferences. This object is used to store a set of key-value specific to your application within the system and be able to CRUD (create, read, update, delete) them easily.
The idea is to use this HashMap to retrieve ​​specific values of your application. In particular I would call a Boolean Initialized that lets you know if your application has already been launched on the Android device. The following code shows how to do (this code is in a class that extends Activity in the onCreate method):

How to send an Email O_o'


Bandeau Conference
Hello,
To send an email, just use the code below:

//load string for email:

String[] adresses=getResources().getStringArray(R.string.mail_adresses);
String subject=getResources().getString(R.string.mail_subject);
String body=getResources().getString(R.string.mail_body);

// send an email
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, adresses);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
startActivity(Intent.createChooser(emailIntent, "Send mail..."));

Notice that you are using Intent to call the Emails' sender activity.

So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)

Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
AndroidEvolution