Friday, September 6, 2013

Note for cscope and vim

How to install cscope:
sudo apt-get install cscope
mkdir -p ~/.vim/plugin
cd ~/.vim/plugin
wget http://cscope.sourceforge.net/cscope_maps.vim

How to create the index:
cscope -bR

How to find file:
:cs f f <filename>

Useful command:
CTRL+]
Go to function definition.

CTRL+ O 
Back to the previous place.

]]
Go to the start of this function

[[ 
Go to the end of this function

Ctrl + \ and press 's'
Find all references.


Reference:
用 vim 和 cscope 來 trace 程式碼
http://softsmith.blogspot.tw/2009/01/vim-cscope-trace.html

How to make a call for last outgoing casll from application

String dialNumber = CallLog.Calls.getLastOutgoingCall(getApplicationContext());
if (dialNumber != "") {
    dialNumber = "tel:"+dialNumber;
    Intent dial = new Intent();
    dial.setAction("android.intent.action.CALL");
    dial.setData(Uri.parse(dialNumber));
    dial.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(dial);
} else {
    Log.e(TAG, "no last outgoing call");
}

Thursday, August 29, 2013

How to get the package name and intent of installed apps

PackageManager pm = getPackageManager();
List<ApplicationInfo>packages = m.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
Log.d(TAG, "Installed package :" + packageInfo.packageName);
Log.d(TAG, "Launch Activity :" + pm.getLaunchIntentForPackage(packageInfo.packageName));
}

Reference:
How to launch another app from your app.
http://qtcstation.com/2011/02/how-to-launch-another-app-from-your-app/