- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
由于似乎无法将 EditText 放入 AppWidget,因此我想在单击它时打开带有 EditText 的 PopUpWindow。
我知道如何从 AppWidget 打开 Activity,我也知道如何从 Activity 打开 PopUpWindow。但是,我不知道如何从 AppWidget 打开 PopUpWindow。我查看了 javadoc 中的许多类(Intent、RemoteViews、PendingIntent 等),但找不到如何启动此 PopUpWindow。任何帮助将不胜感激。
最佳答案
您知道 AppWidgetProvider
是一个 BroadcastReceiver
。 Android Doc说:
A BroadcastReceiver object is only valid for the duration of the call to onReceive(Context, Intent). Once your code returns from this function, the system considers the object to be finished and no longer active.
This has important repercussions to what you can do in an onReceive(Context, Intent) implementation: anything that requires asynchronous operation is not available, because you will need to return from the function to handle the asynchronous operation, but at that point the BroadcastReceiver is no longer active and thus the system is free to kill its process before the asynchronous operation completes.
In particular, you may not show a dialog or bind to a service from within a BroadcastReceiver. For the former, you should instead use the NotificationManager API. For the latter, you can use
Context.startService()
to send a command to the service.
看来你有三种方法:
关于android - 从 AppWidget 打开 PopUpWindow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8991214/
我正在使用一个服务来更新我的 AppWidgets,该服务监听发布/订阅 channel 并且基本上永远在后台运行,每当收到更新时更新 AppWidgets。 我不担心电池生命周期,因为设备始终处于接
我想获取与应用小部件 ID 关联的应用小部件布局。 在 appwidget 的 Widget provider 类中,android 文档提供了一种获取 appwidget id 的简单方法... p
我在 eclipse 中有 2 个 android 项目,一个是主应用程序,另一个是主屏幕的小部件。我想在用户单击小部件时打开主应用程序。但是,当我使用来自主应用程序的 Activity 创建 Int
我在 Android 市场上发布了几个应用程序小部件,它们大部分都运行良好。但是我注意到使用共享首选项保存的首选项有时会重置为默认值。这种情况下的默认值是硬编码变量。保存在 xml 中的共享首选项与用
假设我有一个 android 项目,它有可以添加到应用程序启动器的可用 appWidget。该项目还有一个显示我创建的 appWidget 的 Activity 。 问题:对于启动器,appWidge
我创建了一个显示数字时钟的简单应用程序小部件,并为该时钟设置了一个 PendingIntent。(即)当用户点击 TextView 时,一个拨号盘被打开。它工作得很好。但是,当我打开一些应用程序(如
我有一个小部件,可以让您从 2 种尺寸中进行选择,它还有一个配置。由于某种原因,一段时间后,我的小部件上的按钮将解除绑定(bind),您将无法单击任何内容。我不知道为什么会这样。难道是我的 OnRec
我遇到的问题是,当我调试我的小部件时,它会更改布局,但当我只是运行它时,它不起作用。根据我的调试消息,它设置了 setOnClickPendingIntent 但它没有启动我的服务。 简而言之,我的小
从主屏幕删除我的最后一个 appWidget 实例后,onDisabled、onEnabled 不工作。 我将我的小部件注册为广播接收器,主屏幕上没有实例但广播接收,而且我看到我的日志写在我的 app
我有一个 appwidget,我想在整个 appwidget 布局上添加一个点击监听器,而不仅仅是在 TextView ecc 上。这是行不通的 remoteViews.setOnClickPendi
我一直致力于实现一个可以手动更新的 AppWidget。但是,出于某种原因,Widget 除了第一次显示时不会更新,并且该更新是通过 Configuration Activity 进行的,它与代码几乎
当我的主要 Activity 暂停时,我需要更新我的 AppWidget。我尝试在主要 Activity 的 onPause() 中使用以下代码: super.onPause(); AppWidget
编辑:我安装了我的应用程序 4.x 设备,没有问题。问题仅存在于 3.x 设备。 我正在尝试在用户设置时手动更新 AppWidget设备上的更改。为此,我使用与此类似的代码: ComponentNam
我正在 android 上创建一些应用程序小部件。我还想重新使用 appwidgets 的布局,这样我就可以在我的 Activity 中进行控制,使其看起来一样。 为了工作正常,我遇到的问题是我希望得
我在编写启动器时遇到了 appwidgets 的问题。只有 Clock widget 正常工作,其他不正常: 部分代码: final AppWidgetHostView hostView = mApp
当我在 Debug模式下运行时,我似乎无法到达服务内部的任何断点,这是为什么? @Override public void onUpdate(Context context, AppWidge
我创建了一个显示简单 TextView 的小部件,它可以在配置 Activity 中作为 Edittext 进行编辑。我使用共享首选项保存输入的文本,因此用户可以点击小部件来编辑文本,并且已经输入的文
我有一个应用程序小部件的问题。它没有配置 Activity 。当我在模拟器中设置 android:updatePeriodMillis="10000" (知道不应该这样做,但它只是为了测试)时 onU
您好,我的 Android 小部件出现了一个非常奇怪的问题,我仔细查看了很多地方,但我似乎无法弄清楚哪里出了问题。基本上我在我的小部件中调用了一个 pendingintent 广播,并在 onreci
这就是我想从我的 AppWidget 中得到的: 配置 Activity 出现,当小部件被添加到屏幕时//到目前为止一切顺利 保存配置后,启动更新小部件的服务//目前为止一切正常 定期安排警报以运行更
我是一名优秀的程序员,十分优秀!