限制的Andr​​oid窗口小部件,以每个设备一个实例 [英] Restrict Android Widget to one instance per device

查看:121
本文介绍了限制的Andr​​oid窗口小部件,以每个设备一个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能限制只有一个实例可以由用户在任何时候都可以创建一个方法的Andr​​oid窗口小部件?

一个可能的方式是存储共享preference 包括柜台变量和崩溃,如果数为1,但显然我不赞成这种解决方案。 ; - )

解决方案
  

我怎么能限制只有一个实例可以由用户在任何时候都可以创建一个方法的Andr​​oid窗口小部件?

您不能。

然而,仅仅因为用户要求您的应用程序窗口小部件的多个实例并不意味着你必须要管理每个单独的数据。只是忽略的ID,并使用 updateAppWidget()方法,该方法不带任何标识。

How could I restrict Android widgets in a way that only one instance can be created by the user at all times?

A possible way is to store a SharedPreference including a counter variable and crash, if the count is 1, but obviously I'm not in favor of that solution. ;-)

解决方案

How could I restrict Android widgets in a way that only one instance can be created by the user at all times?

You can't.

However, just because the user asks for multiple instances of your app widget does not mean you have to manage separate data for each. Just ignore the IDs and use the updateAppWidget() method that does not take any IDs.

这篇关于限制的Andr​​oid窗口小部件,以每个设备一个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆