Saturday, April 11, 2015

[Android Studio] How to add an external jar into project


How to Add an External Jar in Android Studio

Any beginners of Android Studio may encounter this problem: how to add an external jar into current project. It's pretty easy, just follow these steps:

-1. download the jar file and create sub dir "libs" in the "app"dir if there's no such subdir, then put the jar file into this dir

-2. Right click current project, and select "Open Module Settings"

-3. Click "+" at the left-top corner to "Import .JAR or .AAR package"

-4. Then find and select the jar file which is now located in the "libs" sub dir. You can choose to "Remove original file" to keep the project clean.

-5. After that, android studio will automatically start to sync the whole project.

That's it, you will find out the new jar was added in your project, and also a new "build.gradle" file was also created, the new jar was added into current project's "build.gradle" file as well.

Thursday, October 16, 2014

Psychological analysis of popularity of mobile apps


Now we are in the era of mobile networking, smartphones can be seen everywhere, almost user behind the smartphone is contributing to the global networking everyday, not just by posting contents or comments on the social medias, but also he/she is reading the online information.

One phenomenon is that some mobiles apps are becoming more and more popular, such as Snapchat, Whatsapp, Instagram, and even a very simple app such as Yo can get more than thousands of millions of users. But at the same time, for most of other apps, it's very hard for them to get event 1K users. What's the essential reasons which lead to this huge difference?

To understand the reason, from my point of view, besides the UI/UX design of the apps, the most important feature a successful and popular mobile app should have is to catch user's sweet point, psychologically. 

I wanna list some psychological principles I found in those popular mobile apps:

1. Desire to share private things in a risk-free way:  
     I would like to talk a bit about Snapchat firstly, the most funny and important feature I like in this app is that I can share a picture to my friend for just a certain period of time, and after that, it will be destroyed. I never tried this before, because of this feature, people can share more private pictures even including nude pictures to their close friends while no need to worry that somebody may leak these pictures online. The psychological principle behind this I think is people has a kind of desire to share private things with others in a limited range, cause no one wants to be judged by the public, but by a few close friends, it's okay. 
    This remind me about another app called "secret", I think the psychological principle behind this app is similar but with a bit difference. Everybody can share their personal awkward and ridiculous secret in a public platform, and others can comment on this, most of the users are interacting in anonymous way, possibly only the back end engineers of this app can tell who is who in the app.

2.  More personal, more sticking:
     People want to feel special and unique, a customized and personalized app will give user this kind of feeling. How to make it personal? Well, at least, I think there are two ways: put my personal friends in this app and allow me to share or post personal things in this app. All of the social network apps such as Facebook, Twitter, Google+ have this functionality. From users' point of view, if they put more personal things in an app, more likely, they will check this app. For example, I rarely posted on Facebook and Wechat, but I check these apps frequently, at least every two or three days, because, my friends are also in this app, and I want to check their status too.

3.  Have fun in a boring life (more interactive, more fun):
     Thanks to the internet and our powerful logistics system, we don't need to go outside and interact with other people, we can get what we want just by connecting to the internet and a few clicks on a web page or in an app.  That also means we are losing one of our major nature instincts: sociability. Life is becoming boring since individuals are more independent from each other than before. Apps which can make our daily life more fun and colorful definitely will get people's favor. For example, Yo is such kind of app, it's very simple, and the functionality looks "stupid", but it is fun, you have to admit this. I think it has the simplest way for you to interact with your friends, and that's why it's spreading quickly like virus. 

More apps I play around, the more I feel that a success of a mobile app is less related with the technology, but more related with the psychological issues. We did not see many fancy technologies in those popular apps, but we did see many unique functionality or feature in those apps. Hope those psychological principles I listed above may inspire us a bit when we're developing our own mobile apps. 

Android developer notes


To create a great product, you need to care about all aspects of it, usually we classify it into two categories: UX and UI.

UX is the most important, without this, user is not gonna use your app even your app got the most beautiful UI.

I'm listing some UX glitches here, so others who are reading this blog will benefit from this.

1 Network issues:
    We can guarantee that our app will always be used with high quality wifi connection, in case of slow/very slow network connection, we need to think about some scenarios in which user may get some problems:
     The principle here is: you can suppose the network is always reliable and even available, in this case, you need to make sure firstly the network task won't block the UI thread, and secondly, the app won't crash in case we cannot get data.

     a) You have a list view, and you also support search functionality for that. Before the whole list load, user may start to search using some keywords. Firstly, we need to make sure the app won't crash; Secondly, we need to show some hints to the user, cause in this case, definitely no result will be found for the search.

      b) You have an async task for one activity/fragment, and in this task, you're gonna use the activity instance, before the task finish, user switches to another activity / fragment, so what are you gonna do to prevent the potential app crash since the previous activity instance is already destroyed. Then in this case, don't use the instance of the activity, use the whole application instance instead.

      c) Sync up between menu items and network task: suppose you're using a global variable which will be assigned in an async task, and this value will be used when user click one of the menu buttons. But due to the unreliable network, before the global variable is assigned, user may click the menu button. Then your app should tolerate this case and make sure it won't crash.

To be continued.

Friday, April 11, 2014

Android Development Handbook


Chapter 1. Setting up Development Environment

1.1 Make sure you have installed Java Runtime  Environment (JRE) and Java Development Kit (JDK) on your machine.

1.2 Download android SDK from: http://developer.android.com/sdk/index.html, follow the instructions to set up the SDK runtime environment

1.3. For some reasons, it won't work in some OS. I was running ubuntu 12.04 LTS 64bits. I got the following error: 
"Unexpected exception 'Cannot run program "/home/.../Descargas/adt-bundle-linux-x86_64 20131030/sdk/platform-tools/adb": error=2, No existe el archivo o el directorio' while attempting to get adb version from '/home/.../Descargas/adt-bundle-linux-x86_64-20131030/sdk/platform-tools/adb'"
when I launched eclipse which already integrated android SDK. I checked the error information in eclipse console, seems I need to install ia32-libs. 

One way to solve the lib dependency issue is to install the following libs one-by-one:

sudo apt-get install libgl1-mesa-dri:i386
sudo apt-get install ia32-libs-multiarch:i386
sudo apt-get install ia32-libs-multiarch
sudo apt-get install ia32-libs

It works well after all libs are ready.

1.4 Follow instructions on the Android official website and enjoy android application development.

* Sometimes, we cannot start the emulator. As I am running android studio on Ubuntu 12.04, and is using Nvidia GPU, an error may triggered because of an OpenGL library cannot be found, such as:
emulator: ERROR: Could not load OpenGLES emulation library: libOpenglRender.so: cannot open shared object file: No such file or directory
emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
A possible way to avoid this problem is specify the option: [ -gpu off | -no-audio ] in command line before launching the emulator.
And also, to specify the missed library path, we should add "/home/.../android-studio/sdk/tools/lib" into "LD_LIBRARY_PATH"




Sunday, March 30, 2014

Federal Tax Return of J1 Scholar


There's a saying: "Nothing is certain but death and taxes". People in US start to get busy in March and April, cause this is so-called "tax-season" in US. Many documents and forms need to complete and submit.

2013 is my first year as a research scholar in US, holding  a J1 visa. As a J1 visa holder, I'm "non resident alien" in US for my first two years, but after that, I will be "resident alien" in US. Two different identities, mean two different ways to apply for federal tax return.

The steps to apply for federal tax return is pretty easy, suppose you're using Glacier for online tax process,which was specially designed for non-resident aliens.
1. Sign into this system, and choose to complete tax return, you will be redirected to the GTP system (which is short for Glacier Tax Prepare system)
2. Basically, before starting applying for federal tax return, you should already got your W-2, and 1042-S forms (or other forms, depends on your visa type and identify in US). Just copy the contents in above forms into the GTP system.
3. GTP will generate some forms for you, the only thing you need to do is print out these forms, sign and date them, and then mail them to IRS (Internal Revenue Service).
* Somethings need to be kept in mind are:
   - Copy those printed out forms before mailing them to IRS, since you need to keep those copies for certain period of time (usually, 3 calender years)
   - File separated forms in separated envelopes to IRS if you have spouse or dependents in US who's also need to submit forms.

That's all, enjoy life, enjoy tax!

Wednesday, October 9, 2013

Extract main content from web page

When we are designing a web search engine, especially vertical search engine, we usually want to extract the main content from a given web page. However, many boilerplate may be placed in a page. It's difficult to extract the main content from a web page since there are all kinds of tags we need to find and exclude.
    A tool I found to extract main content from a web page is called boilerpipe, its a Java library supporting for "detect and remove the surplus "clutter" (boilerplate, templates) around the main textual content of a web page" according to the introduction on the official website. But, there's a little problem that this tool is written in Java, while I want to extract html main content using python. The good thing is there is a python wrapper for this tool, its called python-boilerpipe. Since this is a python wrapper for java libraries, so it needs some "middleware" to act as bridge joint between java and python, it needs jpype and charade. Jpype is an open source project designed for bridging the worlds of java and python, and it is better than Jython( previously called JPython) which supports similar functionality; charade is an universal character encoding detector

    Since all things I need are ready, here's the steps I deploy the software environment for my project:
 1) I am using python 2.7, since charade is already integrated, so in the first step, I only need to set up Jpype. Just download the package from the official site( actually, it will redirect to sourceforge), unpack and install it:
    python setup.py install --prefix=customized_path
add the customized library path (its the installed package path, not only including the customized install path, for example: ~/jpype/lib/python2.7/site-packages/) into environment variable: PYTHONPATH.
     Jpype installation can be easily verified from python command mode. Here's some sample code for testing:
     import jpype 
     jpype.startJVM(jpype.getDefaultJVMPath()) 
     jpype.java.lang.System.out.println( “ hello world! ” ) 
     jpype.shutdownJVM() 
     charade can be configured and installed in the same way, just download it from the official website.
     After jpype and charade have been set up, then we can install python-boilerpipe, its very straightforward.

2) Play with python-boilerpipe.
    One thing I like most of this tool is that it support kinds of text extractors.
    We may specify a extractor to extract text from a web page, by default, the DefaultExtractor will be used.
    We can just specify the url, and the tool will download the html automatically and extract the text from the page, we can use methods of extractor: getText() to get the pure main text of the page, and use getHTML() to get the html content of the page.
    Meanwhile, we can also download the html page by ourselves, and analysis it with python-boilerpipe.



Wednesday, September 4, 2013

Big data analysis in people search, Really challenging.

Nowadays, more and more people, from both industry and academy, are talking about big data. its popularity is like the fanaticism brought by MJ's new album if he's still alive. It is no exaggerating to say that we are now living in an era of "Big Data": science, engineering and technology are producing increasingly large data streams, with petabyte and exabyte scales becoming increasingly common. Big data presents opportunities and also perils. On the optimistic side, it gives us a pretty good opportunity to scale existing theoretical principles and also learning algorithms from modest-size data sets to massive data sets, thus, big data give us a fantastic platform and resources to verify the success of those principles and algorithms; while on the other side, there are some big challenges also brought by big data. It amplify the errors and their effects in existing technologies, and also, efficiency, space, energy are major issues we need to tackle in big data analysis. 
As the social network website are booming since later 90s and early 00s, millions of people join these kind of website like facebook and twitter each year, as the official statistic data of facebook says, it has a billion active user at the end of 2012. People are looking for and sharing all kinds of information on these website, and an obvious trend leaded by social network is that people are much more willing to post and share their personal information online. As a result, anyone wants to find his friends and try to get their recent updates, he can get all of these information by just typing his friends' names online, for example, on google or on some social network websites. Moreover, as this kind of requirement becomes more popular and general, an advanced people search engine is very useful. 
Recently, I'm investigating people search. I felt that neither google or social network website like facebook cannot exactly meet my requirement, actually, there is a wonderful people search engine which can aggregate a person's profile around the internet, not only from social network website, but also from all kinds of personal pages, even news pages online. Its name is called "whova",  provides advanced people search ability which is built upon proprietary big data analytics and mining technology. To precisely aggregate one's personal information online is very challenging, because:
1) Firstly, as we have mentioned above, a single person's information can be scattered around many websites, for example, I may ever submitted my personal information, such as, name, education, affiliation etc on facebook, and also on other website, eg linkedin. To precisely determine that different profiles information parsed from different website belong to a same person is very difficult.
2) Secondly, it may be some kind easy to get profile information from social network website, since the information show on these websites are structural. However, for general pages, an intelligent parser must be carefully designed to inference personal profile from those complex text paragraphs on a page, as we know, semantic analysis is a pretty challenging open problem.