标签: android-2.0-eclair

如何阅读Android 2.0上的联系人

我正在研究Android 2.0,我正在尝试接收所有联系人的列表.

由于android.provider.Contacts.People已过时,我不得不使用android.provider.ContactsContract,但我不能找到如何使用适当的例子(例如:检索电话簿的所有联系人的列表).

谁知道在哪里可以找到这样的例子?

android contacts android-2.0-eclair

95
推荐指数
6
解决办法
9万
查看次数

即使使用WakeLock,当Droid/Nexus One屏幕关闭时,Accelerometer也会停止提供样品

我有一些代码可以扩展服务并在Android上记录onSensorChanged(SensorEvent事件)加速计传感器读数.我希望能够记录这些传感器读数,即使设备关闭(我对电池寿命非常小心,并且在运行时显而易见).虽然屏幕上的日志工作正常,但在2.0.1 Motorola Droid和2.1 Nexus One上.

但是,当手机进入休眠状态时(通过按下电源按钮),屏幕关闭,onSensorChanged事件停止传送(每隔N次使用一次Log.e消息进行验证onSensorChanged).

该服务获取wakeLock以确保它在后台运行; 但是,它似乎没有任何影响.我已经尝试了各种各样的PowerManager.唤醒锁,但它们似乎都不重要.

_WakeLock = _PowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Tag");
_WakeLock.acquire();
Run Code Online (Sandbox Code Playgroud)

关于在屏幕关闭时你是否能真正从传感器获取数据的报道相互矛盾......任何人都对更现代版的Android(Eclair)和硬件有任何经验吗?

这似乎表明它在Cupcake中工作:http: //groups.google.com/group/android-developers/msg/a616773b12c2d9e5

PS:完全相同的代码在G1上的1.5中按预期工作.当屏幕关闭,应用程序在后台等时,记录继续.

android accelerometer power-management android-2.0-eclair

25
推荐指数
1
解决办法
2万
查看次数

最好的Android 2.0开发书籍?

我正在寻找Android 2.0开发的单一书籍来源.虽然我可能对一般的Android开发书感到满意,但是一本涵盖2.0功能的书是理想的.

什么是最好的Android 2.0书籍,或即将推出?

android android-2.0-eclair

21
推荐指数
1
解决办法
1万
查看次数

如何强制GridView使用整个屏幕(无论显示尺寸如何)?

我有以下布局文件,后面有一个GridViewImageView后面的布局文件.

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#FFFFFF">
    <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:layout_marginRight="-70dp"
            android:layout_marginBottom="-50dp"
            android:src="@drawable/s_background"/>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent">
        <GridView xmlns:android="http://schemas.android.com/apk/res/android"
                  android:id="@+id/gridview"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:columnWidth="90dp"
                  android:numColumns="auto_fit"
                  android:verticalSpacing="10dp"
                  android:horizontalSpacing="10dp"
                  android:stretchMode="columnWidth"
                  android:gravity="center"/>
    </LinearLayout>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

这是我用于网格的每个"单元格"中的实际项目的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent">
    <TextView
            android:id="@+id/cardInGrid"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:singleLine="true"
            android:textSize="40sp"
            android:textColor="#660099"
            android:typeface="serif"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我现在在设备上看到以下内容:

在此输入图像描述

是否有任何方法可以使GridView中的每个项目更大,所以它适合屏幕的大小,我在显示屏的底部没有未使用的空白区域?

这在模拟器上工作正常,但在设备上屏幕分辨率更高,因此在底部获得空白区域.

非常感谢

android gridview android-2.0-eclair android-2.1-eclair

7
推荐指数
2
解决办法
1万
查看次数

在android中刷新

可能重复:
如何实现Android Pull-to-Refresh

我已经在我的应用程序中实现了pull刷新,它在2.2中运行良好,但在2.0中却没有.

我在2.0中找不到方法'smoothScrollBy()'.

任何人都可以给我这个问题的解决方案或任何其他选择?我怎样才能在iphone中实现刷新功能?

谢谢..

android android-2.0-eclair android-2.2-froyo

2
推荐指数
1
解决办法
8249
查看次数