<legend id='IlbNC'><style id='IlbNC'><dir id='IlbNC'><q id='IlbNC'></q></dir></style></legend>
  • <small id='IlbNC'></small><noframes id='IlbNC'>

        <bdo id='IlbNC'></bdo><ul id='IlbNC'></ul>

      <tfoot id='IlbNC'></tfoot>
    1. <i id='IlbNC'><tr id='IlbNC'><dt id='IlbNC'><q id='IlbNC'><span id='IlbNC'><b id='IlbNC'><form id='IlbNC'><ins id='IlbNC'></ins><ul id='IlbNC'></ul><sub id='IlbNC'></sub></form><legend id='IlbNC'></legend><bdo id='IlbNC'><pre id='IlbNC'><center id='IlbNC'></center></pre></bdo></b><th id='IlbNC'></th></span></q></dt></tr></i><div id='IlbNC'><tfoot id='IlbNC'></tfoot><dl id='IlbNC'><fieldset id='IlbNC'></fieldset></dl></div>
      1. AppWidgetProvider 问题

        AppWidgetProvider problem(AppWidgetProvider 问题)
        <legend id='UztBJ'><style id='UztBJ'><dir id='UztBJ'><q id='UztBJ'></q></dir></style></legend>

          <tfoot id='UztBJ'></tfoot>
        1. <small id='UztBJ'></small><noframes id='UztBJ'>

            <i id='UztBJ'><tr id='UztBJ'><dt id='UztBJ'><q id='UztBJ'><span id='UztBJ'><b id='UztBJ'><form id='UztBJ'><ins id='UztBJ'></ins><ul id='UztBJ'></ul><sub id='UztBJ'></sub></form><legend id='UztBJ'></legend><bdo id='UztBJ'><pre id='UztBJ'><center id='UztBJ'></center></pre></bdo></b><th id='UztBJ'></th></span></q></dt></tr></i><div id='UztBJ'><tfoot id='UztBJ'></tfoot><dl id='UztBJ'><fieldset id='UztBJ'></fieldset></dl></div>
              <tbody id='UztBJ'></tbody>

            • <bdo id='UztBJ'></bdo><ul id='UztBJ'></ul>
                • 本文介绍了AppWidgetProvider 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 AppWidgetProvider,我需要在第一次将小部件添加到主屏幕时进行一些初始化.我知道这样做的地方是 onEnabled(Context context) 方法.我的问题是这个方法永远不会被调用(据我在 logcat 中看到的).

                  I have an AppWidgetProvider, and I need to do some initialization when a widget is first added to the home screen. I understand that the place to do it is in the onEnabled(Context context) method. My Problem is that this method is never called (As far as I can see in the logcat).

                  这是我的代码:

                  public class MyMonitorWidget extends AppWidgetProvider{
                  
                      @Override
                      public void onEnabled(Context context) {
                          super.onEnabled(context);
                  
                          Log.v("LOG", "Widget onEnabled");
                          Intent intentToFire = new Intent(UpdateAlarmReceiver.ACTION_UPDATE_ALARM); 
                          context.sendBroadcast(intentToFire);
                      } 
                  ...
                  }
                  

                  还有我的 appwidget-provider xml:

                  And my appwidget-provider xml:

                  <?xml version="1.0" encoding="utf-8"?>
                  <appwidget-provider
                    xmlns:android="http://schemas.android.com/apk/res/android"
                    android:initialLayout="@layout/widget_layout"
                    android:minWidth="146dp" 
                    android:minHeight="74dp"
                    android:label="Monitor Widget"
                    />
                  

                  在清单中:

                  <receiver android:name="MyMonitorWidget" android:label="Monitor Widget">
                          <intent-filter>
                              <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                          </intent-filter>
                          <intent-filter>
                          <action android:name="com.android.myMonitor.ACTION_NOTIFY_WIDGET"/>
                          </intent-filter>
                          <meta-data android:name="android.appwidget.provider" 
                          android:resource="@xml/monitor_widget_info"/>
                      </receiver>
                  

                  你认为是什么问题?

                  推荐答案

                  您需要添加 android.appwidget.action.APPWIDGET_ENABLED 作为另一个动作:

                  You need to add android.appwidget.action.APPWIDGET_ENABLED as another action:

                      <intent-filter>
                          <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                          <action android:name="android.appwidget.action.APPWIDGET_ENABLED" />
                      </intent-filter>
                  

                  否则,您将不会收到触发 onEnabled() 的广播.

                  Without that, you will not receive the broadcast that triggers onEnabled().

                  这篇关于AppWidgetProvider 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  script.sh: line 1: ./gradlew: No such file or directory on Jenkins(script.sh:第 1 行:./gradlew:Jenkins 上没有这样的文件或目录)
                  Arduino: using Serial and Software Serial with bluetooth module(Arduino:使用带有蓝牙模块的串口和软件串口)
                  Access native serial port on Android(在Android上访问本机串口)
                  Android: USB Communication Android lt;-gt; External Device(Android:USB通信Androidlt;-gt;外接设备)
                  Sending commands from a PC to an Android phone - via physical connection (USB, Serial, etc)(从 PC 向 Android 手机发送命令 - 通过物理连接(USB、串行等))
                  Android: RS232 Serial Communication with android device(Android:与安卓设备的RS232串行通信)

                • <i id='Bpro6'><tr id='Bpro6'><dt id='Bpro6'><q id='Bpro6'><span id='Bpro6'><b id='Bpro6'><form id='Bpro6'><ins id='Bpro6'></ins><ul id='Bpro6'></ul><sub id='Bpro6'></sub></form><legend id='Bpro6'></legend><bdo id='Bpro6'><pre id='Bpro6'><center id='Bpro6'></center></pre></bdo></b><th id='Bpro6'></th></span></q></dt></tr></i><div id='Bpro6'><tfoot id='Bpro6'></tfoot><dl id='Bpro6'><fieldset id='Bpro6'></fieldset></dl></div>

                  <small id='Bpro6'></small><noframes id='Bpro6'>

                    <tfoot id='Bpro6'></tfoot>
                        <tbody id='Bpro6'></tbody>
                    1. <legend id='Bpro6'><style id='Bpro6'><dir id='Bpro6'><q id='Bpro6'></q></dir></style></legend>
                          <bdo id='Bpro6'></bdo><ul id='Bpro6'></ul>