Tuesday, August 16, 2011

Add static libraries *.jar to Android.mk based build

in Android.mk


LOCAL_STATIC_JAVA_LIBRARIES := mylocaljar


LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := mylocaljar: mylocaljar.jar


mylocaljar.jar should be in root directory of the project. Look at the Calculator app's Android.mk in Android tree as an example



Fragments for All

http://android-developers.blogspot.com/2011/03/fragments-for-all.html



Blogpost code highlighting

Here I found how to highlight code in my blogposts on Blogspot. It's still not ideal because it doesn't support the original indentation but better nothing.



Automatic thread

Nice piece of code from Android e-mail client



public static AsyncTask runAsync(final Runnable r)
{ return new AsyncTask() {
@Override
protected Void doInBackground(Void... params) {
r.run();
return null;
}}.execute();
}
runAsync(new Runnable() {
@Override
public void run() {}}
);



Monday, August 15, 2011

Friday, July 29, 2011

Market filters

Today's challenger was the defect where some Android devices did not see some apps on Android Market and some other did. Android is complicated in this area too. If your device is not good for a certain app Android Market hides the app rom the view. On one hand it's good. If your device cannot run an app why bother and display it? On the other what if I, a user, want this app so bad that I wanna buy a new phone just to make this app happy. How am I supposed to know what phone I need and what features or operating system version it should have?


Anyway the solution (not for newbies) lies here. This article explains a million complicated reasons why you don't see your app. I think Google should always display apps like that. But it should not let user to install them with explanations why.












Wednesday, July 13, 2011

Broadcast receiver problem

Today I saw a weird bug. I had a broadcast receiver in one app's AndroidManifest.xml


<receiver android:name=".MyReceiver">


<intent-filter>


<action android:name="com.my.intent.update" />


</intent-filter>


</receiver>




and another app sent broadcast with the intent the first app had to handle.




Intent intent = new Intent("com.my.intent.update");


sendBroadcast(intent);




The problem was it never did. I spent some time and asked my co-worker to look at it with me. While looking I found the problem (pair programming works after all). I had an activity in the same manifest file that had a receiver that handled the same intent!





<activity android:label="Test" android:name=".HomeActivity"


android:launchMode="singleTask" android:configChanges="orientation">


<intent-filter>


<action android:name="com.my.intent.update" />


</intent-filter>


</activity>




I don't know why it was there but it made receiver never handle the intent.