Android的活动上4.3设备速度慢速度慢、设备、Android

2023-09-07 22:45:28 作者:时光叫我别念他°

我开发了一个应用程序,将视频流从网络。我有一个活动,列出了影片,包括他们的图标,标题和状态(最近更新)。对于每一行,还有一个缩略图视频,视频标题,然后是新鲜的图标,表示这是一个新的上传。

在模拟器,这个工作比较精细。在2.3和4.0.3宏达电Evo设备,它的伟大工程。上的HTC One 4.3装置,这次活动实在是太慢了。单击列表中,这需要你到另一个活动上的一个项目,工作正常。其他活动,除了列表中的活性确定。

下面是我到目前为止已经试验。我已删除从XML的新鲜的图标,和它的工作太棒了。所以,我认为它是与此图标。该图像是相当大(1000x900px),但只有在50x50dp呈现。我还没有尝试过瘦身此图片看性能。但是,如果这是一个问题,怎么来的旧的HTC手机可以完美地呈现它。

从的HTC One与老HTC手机唯一不同的是,HTC的一个有一个操作栏,并上了年纪的手机使用的设备专用菜单键。

有没有一种方法来检查内存使用量或流程,同时在设备上运行的应用程序,看看它为什么要花这么慢?

更新: 我已经调整了图像100x100px,这是绝对快得多。但我仍然发现有一定的滞后性。

文章图片索尼公布可升Android 4.3固件设备清单 共1张

下面是该列表行的布局:

 < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:paddingBottom会=2DP
    机器人:paddingTop =2DP>

    < ImageView的
        机器人:ID =@ + ID /图标
        机器人:layout_width =100dp
        机器人:layout_height =100dp
        机器人:layout_alignParentLeft =真
        机器人:layout_centerVertical =真/>

    < ImageView的
        机器人:ID =@ + ID /状态
        机器人:layout_width =50dp
        机器人:layout_height =50dp
        机器人:layout_alignParentRight =真
        机器人:layout_alignParentTop =真/>

    <的TextView
        机器人:ID =@ + ID /标题
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_centerVertical =真
        机器人:layout_marginLeft =10dp
        机器人:layout_toLeftOf =@ ID /状态
        机器人:layout_toRightOf =@ ID /图标/>
< / RelativeLayout的>
 

解决方案

尝试启动方法分析(见图片),然后启动你的活动,然后通过再次撞击的画面相同的按钮停止方法分析。 Eclipse会生成一份报告,在那里你会看到哪些方法需要什么时间执行。因此,你可以找出哪些方法会造成延迟。

I developed an app that would stream videos from the web. I have an activity that lists the videos including their icons, titles and status (newly updated). For every row, there is a thumbnail for the video, the video title, and then a "fresh" icon to indicate it's a new upload.

In the emulator, this works relatively fine. In a 2.3 and 4.0.3 HTC Evo devices, it works great. On an HTC One 4.3 device, this activity is really slow. Clicking an item on the list, which takes you to another activity, works fine. Other activities are OK except the list activity.

Here's what I've experimented so far. I have removed the "fresh" icon from the xml, and it worked great. So I assumed it has something to do with this icon. The image is quite large (1000x900px) but only rendered in 50x50dp. I haven't tried downsizing this image to see the performance. But if this is the problem, how come the older HTC phones can render it perfectly.

Only other difference from HTC One and the older HTC phones is that HTC One has an action bar and the older phones use the dedicated menu key in the device.

Is there a way to check the memory usage or processes while running an app in a device to see why it's taking so slow?

UPDATE: I have resized the image to 100x100px, and it's definitely faster. But I still notice there is some lag.

Here's the layout for that list row:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="2dp"
    android:paddingTop="2dp" >

    <ImageView
        android:id="@+id/icon"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true" />

    <ImageView
        android:id="@+id/status"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true" />

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="10dp"
        android:layout_toLeftOf="@id/status"
        android:layout_toRightOf="@id/icon" />
</RelativeLayout>

解决方案

Try to start method profiling (see picture), then launch your activity, then stop method profiling by hitting the same button in the picture again. Eclipse will generate a report where you will see which method takes what time to execute. Thus you can find out which method caused the delay.