weixin_43405347
2019-10-13 17:14
采纳率: 50%
浏览 5.3k
已采纳

notification无法显示

按照第一行代码打的notification,不知道那里错了(水平太低),系统是ubuntu

package com.example.unit_8;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationCompat;

import android.app.Notification;
import android.app.NotificationManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    private Button Send_notice;
    private  NotificationManager notificationManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Send_notice = (Button) findViewById(R.id.send_notice);
        Send_notice.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.send_notice:
                notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
                Notification notification = new NotificationCompat.Builder(this,"default")
                        .setContentTitle("this is title")
                        .setContentText("this is text")
                        .setSmallIcon(R.mipmap.ic_launcher).build();
                notificationManager.notify(1,notification);
                Log.i("msg","R.id.send_notice");
                break;
            default:
                break;
        }
    }
}
这个是log信息
2019-10-13 17:07:18.253 28995-28995/? I/.example.unit_: Not late-enabling -Xcheck:jni (already on)

2019-10-13 17:07:18.283 28995-28995/? E/.example.unit_: Unknown bits set in runtime_flags: 0x8000

2019-10-13 17:07:18.288 28995-28995/? W/.example.unit_: Unexpected CPU variant for X86 using defaults: x86

2019-10-13 17:07:18.497 28995-28995/com.example.unit_8 W/.example.unit_: JIT profile information will not be recorded: profile file does not exits.

2019-10-13 17:07:18.498 28995-28995/com.example.unit_8 I/chatty: uid=10142(com.example.unit_8) identical 10 lines

2019-10-13 17:07:18.498 28995-28995/com.example.unit_8 W/.example.unit_: JIT profile information will not be recorded: profile file does not exits.

2019-10-13 17:07:18.504 28995-28995/com.example.unit_8 I/InstantRun: starting instant run server: is main process

2019-10-13 17:07:18.523 28995-28995/com.example.unit_8 W/RenderThread: type=1400 audit(0.0:186): avc: denied { write } for name="property_service" dev="tmpfs" ino=7189 scontext=u:r:untrusted_app:s0:c142,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0

2019-10-13 17:07:18.540 28995-29016/com.example.unit_8 D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
2019-10-13 17:07:18.541 28995-29016/com.example.unit_8 W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)

2019-10-13 17:07:18.603 28995-29016/com.example.unit_8 D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so

2019-10-13 17:07:18.604 28995-29016/com.example.unit_8 D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
2019-10-13 17:07:18.617 28995-29016/com.example.unit_8 D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so

2019-10-13 17:07:18.695 28995-28995/com.example.unit_8 W/.example.unit_: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)

2019-10-13 17:07:18.695 28995-28995/com.example.unit_8 W/.example.unit_: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)

2019-10-13 17:07:18.849 28995-29014/com.example.unit_8 D/HostConnection: HostConnection::get() New Host Connection established 0xd753b9a0, tid 29014

2019-10-13 17:07:18.855 28995-29014/com.example.unit_8 D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2 

2019-10-13 17:07:18.874 28995-29014/com.example.unit_8 W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...

2019-10-13 17:07:18.876 28995-29014/com.example.unit_8 D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0

2019-10-13 17:07:18.876 28995-29014/com.example.unit_8 D/EGL_emulation: eglCreateContext: 0xe2c1c180: maj 2 min 0 rcv 2

2019-10-13 17:07:18.877 28995-29014/com.example.unit_8 D/EGL_emulation: eglMakeCurrent: 0xe2c1c180: ver 2 0 (tinfo 0xe2cfded0)

2019-10-13 17:07:18.942 28995-29014/com.example.unit_8 W/Gralloc3: mapper 3.x is not supported

2019-10-13 17:07:18.948 28995-29014/com.example.unit_8 D/HostConnection: createUnique: call

2019-10-13 17:07:18.950 28995-29014/com.example.unit_8 D/HostConnection: HostConnection::get() New Host Connection established 0xd753d110, tid 29014

2019-10-13 17:07:18.969 28995-29014/com.example.unit_8 D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2 

2019-10-13 17:07:18.969 28995-29014/com.example.unit_8 D/eglCodecCommon: allocate: Ask for block of size 0x1000

2019-10-13 17:07:18.969 28995-29014/com.example.unit_8 D/eglCodecCommon: allocate: ioctl allocate returned offset 0x3ff801000 size 0x2000

2019-10-13 17:07:19.005 28995-29014/com.example.unit_8 D/EGL_emulation: eglMakeCurrent: 0xe2c1c180: ver 2 0 (tinfo 0xe2cfded0)

2019-10-13 17:07:19.012 28995-29014/com.example.unit_8 D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 0

2019-10-13 17:07:34.632 28995-28995/com.example.unit_8 I/msg: R.id.send_notice
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dabocaiqq 2019-10-14 09:17
    已采纳
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题