When there’s no limit to what Android gets, there’s no limit to what Android does
Android development
Android Facebook integration
Jan 21st
Steps for Facebook integration into your app
- Create your app on Facebook : http://www.facebook.com/developers/createapp.php
- Download Facebook SDK : http://developers.facebook.com/docs/guides/mobile
More >
Admob with padding
Aug 26th
I just added AdMob to my Android app DRoute and it doesn’t work. I receive many calls to onFailedToReceiveAd event function
-
@Override
-
public void onFailedToReceiveAd(AdView adView)
-
{
-
Log.d("DRoute", "onFailedToReceiveAd");
-
super.onFailedToReceiveAd(adView);
-
}
I dig into the problem, search on the internet and didn’t found a solution. This morning I’ve created step by step a fresh new app only to test AdMob publisher code and ID and it works fine on emulator with :
After step by step testing I found out that the problem was with a padding value that I have in my surrounding
More >
Handle Back button action
Aug 10th
By default pressing Back button on any activity the Android sistem will close / destroy the activity ( OnDestroy method is called ) See : Activity Lifecycle.
This can be a little annoying when you have some service that perform background work.
More >
Install/Move to sd card on Froyo
Aug 5th
On Froyo ( Android 2.2 ) the user have the option to move / install applications to sd card. This is good due to lack of space on phone memory.
To enable this option at application level the developer should do some simple modifications.
- Open manifest file ( AndroidManifest.xml ).
- Add android:installLocation=”auto” as attributes to your root manifest element. Here you have 3 options :
internalOnly: Install the application on internal storage only. This will result in storage errors if the device runs low on internal storage.preferExternal: The android system tries to install the application on external storage. If that is full, the application is installed on internal storage.auto: Let the Android system decide the best install location for the application. The default system policy is to install the application on internal storage first. If the system is running low on storage, the application is then installed on external storage.
- Change Project Build Target to Android 2.2
- Keep android:minSdkVersion as low as you want. This new option will be available only on devices running Froyo (2.2)
References : http://android-developers.blogspot.com/2010/07/apps-on-sd-card-details.html
Services – connect and communicate using aidl
Jul 31st
With services there are 2 ways to work with :
- One is to use startService(Intent) to start the service and stopService(Intent) to stop the service from within your activity. With this solution you cannot communicate directly with the service, but you can use SQLITE as a layer between activities and services.
- The second is to use bindService() to bind the service with the activity. With this the service is alive all the time the activity that is bind to is alive. With this method you can communicate with the service directly.
I will write a simple tutorial about the second option.
I use Eclipse and ADT Plugin for Eclipse . This will do some background work.
Add settings to an application using Preferences
Jul 10th
You can use Preference classes from Android SDK to store, set and retrieve Settings at application level or at activity level.
There are 2 ways to manipulate preferences :
- Using your own screen to modify the settings
- Using the built in PreferenceActivity class
How to share / send data from your application
Jun 29th
If you want to share / send data from your application using others applications, you must use ACTION_SEND intent.
An example below :
-
Intent intent = new Intent(Intent.ACTION_SEND);
-
-
intent.putExtra(Intent.EXTRA_SUBJECT, this.getResources().getString(R.string.shareSubject));
-
intent.putExtra(Intent.EXTRA_TEXT, this.getResources().getString(R.string.shareExtra));
-
intent.setType("text/plain");
-
-
startActivity(Intent.createChooser(intent, this.getResources().getString(R.string.mailAppChoose)));
If you want to choose only from e-mail applications use :
-
intent.setType("application/e-mail");
If you want to attach a file to e-mail use :
-
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/"+fileName));
Create a custom adapter
May 28th
If you want to create a detailed list you may need a custom adapter for that list.
With the solution below you can manipulate and populate your custom list.
1. extend ArrayAdapter<YourClass>
2. override public View getView(int position, View convertView, ViewGroup parent)
How to get string resources values
May 27th
In code :
getResources().getString(R.string.resourceName);
In xml :
@string/resourceName
