2014년 8월 27일 수요일

How to check the package name of current launcher


Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
ResolveInfo resolveInfo = getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
String packageName = resolveInfo.activityInfo.packageName;

2014년 8월 3일 일요일

How to take a snapshot in Google Map v2

// Once everything has loaded, cache the map’s image for fast display later
// Note: the map loaded callback is only called once.
mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
    public void onMapLoaded() {
        mMap.snapshot(new GoogleMap.SnapshotReadyCallback() {
            public void onSnapshotReady(Bitmap bitmap) {
                // Write image to disk
            }
        });
    }
});
Reference: http://googlegeodevelopers.blogspot.sg/2013/10/ghost-markers-in-your-neighborhood-new.html

How to change text color of SearchView

int textViewId = mSearchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
TextView textView = (TextView) mSearchView.findViewById(textViewId);
textView.setTextColor(Color.GRAY);