我想使用主题中的颜色将其应用于我的应用渲染的某些HTML.我想知道我能做到吗?
我希望使用在themes.xml中指定的颜色:
<item name="colorBackground">@android:color/background_dark</item>
<item name="textColorPrimary">@android:color/primary_text_dark</item>
Run Code Online (Sandbox Code Playgroud)
因此,看着他们,他们以同样的方式宣布.所以我想我也可以用同样的方式访问它们.
这不是原因.尝试以这种方式访问这些值时:
TypedValue tv = new TypedValue();
getTheme().resolveAttribute(android.R.attr.colorBackground, tv, true);
System.out.println("tv.string=" + tv.string);
System.out.println("tv.coerced=" + tv.coerceToString());
int colorResourceId = getResources().getColor(tv.resourceId);
System.out.println("colorResourceId=" + colorResourceId);
tv = new TypedValue();
getTheme().resolveAttribute(android.R.attr.textColorPrimary, tv, true);
System.out.println("tv.string=" + tv.string);
System.out.println("tv.coerced=" + tv.coerceToString());
colorResourceId = getResources().getColor(tv.resourceId);
System.out.println("colorResourceId=" + colorResourceId);
Run Code Online (Sandbox Code Playgroud)
我得到了这个结果:
I/System.out( 1578): tv.string=null
I/System.out( 1578): tv.coerced=#ffffffff
I/System.out( 1578): colorResourceId=-1
I/System.out( 1578): tv.string=res/color/primary_text_light.xml
I/System.out( 1578): tv.coerced=res/color/primary_text_light.xml
I/System.out( 1578): colorResourceId=-16777216
Run Code Online (Sandbox Code Playgroud)
结果不同.第一个实际上给了我"#fffffff"的颜色,这对我有用,第二个只给我一个xml.
我是否需要在这里跳过几个箍来解决实际的颜色?我的初衷是否有用?也许它不起作用,因为颜色可以是任意的drawables?
我没有找到任何相关的文件,但如果你知道的话,请指点我.
顺便说一句.我也尝试过obtainStyledAttributes(),但这基本上都是一样的问题.
我的应用程序中有一个自动错误报告工具,其中包含有用的调试信息.
我想要包括的一件事是ROM提供商.特别是我想知道用户是否正在运行自定义ROM,最好是使用版本号.
知道如何以编程方式检索此信息吗?
---取自Quintin(见下文)
public static String getReadableModVersion() {
String modVer = getSystemProperty(Constants.SYS_PROP_MOD_VERSION);
return (modVer == null || modVer.length() == 0 ? "Unknown" : modVer);
}
Run Code Online (Sandbox Code Playgroud)
这个常数是这样的:
public static final String SYS_PROP_MOD_VERSION = "ro.modversion";
Run Code Online (Sandbox Code Playgroud)
这是getSystemProperty();
public static String getSystemProperty(String propName){
String line;
BufferedReader input = null;
try
{
Process p = Runtime.getRuntime().exec("getprop " + propName);
input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
line = input.readLine();
input.close();
}
catch (IOException ex)
{
Log.e(TAG, "Unable to read sysprop " + propName, …Run Code Online (Sandbox Code Playgroud) 为了将离线客户端写入Google阅读器服务,我想知道如何最好地与服务同步.
似乎还没有官方文档,我到目前为止找到的最佳来源是:http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI
现在考虑一下:有了上面的信息,我可以下载所有未读的项目,我可以指定下载多少项目并使用atom-id我可以检测到已经下载的重复项目.
对我来说缺少的是一种指定我只想要自上次同步以来的更新的方法.我可以说给我10个(参数n = 10)最新(参数r = d)条目.如果我指定参数r = o(日期升序),那么我也可以指定参数ot = [最后一次同步],但只有那时,升序顺序没有任何意义,当我只想阅读一些项目而不是所有项目项目.
知道如何解决这个问题,而无需再次下载所有项目,只是拒绝重复项目?不是一种非常经济的民意调查方式.
有人建议我可以指定我只想要未读条目.但是为了使该解决方案能够像Google Reader再次提供此条目一样,我需要将它们标记为已读.反过来,这意味着我需要在客户端保持自己的已读/未读状态,并且当用户登录到Google阅读器的在线版本时,条目已被标记为已读.这对我不起作用.
干杯,马里亚诺