2012年10月28日 星期日

typename in C++

typename as we know in C++ is used in template.
The difference between typename and class is in the nested type.
Take the class sp in RefBase.h of Android Framework as example:


template <typename T>
class sp
{
public:
    typedef typename RefBase::weakref_type weakref_type;
    .........
}



class RefBase
{
public:
           .........
         class weakref_type
         {
          .........
          }
}
--------------------------
Notice that " typedef typename RefBase::weakref_type weakref_type; "
Compiler will  not know that if weakref_type is a variable of RefBase.  Compiler will know that weakref_type is a type or class of RefBase by giving typename .





2012年10月16日 星期二

Android -Google Maps (Webview)

Use WebView to show the map:

1.webView.getSettings().setJavaScriptEnabled(true);
 Open the JavaScript of the web.

2.webView.getSettings().setGeolocationEnabled(true);
 Open the geolocation for the web to get location through Javascript

PS:Use LocationManager to get the location from network or GPS.


Ref:

More info about Webview

2012年10月14日 星期日

Android bindService() notice

There are roughly two ways of using the service in Android,Context.startService() and Context.bindService().

Context.startService(): can be used only by one application.
Context.bindService(): could be exposed to other applications.

Here we focuse on Context.bindService().

bindService() -> onCreate() -> onBind() ->onServiceConnected()-> running.

There is one thing we have to notice.

The onServiceConnected() may not be called immediately and this might cause some problem!


Ref:
http://stackoverflow.com/questions/2486692/onserviceconnected-never-called-after-bindservice-method



Android - Animation


(1) tweened animation
1.alpha
2.scale
(2)frame by frame
1.translate
2.rotate
----------------
Using by two ways:
1.XML

Animation myAnimation= AnimationUtils.loadAnimation(this,R.anim.myanimationxml);

2.Non-XML

Animation myAnimation_Alpha=new AlphaAnimation(0.1f, 1.0f);

Reference from:
http://jjnnykimo.pixnet.net/blog/post/30359165-android-amimation