主要事件方法:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 /**   * Implementation of App Widget functionality.   */ public  class  NewAppWidget  extends  AppWidgetProvider {      /**       * 到达指定的更新时间或者当用户向桌面添加AppWidget时被调用       * */      @Override      public  void  onUpdate(Context context, AppWidgetManager appWidgetManager,              int [] appWidgetIds)      {          // There may be multiple widgets active, so update all of them          final  int  N = appWidgetIds.length;          for  ( int  i =  0 ; i < N; i++)          {              updateAppWidget(context, appWidgetManager, appWidgetIds[i]);          }      }      /**       * AppWidget的实例第一次被创建时调用       * */      @Override      public  void  onEnabled(Context context)      {          // Enter relevant functionality for when the first widget is created      }      /**       * 最后一个appWidget被删除时调用       * */      @Override      public  void  onDisabled(Context context)      {          // Enter relevant functionality for when the last widget is disabled      }      /**       * 接受广播事件       * */      @Override      public  void  onReceive(Context context, Intent intent)      {          // TODO Auto-generated method stub          super .onReceive(context, intent);      }                   /**       * 删除一个AppWidget时调用       * */      @Override      public  void  onDeleted(Context context,  int [] appWidgetIds)      {          // TODO Auto-generated method stub          super .onDeleted(context, appWidgetIds);      }      static  void  updateAppWidget(Context context,              AppWidgetManager appWidgetManager,  int  appWidgetId)      {          CharSequence widgetText = context.getString(R.string.appwidget_text);          // Construct the RemoteViews object          RemoteViews views =  new  RemoteViews(context.getPackageName(),                  R.layout.new_app_widget);          views.setTextViewText(R.id.appwidget_text, widgetText);          // Instruct the widget manager to update the widget          appWidgetManager.updateAppWidget(appWidgetId, views);      } }




本文转自 glblong 51CTO博客,原文链接:http://blog.51cto.com/glblong/1228549,如需转载请自行联系原作者

更多相关文章

  1. android Activity 之间传递复杂对象
  2. Android布局整理
  3. android ViewGroup删除子视图时应该注意的一个问题
  4. andriod一个不错的启动菜单显示屏动画效果
  5. 在ubuntu 14.04 编译android 2.3.1 错误解决办法
  6. Android(安卓)Matrix
  7. android 带清除功能的EditText
  8. android中短信协议与字段
  9. Ubuntu 12.04中Android(安卓)NDK r8d 编译 FFmpeg 0.11.1 并使用

随机推荐

  1. android:RecyclerView局部刷新那点事~
  2. Android开发工具——ADB(Android(安卓)De
  3. Android热更新实现原理
  4. Android入门学习:Android 系统框架及应用
  5. Android开发100G文档知识大全资料集合
  6. react-native webView android使用本地ht
  7. Android Drawable Resources系列10:
  8. Android跑马灯效果,字体滚动滚屏效果
  9. Android发展史(Android各版本特性-知识篇)
  10. Android简明开发教程二十四篇及示例代码