小编vai*_*hav的帖子

无法展开RemoteViews:StatusBarNotification

之前已经问过这个问题,但没有一个答案帮助我发布我的案例.

我正在尝试使用布局文件构建自定义通知.但是我收到以下错误:

android.app.RemoteServiceException:从包com.eswaraj.app.eswaraj发布的错误通知:无法展开RemoteViews:StatusBarNotification(pkg = com.eswaraj.app.eswaraj user = UserHandle {0} id = 8888 tag = null score = 0:通知(pri = 0 contentView = com.eswaraj.app.eswaraj/0x7f030052 vibrate = null sound = null defaults = 0x0 flags = 0x0 kind = [null]))

我的布局文件是:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="left">

<com.makeramen.RoundedImageView
    android:id="@+id/nImage"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:src="@drawable/profile_image"
    android:padding="15dp"
    android:scaleType="fitCenter"
    app:riv_corner_radius="30dip"
    app:riv_border_width="2dip"
    app:riv_border_color="#333333"
    app:riv_mutate_background="true"
    app:riv_oval="true"/>

<TextView
    android:id="@+id/nTitle"
    android:text="eSwaraj: Your voice is heard"
    android:layout_toRightOf="@+id/nImage"
    android:paddingTop="12dp"
    android:textSize="20dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<TextView
    android:id="@+id/nMessage"
    android:layout_below="@+id/nTitle"
    android:layout_toRightOf="@+id/nImage"
    android:text="Your comaplaint …
Run Code Online (Sandbox Code Playgroud)

notifications android android-layout remoteview

8
推荐指数
1
解决办法
8981
查看次数

Android:ScrollView不滚动

我正在尝试创建一个带有标题的布局,在它下面有一个横幅,然后在横幅下面创建一些ListView.我希望整个屏幕可以滚动,除了标题.现在我知道ListView不会在ScrollView中滚动,所以我已经将ListView的高度设置得足够大以显示所有项目.问题是,即使经过这些更改,我也看到ListView独立滚动,整个屏幕不可滚动.

`

<include
    android:id="@+id/logo_header"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    layout="@layout/screen_header" />

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:layout_weight="0.8"
            android:background="#f2f2f2">

            <include
                android:id="@+id/mcUser"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                layout="@layout/complaint_reporters_details"
                android:layout_weight="2" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="horizontal"
                android:weightSum="9"
                android:layout_weight="2">

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:orientation="vertical"
                    android:weightSum="1"
                    android:layout_weight="3"
                    android:focusableInTouchMode="false"
                    android:paddingLeft="30dp"
                    android:paddingRight="30dp">

                    <ImageView android:id="@+id/mcShowList"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:gravity="center"
                        android:layout_marginTop="5dp"
                        android:layout_marginBottom="5dp"
                        android:scaleType="fitXY"
                        android:src="@drawable/list_icon"
                        android:layout_weight="0.2" />

                    <TextView android:id="@+id/mcShowList_label"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:gravity="center"
                        android:textStyle="bold"
                        android:textSize="12sp"
                        android:textColor="#929292"
                        android:maxLines="1"
                        android:text="List"
                        android:layout_weight="0.8"
                        android:layout_marginTop="-8dp" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:orientation="vertical"
                    android:weightSum="1"
                    android:layout_weight="3"
                    android:gravity="center_vertical|center_horizontal"
                    android:paddingLeft="30dp"
                    android:paddingRight="30dp">

                    <ImageView android:id="@+id/mcShowMap" …
Run Code Online (Sandbox Code Playgroud)

android listview scrollview android-layout android-listview

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

转到HTTP服务器性能问题

我正在编写一个事件收集器http服务器,它将负载很重.因此,在http处理程序中,我只是对事件进行反序列化,然后在goroutine中的http请求 - 响应周期之外运行实际处理.

有了这个,我看到如果我以每秒400个请求命中服务器,那么99百分位的延迟低于20毫秒.但是一旦我将请求率提高到每秒500,延迟就会超过800毫秒.

任何人都可以帮我解释一下原因是什么,以便我可以探索更多.

package controller

import (
    "net/http"
    "encoding/json"
    "event-server/service"
    "time"
)

func CollectEvent() http.Handler {
    handleFunc := func(w http.ResponseWriter, r *http.Request) {
        startTime := time.Now()
        stats.Incr("TotalHttpRequests", nil, 1)
        decoder := json.NewDecoder(r.Body)
        var event service.Event
        err := decoder.Decode(&event)
        if err != nil {
            http.Error(w, "Invalid json: " + err.Error(), http.StatusBadRequest)
            return
        }
        go service.Collect(&event)
        w.Write([]byte("Accepted"))
        stats.Timing("HttpResponseDuration", time.Since(startTime), nil, 1)
    }

    return http.HandlerFunc(handleFunc)
}
Run Code Online (Sandbox Code Playgroud)

我以每秒1000个请求运行测试并对其进行了分析.以下是结果.

(pprof) top20
Showing nodes accounting for 3.97s, 90.85% of 4.37s total
Dropped 89 nodes …
Run Code Online (Sandbox Code Playgroud)

performance latency http go server

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