Posts

Showing posts from January, 2015

Android - Google Now's launch intent

Image
     Ever needed to trap launch event for Google Now, the activity displaying a list of context based cards? This is exactly what latest version of Firefox managed to do, though the functionality is limited.      The intent is fired with an action of  android.intent.action.ASSIST and category  android.intent.category.DEFAULT .

Android - Activity's getIntent() and setIntent()

    Android Activity's getIntent() API documentation isn't clear if application developers should book keep and save the intent at appropriate times for reuse.  Fortunately, this doesn't need any explicit action by application developers in onSaveInstanceState().     It is supposed to work for cases when the activity is paused and the process is killed by the framework and later restarted when user resumes the application. The reason this works despite a process kill is because the launch intent is book kept in the framework by Activity manager service. So as long as the framework is alive, its always possible to get back to the launch intent and this is yet another reason as to why its not a good idea to store huge data set as Intent extras, which would end up increasing framework's memory usage.    However, there is another API to update the launch intent via setIntent(). This is needed for cases when a single instance activity is launched via o...

Curl - Command line equivalent C++ code

  Ever needed the source code corresponding to a curl command line? Fortunately, the developers were nice to add an option to generate the C++ source code.    curl command has an option --libcurl FILE to generate the source code for any http request. This basically saves the code in the specified file and executes the actual http request. The most often used curl request is to get repo to download Android's source code.           curl https://storage.googleapis.com/git-repo-downloads/repo This along with --libcurl generates this nice helper function, curl https://storage.googleapis.com/git-repo-downloads/repo --libcurl curl.cpp /********* Sample code generated by the curl command line tool **********  * All curl_easy_setopt() options are documented at:  * http://curl.haxx.se/libcurl/c/curl_easy_setopt.html  ************************************************************************/ #include <curl/curl.h>...