Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/app_mobile_and.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ void sendNotification(uintptr_t java_vm, uintptr_t jni_env, uintptr_t ctx, char
jmethodID setContentText = find_method(env, cls, "setContentText", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;");
(*env)->CallObjectMethod(env, builder, setContentText, bodyStr);

int iconID = 17629184; // constant of "unknown app icon"
jclass classContext = (*env)->GetObjectClass(env, (jobject)ctx);
jmethodID getApplicationInfoMethod = find_method(env, classContext, "getApplicationInfo", "()Landroid/content/pm/ApplicationInfo;");
jobject appInfo = (*env)->CallObjectMethod(env, (jobject)ctx, getApplicationInfoMethod);
jclass applicationInfoClass = find_class(env, "android/content/pm/ApplicationInfo");
jfieldID iconFieldID = (*env)->GetFieldID(env, applicationInfoClass, "icon", "I");
jint iconID = (*env)->GetIntField(env, appInfo, iconFieldID);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very glad you tracked this down. Feels like the hard part is already done :). Now we just need to get the API right for the icon types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope it's useful! I got familiar with the JNI stuff doing the battery optimization calls, so I'm happy to dive into more JNI where it's needed.

jmethodID setSmallIcon = find_method(env, cls, "setSmallIcon", "(I)Landroid/app/Notification$Builder;");
(*env)->CallObjectMethod(env, builder, setSmallIcon, iconID);

Expand Down
Loading