小编Liy*_*iya的帖子

为通知操作设置不同的颜色

您好,我正在通过两个操作设置来电通知:接听和拒绝。我需要为 Answer 操作设置绿色,为 Decline 设置红色。但我找不到解决方案。

这是我的代码:

NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext,"Call")
                .setSmallIcon(R.drawable.ic_stat_rider_logo)
                .setContentIntent(contentIntent)
                .setContentTitle(generalFunc.retrieveLangLBl("","LBL_SINCH_NOTIFICATION_CONTENT"))
                .setContentText(call.getHeaders().get("Name") +" "+ generalFunc.retrieveLangLBl("","LBL_SINCH_NOTIFICATION_TITLE"));

        builder.addAction(getServiceNotificationAction(mContext, denyCallIntent(mContext,call),R.drawable.ic_call_icon, R.string.decline));
        builder.addAction(getServiceNotificationAction(mContext, answerCallIntent(mContext,call),R.drawable.com_facebook_close, R.string.answer));
 if (callActivityRestricted()) {
        builder.setFullScreenIntent(contentIntent, true);
        builder.setPriority(NotificationCompat.PRIORITY_HIGH);
        builder.setCategory(NotificationCompat.CATEGORY_CALL);
    }
 private NotificationCompat.Action getServiceNotificationAction(Context context, Intent intent, int iconResId, int titleResId) {
        PendingIntent pendingIntent = Build.VERSION.SDK_INT >= 26 ? PendingIntent.getForegroundService(context, 0, intent, 0)
                : PendingIntent.getService(context, 0, intent, 0);

        return new NotificationCompat.Action(iconResId, context.getString(titleResId), pendingIntent);
    }
Run Code Online (Sandbox Code Playgroud)

我尝试了 setColor() ,但它为这两个操作设置了唯一的颜色。

请帮我解决这个问题。提前致谢

java notifications android builder

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

没有得到套接字连接的响应

我无法在套接字连接中得到响应,我无法理解代码有什么问题.我能够使用ip地址和端口号建立套接字连接,并且它正在进入

    if (nsocket.isConnected()) {} 
Run Code Online (Sandbox Code Playgroud)

当我尝试使用telnet时,我可以得到响应.但输入还有一些其他参数,如:

POST/setMap HTTP/1.1主机:192.168.1.1 Content-Type:application/json; charset = utf-8内容长度:1234

{"cmd":"request_get_file_list","验证":"CVS"}

我不知道如何在代码中包含内容类型,长度等连接属性.

这是代码:

public class WebService {

public static String devicelisting() {
    Socket nsocket;

    String response = null;

    try {
        nsocket = new Socket("192.168.1.1", 6666);
        if (nsocket.isConnected()) {

            JSONObject json = new JSONObject();
            json.put("cmd", "request_get_file_list");
            json.put("verification", "CVS");
            Log.i("AsyncTask", "doInBackground: Creating socket");
            // nsocket = new Socket();
             OutputStreamWriter out = new OutputStreamWriter(nsocket.getOutputStream(), StandardCharsets.UTF_8);
                out.write(json.toString());
            Log.i("Webservice", "json.toString"+json.toString());

            InputStream in = new BufferedInputStream(nsocket.getInputStream());
            BufferedReader r = new BufferedReader(new InputStreamReader(in));
            StringBuilder stringbuilder = …
Run Code Online (Sandbox Code Playgroud)

sockets android json

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

ViewPager滑动和RecyclerView滚动之间的冲突

在我的应用程序中,我有一个ViewPager不同的选项卡.每个选项卡仅由一个RecyclerView可以垂直滚动的选项卡组成.

我的问题是,当我尝试导航到其他选项卡并向左或向右滑动RecyclerView's时,首先检测滚动,而不是转到另一个选项卡RecyclerView滚动.

我尝试了以下回收者视图的属性:

         rv_home.setNestedScrollingEnabled(false);
Run Code Online (Sandbox Code Playgroud)

那个时间ViewPager滑动按预期工作但是垂直滚动recycler view禁用.我该怎么办?

android android-recyclerview

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