zoukankan      html  css  js  c++  java
  • android之app widget(二)

        PendingIntent:

        //创建PendingIntent的方法:

        getActivity(Context context,int requestCode,Intent intent,int flags)      //启动一个Activity
        getBroadcast(Context context,int requestCode,Intent intent,int flags)     //发送一个广播
        getService(Context context,int requestCode,Intent intent,int flags)       //启动一个服务

        RemoteView:所表示的对象运行在不同的进程当中

        //调用app widget按钮的方法,使用以下的监听

        remoteViews.setOnClickPendingIntent(控件ID , pendingIntent方法)

        onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)

        对app widget控件的具体操作事情在继承appWidgetProvider的类的复写方法onUpdate中实现,操作步骤如下:

        1. 创建Intent

        2. 创建PendingIntent,传入Intent

        3. 创建RemoteViews对象 RemoteViews remoteViews = new RemoteViews(String packageName, int layoutId);

        第一个参数是包含需要设施的layout的包明,可以通过context.getPackageName获得;第二个参数是布局文件

        4. 调用remoteViews.setOnClickPendingIntent(绑定处理器的控件ID , PendingIntent对象)方法

        5. 更新app widget  ,   appWidgetManager.updateAppWidget(appWidgetIds[i] ,remoteViews对象)方法

     

  • 相关阅读:
    技术网址收藏
    解决IE兼容模式的方案
    C/S通信模型与B/S通信模型介绍
    asp.net 常用于客户端注册的机器信息
    Ado.Net,关于DataSet和DataTable
    WinForm程序开发
    发送邮件-成功
    css背景全屏-视差
    ASP.NET中的随机密码生成
    javascript 替换 window.onload 的 document.ready
  • 原文地址:https://www.cnblogs.com/lee0oo0/p/2394181.html
Copyright © 2011-2022 走看看