0

I have been working on this all day and can't figure out where the disconnect is. Please find below my wear app method in which I call the notification request from a broadcast receiver:

private void createWearNotification(final String notificationString, final String name, final String extensionRequested) {

    // Wear 2.0 allows for in-line actions, which will be used for "reply".
    NotificationCompat.Action.WearableExtender inlineNotification =
            new NotificationCompat.Action.WearableExtender()
                    .setHintDisplayActionInline(true)
                    .setHintLaunchesActivity(true);

    //Create View Message Intent
    Intent intent = new Intent(this, ViewMessageActivity.class);
    PendingIntent replyIntent = PendingIntent.getActivity(this, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    // Add an action to allow replies.
    NotificationCompat.Action replyAction =
            new NotificationCompat.Action.Builder(
                    R.drawable.ic_curved_arrow_right,
                    getString(R.string.reply_action),
                    replyIntent)
                    .extend(inlineNotification)
                    .build();

    int notificationId = 001;
    // The channel ID of the notification.
    String id = "my_channel_01";

    NotificationCompat.Builder builder =
            new NotificationCompat.Builder(getApplicationContext())
                    .setSmallIcon(R.drawable.ic_email)
                    .setContentTitle("")
                    .setDefaults(NotificationCompat.DEFAULT_VIBRATE)
                    .setContentText(notificationString)
                    .addAction(replyAction)
                    .setPriority(NotificationCompat.PRIORITY_DEFAULT)
                    .setContentIntent(replyIntent);

    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
    notificationManager.notify(notificationId, builder.build());
}

I have the below declaration in my androidmanifext.xml doc:

    <meta-data
        android:name="com.google.android.wearable.standalone"
        android:value="true" />

Here are my build.gradle dependencies for the wear app:

  • implementation fileTree(dir: 'libs', include: ['*.jar'])
  • implementation 'com.google.android.support:wearable:2.3.0'
  • implementation 'com.google.android.gms:play-services-wearable:15.0.1'
  • implementation 'com.android.support:percent:27.1.1'
  • implementation 'com.android.support:support-v4:27.1.1'
  • implementation 'com.android.support:recyclerview-v7:27.1.1'
  • implementation 'com.android.support:wear:27.1.1'
  • compileOnly 'com.google.android.wearable:wearable:2.3.0'
  • implementation 'com.android.support:appcompat-v7:27.1.1'
  • implementation 'com.android.support.constraint:constraint-layout:1.1.1'
  • implementation 'com.android.support:cardview-v7:27.1.1'
  • implementation 'com.android.support:support-compat:27.1.1'
  • implementation 'com.android.support:support-core-utils:27.1.1'
  • implementation 'com.android.support:support-core-ui:27.1.1'

I also get a lot of these weird comments in my Logcat file:

  • I/vndksupport: sphal namespace is not configured for this process. Loading /vendor/lib/hw/gralloc.mt2601.so from the current namespace instead.

I have tried everything - the funny thing is that when I run this from the main phone app as a regular notification it works. I am able to open up apps that I use layouts for - this only happens for notifications? What am I missing?

  • Is one of my library references conflicting with another one?
  • Is there a rule that prohibits us from being able to open up a notification from a wear app as opposed to a regular android app?
  • Is there some way to make sure that the notification bar at the bottom of the interface is enabled?

Any thoughts and suggestions are greatly appreciated!

Mike
  • 1,590
  • 8
  • 27
  • 41

1 Answers1

0

Yeah . . . so . . . I didn't assign a notification channel:

NotificationChannel issue in Android O

If you don't have a notification channel in the newer API versions (API 26+) it doesn't allow your notification to be displayed.

Of course the new documentation points it out as well: ) Otherwise, you have to notice the tiny error message amongst a million others that don't seem to have an overly negative effect:

06-20 20:15:16.251 296-900/? E/NotificationService: No Channel found for pkg=com.xxxx.xxxxxxx, channelId=null, id=1, tag=null, opPkg=com.xxxx.xxxxxxx, callingUid=10049, userId=0, incomingUserId=0, notificationUid=10049, notification=Notification(channel=null pri=0 contentView=null vibrate=default sound=null defaults=0x2 flags=0x0 color=0x00000000 actions=1 vis=PRIVATE)

Also, changed my minSdkVersion to 26 and ended up with the below Gradle dependency declarations:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.android.support:wearable:2.3.0'
    implementation 'com.google.android.gms:play-services-wearable:15.0.1'
    implementation 'com.android.support:percent:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:wear:27.1.1'
    compileOnly 'com.google.android.wearable:wearable:2.3.0'
    implementation 'com.android.support:appcompat-v7:27.1.1'
}
Mike
  • 1,590
  • 8
  • 27
  • 41