- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
有没有什么办法可以用Delphi更改Android应用程序通知中的小图标图像(默认使用的应用程序图标)?
轻松创建通知的标准方法是:
var
aNotification: TNotification;
begin
aNotification:= aNotificationCenter.CreateNotification;
try
aNotification.Name:= 'Notification Name';
aNotification.Title:= 'Notification Title';
aNotification.AlertBody:= 'Notification Alert Body';
aNotification.EnableSound:= False;
aWorkNotification.Number:= 1;
aNotificationCenter.PresentNotification(aNotification);
finally
aNotification.Free;
end;
end;
我知道 Java 的解决方案,但我不知道如何在 Delphi 中编写相同的程序。
有人给我建议吗?
最佳答案
首先,准备png格式的图标(16 x 16,命名为例如ic_test)。使用 Deployment 将 png 图标保存到这些目录:
res\drawable-ldpi\
res\drawable-mdpi\
res\drawable-hdpi\
res\drawable-xhdpi\
res\drawable-xxhdpi\
然后使用下面的代码:
.
.
var
Ntf: JNotification;
ntfBuilder: JNotificationCompat_Builder;
ntfManager: JNotificationManager;
.
.
ntfBuilder:= TJNotificationCompat_Builder.JavaClass.init(TAndroidHelper.Context);
ntfBuilder.setSmallIcon(TAndroidHelper.Context.getResources.getIdentifier(StringToJString('ic_test'), StringToJString('drawable'), TAndroidHelper.Context.getPackageName));
ntfBuilder.setContentTitle(StrToJCharSequence('Content Title'));
ntfBuilder.setContentText(StrToJCharSequence('Content Test'));
ntfBuilder.setAutoCancel(True);
Ntf:= ntfBuilder.build;
ntfManager:= TJNotificationManager.Wrap((TAndroidHelper.Context.getSystemService(TJContext.JavaClass.NOTIFICATION_SERVICE) as ILocalObject).GetObjectID);
ntfManager.notify(1, Ntf);
.
.
如果你想使用内置系统图标使用这个常量
const
r_drawable_alert_dark_frame = 17301504;
r_drawable_alert_light_frame = 17301505;
r_drawable_arrow_down_float = 17301506;
r_drawable_arrow_up_float = 17301507;
r_drawable_bottom_bar = 17301658;
r_drawable_btn_default = 17301508;
r_drawable_btn_default_small = 17301509;
r_drawable_btn_dialog = 17301527;
r_drawable_btn_dropdown = 17301510;
r_drawable_btn_minus = 17301511;
r_drawable_btn_plus = 17301512;
r_drawable_btn_radio = 17301513;
r_drawable_btn_star = 17301514;
r_drawable_btn_star_big_off = 17301515;
r_drawable_btn_star_big_on = 17301516;
r_drawable_button_onoff_indicator_off = 17301518;
r_drawable_button_onoff_indicator_on = 17301517;
r_drawable_checkbox_off_background = 17301519;
r_drawable_checkbox_on_background = 17301520;
r_drawable_dark_header = 17301669;
r_drawable_dialog_frame = 17301521;
r_drawable_dialog_holo_dark_frame = 17301682;
r_drawable_dialog_holo_light_frame = 17301683;
r_drawable_divider_horizontal_bright = 17301522;
r_drawable_divider_horizontal_dark = 17301524;
r_drawable_divider_horizontal_dim_dark = 17301525;
r_drawable_divider_horizontal_textfield = 17301523;
r_drawable_edit_text = 17301526;
r_drawable_editbox_background = 17301528;
r_drawable_editbox_background_normal = 17301529;
r_drawable_editbox_dropdown_dark_frame = 17301530;
r_drawable_editbox_dropdown_light_frame = 17301531;
r_drawable_gallery_thumb = 17301532;
r_drawable_ic_btn_speak_now = 17301668;
r_drawable_ic_delete = 17301533;
r_drawable_ic_dialog_alert = 17301543;
r_drawable_ic_dialog_dialer = 17301544;
r_drawable_ic_dialog_email = 17301545;
r_drawable_ic_dialog_info = 17301659;
r_drawable_ic_dialog_map = 17301546;
r_drawable_ic_input_add = 17301547;
r_drawable_ic_input_delete = 17301548;
r_drawable_ic_input_get = 17301549;
r_drawable_ic_lock_idle_alarm = 17301550;
r_drawable_ic_lock_idle_charging = 17301534;
r_drawable_ic_lock_idle_lock = 17301535;
r_drawable_ic_lock_idle_low_battery = 17301536;
r_drawable_ic_lock_lock = 17301551;
r_drawable_ic_lock_power_off = 17301552;
r_drawable_ic_lock_silent_mode = 17301553;
r_drawable_ic_lock_silent_mode_off = 17301554;
r_drawable_ic_media_ff = 17301537;
r_drawable_ic_media_next = 17301538;
r_drawable_ic_media_pause = 17301539;
r_drawable_ic_media_play = 17301540;
r_drawable_ic_media_previous = 17301541;
r_drawable_ic_media_rew = 17301542;
r_drawable_ic_menu_add = 17301555;
r_drawable_ic_menu_agenda = 17301556;
r_drawable_ic_menu_always_landscape_portrait = 17301557;
r_drawable_ic_menu_call = 17301558;
r_drawable_ic_menu_camera = 17301559;
r_drawable_ic_menu_close_clear_cancel = 17301560;
r_drawable_ic_menu_compass = 17301561;
r_drawable_ic_menu_crop = 17301562;
r_drawable_ic_menu_day = 17301563;
r_drawable_ic_menu_delete = 17301564;
r_drawable_ic_menu_directions = 17301565;
r_drawable_ic_menu_edit = 17301566;
r_drawable_ic_menu_gallery = 17301567;
r_drawable_ic_menu_help = 17301568;
r_drawable_ic_menu_info_details = 17301569;
r_drawable_ic_menu_manage = 17301570;
r_drawable_ic_menu_mapmode = 17301571;
r_drawable_ic_menu_month = 17301572;
r_drawable_ic_menu_more = 17301573;
r_drawable_ic_menu_my_calendar = 17301574;
r_drawable_ic_menu_mylocation = 17301575;
r_drawable_ic_menu_myplaces = 17301576;
r_drawable_ic_menu_preferences = 17301577;
r_drawable_ic_menu_recent_history = 17301578;
r_drawable_ic_menu_report_image = 17301579;
r_drawable_ic_menu_revert = 17301580;
r_drawable_ic_menu_rotate = 17301581;
r_drawable_ic_menu_save = 17301582;
r_drawable_ic_menu_search = 17301583;
r_drawable_ic_menu_send = 17301584;
r_drawable_ic_menu_set_as = 17301585;
r_drawable_ic_menu_share = 17301586;
r_drawable_ic_menu_slideshow = 17301587;
r_drawable_ic_menu_sort_alphabetically = 17301660;
r_drawable_ic_menu_sort_by_size = 17301661;
r_drawable_ic_menu_today = 17301588;
r_drawable_ic_menu_upload = 17301589;
r_drawable_ic_menu_upload_you_tube = 17301590;
r_drawable_ic_menu_view = 17301591;
r_drawable_ic_menu_week = 17301592;
r_drawable_ic_menu_zoom = 17301593;
r_drawable_ic_notification_clear_all = 17301594;
r_drawable_ic_notification_overlay = 17301595;
r_drawable_ic_partial_secure = 17301596;
r_drawable_ic_popup_disk_full = 17301597;
r_drawable_ic_popup_reminder = 17301598;
r_drawable_ic_popup_sync = 17301599;
r_drawable_ic_search_category_default = 17301600;
r_drawable_ic_secure = 17301601;
r_drawable_list_selector_background = 17301602;
r_drawable_menu_frame = 17301603;
r_drawable_menu_full_frame = 17301604;
r_drawable_menuitem_background = 17301605;
r_drawable_picture_frame = 17301606;
r_drawable_presence_audio_away = 17301679;
r_drawable_presence_audio_busy = 17301680;
r_drawable_presence_audio_online = 17301681;
r_drawable_presence_away = 17301607;
r_drawable_presence_busy = 17301608;
r_drawable_presence_invisible = 17301609;
r_drawable_presence_offline = 17301610;
r_drawable_presence_online = 17301611;
r_drawable_presence_video_away = 17301676;
r_drawable_presence_video_busy = 17301677;
r_drawable_presence_video_online = 17301678;
r_drawable_progress_horizontal = 17301612;
r_drawable_progress_indeterminate_horizontal = 17301613;
r_drawable_radiobutton_off_background = 17301614;
r_drawable_radiobutton_on_background = 17301615;
r_drawable_screen_background_dark = 17301656;
r_drawable_screen_background_dark_transparent = 17301673;
r_drawable_screen_background_light = 17301657;
r_drawable_screen_background_light_transparent = 17301674;
r_drawable_spinner_background = 17301616;
r_drawable_spinner_dropdown_background = 17301617;
r_drawable_star_big_off = 17301619;
r_drawable_star_big_on = 17301618;
r_drawable_star_off = 17301621;
r_drawable_star_on = 17301620;
r_drawable_stat_notify_call_mute = 17301622;
r_drawable_stat_notify_chat = 17301623;
r_drawable_stat_notify_error = 17301624;
r_drawable_stat_notify_missed_call = 17301631;
r_drawable_stat_notify_more = 17301625;
r_drawable_stat_notify_sdcard = 17301626;
r_drawable_stat_notify_sdcard_prepare = 17301675;
r_drawable_stat_notify_sdcard_usb = 17301627;
r_drawable_stat_notify_sync = 17301628;
r_drawable_stat_notify_sync_noanim = 17301629;
r_drawable_stat_notify_voicemail = 17301630;
r_drawable_stat_sys_data_bluetooth = 17301632;
r_drawable_stat_sys_download = 17301633;
r_drawable_stat_sys_download_done = 17301634;
r_drawable_stat_sys_headset = 17301635;
r_drawable_stat_sys_phone_call = 17301636;
r_drawable_stat_sys_phone_call_forward = 17301637;
r_drawable_stat_sys_phone_call_on_hold = 17301638;
r_drawable_stat_sys_speakerphone = 17301639;
r_drawable_stat_sys_upload = 17301640;
r_drawable_stat_sys_upload_done = 17301641;
r_drawable_stat_sys_vp_phone_call = 17301671;
r_drawable_stat_sys_vp_phone_call_on_hold = 17301672;
r_drawable_stat_sys_warning = 17301642;
r_drawable_status_bar_item_app_background = 17301643;
r_drawable_status_bar_item_background = 17301644;
r_drawable_sym_action_call = 17301645;
r_drawable_sym_action_chat = 17301646;
r_drawable_sym_action_email = 17301647;
r_drawable_sym_call_incoming = 17301648;
r_drawable_sym_call_missed = 17301649;
r_drawable_sym_call_outgoing = 17301650;
r_drawable_sym_contact_card = 17301652;
r_drawable_sym_def_app_icon = 17301651;
r_drawable_title_bar = 17301653;
r_drawable_title_bar_tall = 17301670;
r_drawable_toast_frame = 17301654;
r_drawable_zoom_plate = 17301655;
使用以下代码(例如,对于 R.drawable.ic _menu_send 的 android 等价物):
ntfBuilder.setSmallIcon(r_drawable_ic_menu_send);
关于android - 如何使用DELPHI在Android设备上更改通知中的小图标图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38678344/
我想做的是让 JTextPane 在 JPanel 中占用尽可能多的空间。对于我使用的 UpdateInfoPanel: public class UpdateInfoPanel extends JP
我在 JPanel 中有一个 JTextArea,我想将其与 JScrollPane 一起使用。我正在使用 GridBagLayout。当我运行它时,框架似乎为 JScrollPane 腾出了空间,但
我想在 xcode 中实现以下功能。 我有一个 View Controller 。在这个 UIViewController 中,我有一个 UITabBar。它们下面是一个 UIView。将 UITab
有谁知道Firebird 2.5有没有类似于SQL中“STUFF”函数的功能? 我有一个包含父用户记录的表,另一个表包含与父相关的子用户记录。我希望能够提取用户拥有的“ROLES”的逗号分隔字符串,而
我想使用 JSON 作为 mirth channel 的输入和输出,例如详细信息保存在数据库中或创建 HL7 消息。 简而言之,输入为 JSON 解析它并输出为任何格式。 最佳答案 var objec
通常我会使用 R 并执行 merge.by,但这个文件似乎太大了,部门中的任何一台计算机都无法处理它! (任何从事遗传学工作的人的附加信息)本质上,插补似乎删除了 snp ID 的 rs 数字,我只剩
我有一个以前可能被问过的问题,但我很难找到正确的描述。我希望有人能帮助我。 在下面的代码中,我设置了varprice,我想添加javascript变量accu_id以通过rails在我的数据库中查找记
我有一个简单的 SVG 文件,在 Firefox 中可以正常查看 - 它的一些包装文本使用 foreignObject 包含一些 HTML - 文本包装在 div 中:
所以我正在为学校编写一个 Ruby 程序,如果某个值是 1 或 3,则将 bool 值更改为 true,如果是 0 或 2,则更改为 false。由于我有 Java 背景,所以我认为这段代码应该有效:
我做了什么: 我在这些账户之间创建了 VPC 对等连接 互联网网关也连接到每个 VPC 还配置了路由表(以允许来自双方的流量) 情况1: 当这两个 VPC 在同一个账户中时,我成功测试了从另一个 La
我有一个名为 contacts 的表: user_id contact_id 10294 10295 10294 10293 10293 10294 102
我正在使用 Magento 中的新模板。为避免重复代码,我想为每个产品预览使用相同的子模板。 特别是我做了这样一个展示: $products = Mage::getModel('catalog/pro
“for”是否总是检查协议(protocol)中定义的每个函数中第一个参数的类型? 编辑(改写): 当协议(protocol)方法只有一个参数时,根据该单个参数的类型(直接或任意)找到实现。当协议(p
我想从我的 PHP 代码中调用 JavaScript 函数。我通过使用以下方法实现了这一点: echo ' drawChart($id); '; 这工作正常,但我想从我的 PHP 代码中获取数据,我使
这个问题已经有答案了: Event binding on dynamically created elements? (23 个回答) 已关闭 5 年前。 我有一个动态表单,我想在其中附加一些其他 h
我正在尝试找到一种解决方案,以在 componentDidMount 中的映射项上使用 setState。 我正在使用 GraphQL连同 Gatsby返回许多 data 项目,但要求在特定的 pat
我在 ScrollView 中有一个 View 。只要用户按住该 View ,我想每 80 毫秒调用一次方法。这是我已经实现的: final Runnable vibrate = new Runnab
我用 jni 开发了一个 android 应用程序。我在 GetStringUTFChars 的 dvmDecodeIndirectRef 中得到了一个 dvmabort。我只中止了一次。 为什么会这
当我到达我的 Activity 时,我调用 FragmentPagerAdapter 来处理我的不同选项卡。在我的一个选项卡中,我想显示一个 RecyclerView,但他从未出现过,有了断点,我看到
当我按下 Activity 中的按钮时,会弹出一个 DialogFragment。在对话框 fragment 中,有一个看起来像普通 ListView 的 RecyclerView。 我想要的行为是当
我是一名优秀的程序员,十分优秀!