Wear for Android is not showing

I have a problem. My Android clothes emulator doesn't show notification. Here is my mobile code:

private void notifyToWear() {
        NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender()
                .setHintShowBackgroundOnly(true);

        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.ic_launcher)
                .setContentTitle("Request text")
                .setContentText("Speak something then your phone will search it.")
                .extend(wearableExtender);

        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
        notificationManager.notify(0, notificationBuilder.build());
    }

      

I call it when the MainActivity button is clicked. On my phone, it shows a notification, but not on the Android wearable emulator. Notes: + I connected between android phone and android wear emualtor. I tested with a sample card in the Android Wear App. He works.

Thank.

- Update - The code executes the click button:

(findViewById(R.id.btn_request_text)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(MyActivity.this, "Call request", Toast.LENGTH_SHORT).show();
                notifyToWear();
            }
        });

      

When I click the "Toast is show" button.

--- Update --- I am also running ElizaChat and RecipeAssistant in Wear Sample. But it doesn't work either.

+3


source to share


3 answers


Make sure the Android Wear app is installed on your device to receive notifications.

In 4.4: Settings> Security> Access to notifications
In L Preview: Settings> Sound and notifications> Access to notifications



In the Notification Access window, make sure Android Wear is checked .

+10


source


On Android 7, go to: Settings> Apps> press cogwheel> Accessibility> Notification access> Android Wear> press the switch for Tasker. See Screenshot. enter image description here



+1


source


Try the following:

NotificationCompact.Builder notBuilder = 
                                   new NotificationCompact.Builder(this);
notBuilder.setContentTitle("Title").setContentText("Text");
WearableNotifications.Builder wearBuilder = 
                                 new WearableNotifications.Builder(notBuilder);
Notification not = wearBuilder.build();

NotificationManagerCompat manager = NotificationManagerCompat.from(this);
manager.notify(0,not);

      

Hope this helps you.

0


source







All Articles