2013年6月26日 星期三

foreground service trick

If you experiencing an issue that you cannot start a foreground service, you can look forward this article may help you.

Pre: 
According to Google doc, if you want to start a foreground service, you can call a function startForeground (int id, Notification notification) in your service.


Then your service will keep running even if your application/activities are destroyed.

Trick:
REMEMBER. DON'T use 0 as the input of int parameter, if you don't want to spend 2 days on fixing it.

startForeground(0, notification); // Doesn't work...

startForeground(1, notification); // Works!!!


P.S. Someone in the above post said he tried 123 which also doesn't work. Only 1 is work. I haven't prove it. If anyone tried, please tell me.



2013年6月14日 星期五

use InAppBillingService in Android Studio

This is for those people who use Android Studio(AS as short) to develop. If you are using other IDE and also need help, you can leave comments to seek help.

First, if you aren't use AS to create new project with Gradle project structure, you can ignore this article. 




Above screenshot show the correct directory structure to put the IInAppBillingService.aidl.

The default directory structure does not have aidl . You need to create it by yourself. After that, you just need to rebuild the project, then you can use this service just like the sample TrivalDriver.

P.S. I am still a newbie in Android development.

P.S^2 母語是中文, 所以大家都可以用中文問題. I can understand Chinese, I am just too lazy to type Chinese =3=