【通知开关】开【通知开关】
【通知标题】推送通知标题【通知标题】
【文字】测试通知,点击通知跳转的指定URL【文字】
【网址】https://gxusb.com/81.html【网址】
程序启动时会执行的事件
--程序启动时会执行的事件
--远程推送通知栏消息
require "import"
import "android.app.*"
import "android.os.*"
import "android.widget.*"
import "android.view.*"
import "android.content.Context"
import "android.content.Intent"
import "android.app.PendingIntent"
import "android.app.Notification"
urla="https://gxusb.com/81.html"--换自己的远程链接
--远程链接,可使用的讯飞语记,其他网页,过滤规则可以需要重写。
Http.get(urla,nil,nil,nil,function(code,content)
if code==200 then
content=content:gsub("amp;","") or content;
content=content:gsub("<div>","") or content;
content=content:gsub("</div>","") or content;
--content=content:gsub("amp;","") or content;
content=content:gsub(" ","") or content;
local 开关=content:match("【通知开关】(.-)【通知开关】")
local 通知标题=content:match("【通知标题】(.-)【通知标题】")
local 文字=content:match("【文字】(.-)【文字】")
local urlb=content:match("【网址】(.-)【网址】")
if 开关=="开" then
mBuilder = Notification.Builder(this);
mBuilder.setSmallIcon(R.drawable.icon)--设置图标
mBuilder.setContentTitle(通知标题);--大标
mBuilder.setContentText(文字);--小标
mBuilder.setAutoCancel(true);--设置这个标志当用户单击面板就可以让通知将自动取消
mBuilder.setDefaults( Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) --使用默认震动
notificationManager =activity.getSystemService(Context.NOTIFICATION_SERVICE)
notificationIntent =Intent(Intent.ACTION_VIEW, Uri.parse(urlb))
pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
mBuilder.setContentIntent(pendingIntent).setAutoCancel(true)
mBuilder.setOngoing(false)--ture,设置他为一
mBuilder.setPriority(Notification.PRIORITY_DEFAULT) --设置该通知优先级
notificationManager.notify(1, mBuilder.build()) --发送通知
--notificationManager.cancel(1); --关闭通知
--[[以上通知栏代码原创为柯南大佬。远程推送以及注释来自偶尔想吃榨菜]]
elseif 开关=="关" then
-- print"关"
return true
end
end
end)
--分割线
万水千山总是情,给个打赏行不行。
打赏

百度已收录