gdx 源码分析摘录

一, HandlerCaller的使用

        封装handler;

        1,实现类

              HandlerCaller   mCaller = new HandlerCaller(context, context.getMainLooper(), this, true);

        2,实现回调;

               class XX implements HandlerCaller.Callback

               public void executeMessage(Message message) { }

        3,创建发送message

           Message msg = mCaller.obtainMessageI(MSG_VISIBILITY_CHANGED,
                    visible ? 1 : 0);
            mCaller.sendMessage(msg);


二, Engine

        The actual implementation of a wallpaper. You must implement {@link WallpaperService#onCreateEngine()}

         to return your concrete Engine implementation.

              1,监听屏幕

             

 final BroadcastReceiver mReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {
                    mScreenOn = true;
                    reportVisibility();
                } else if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
                    mScreenOn = false;
                    reportVisibility();
                }
            }
        };
        
    

三, class WallpaperService extends Service

         实现了IWallpaperService


四,IWallpaperService.stub

       attach(); 在attach中创建engine


五,IWallpaperEngine

oneway interface IWallpaperEngine {
    void setDesiredSize(int width, int height);
    void setVisibility(boolean visible);
    void dispatchPointer(in MotionEvent event);
    void dispatchWallpaperCommand(String action, int x, int y,
            int z, in Bundle extras);
        void destroy();
}
控制wallpaper的生命周期,ibinder对象

六: 创建AndroidWallpaperEngine(libgdx封装)

         public class AndroidWallpaperEngine extends Engine


七:  Application

       It sets up a window and rendering surface and manages the * different aspects of your application


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值