old mode 100755
new mode 100644
| | |
| | | using Com.Tencent.MM.Sdk.Openapi; |
| | | using ZXing.Mobile;
|
| | | using System.IO;
|
| | |
|
| | | using GateWay.Droid.JPush; |
| | | |
| | | namespace com.hdl.home |
| | | { |
| | | [Activity(Name = "com.hdl.home.wxapi.WXEntryActivity", Exported = true, Theme = "@android:style/Theme.Translucent", LaunchMode = Android.Content.PM.LaunchMode.SingleTask)] |
| | |
| | | //取消屏幕常亮
|
| | | BaseActivity.KeepScreenON = false;
|
| | | //隐藏底部软按键
|
| | | BaseActivity.IsHideVirualButtons = true;
|
| | |
|
| | | //设置极光调试模式,为false时只打印警告信息
|
| | | // System.Console.WriteLine($"AAA : {System.DateTime.Now.ToString()}");
|
| | | #if Release |
| | | JPushInterface.SetDebugMode(false); |
| | | //保存手机名称到本地文件 |
| | | //System.Console.WriteLine($"BBB : {System .DateTime .Now .ToString ()}"); |
| | | BaseActivity.IsHideVirualButtons = true; |
| | | |
| | | JPushInterface.Init(this); |
| | | //System.Console.WriteLine($"CCC : {System.DateTime.Now.ToString()}"); |
| | | #endif |
| | | //设置极光调试模式,为false时只打印警告信息 |
| | | // System.Console.WriteLine($"AAA : {System.DateTime.Now.ToString()}"); |
| | | |
| | | JPushInterface.SetDebugMode(true); |
| | | JPushInterface.Init(this);
|
| | | string registration_id = JPushInterface.GetRegistrationID(this); |
| | | |
| | | BaseActivity.BackKeyAction = () =>
|
| | | { |
| | |
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | |
|
| | | } |
| | | }
|
| | |
|
| | | [BroadcastReceiver(Name = "com.evoyo.home.JpushNotificationReceiver", Exported = false, Enabled = true)]
|
| | | [IntentFilter(new string[] { "cn.jpush.android.intent.REGISTRATION",
|
| | | "cn.jpush.android.intent.MESSAGE_RECEIVED",
|
| | | "cn.jpush.android.intent.NOTIFICATION_RECEIVED",
|
| | | "cn.jpush.android.intent.NOTIFICATION_OPENED",
|
| | | "cn.jpush.android.intent.CONNECTION" }, Categories = new string[] { "com.evoyo.home" })] |
| | | public class JpushNotificationReceiver : BroadcastReceiver |
| | | { |
| | | private static string TAG = "JpushNotificationReceiver"; |
| | | private NotificationManager nm; |
| | | static string ACTION = "android.intent.action.BOOT_COMPLETED"; |
| | | public override void OnReceive(Context context, Intent intent) |
| | | { |
| | | if (nm == null) |
| | | { |
| | | nm = (NotificationManager)context.GetSystemService(Context.NotificationService); |
| | | } |
| | | //base.OnReceive (context, intent); |
| | | try |
| | | { |
| | | Bundle bundle = intent.Extras; |
| | | if (intent.Action == ACTION) |
| | | { |
| | | //开机自动服务自动启动,PushService是要启动的服务 |
| | | Intent service = new Intent(context, typeof(PushService)); |
| | | context.StartService(service); |
| | | }
|
| | |
|
| | | //接收Registration Id
|
| | | if (JPushInterface.ActionRegistrationId == intent.Action)
|
| | | {
|
| | | string regId = bundle.GetString(JPushInterface.ExtraRegistrationId);
|
| | | if (!string.IsNullOrEmpty(regId))
|
| | | {
|
| | | Shared.Common.Config.Instance.RegistrationID = regId;
|
| | | Shared.Common.Config.Instance.Save();
|
| | | }
|
| | | #if Release
|
| | | //调试:记录极光ID
|
| | | Shared.Phone.UserCenter.HdlLogLogic.Current.WriteOtherText(Shared.Phone.UserCenter.DirNameResourse.JiguangFile, "receive2:" + regId, false, true);
|
| | | #endif
|
| | | } |
| | | //用户点击打开了通知 |
| | | else if (JPushInterface.ActionNotificationOpened == intent.Action) |
| | | { |
| | | OpenNotification(context, bundle); |
| | | } |
| | | //接受到推送下来的通知 |
| | | else if (JPushInterface.ActionNotificationReceived == intent.Action) |
| | | { |
| | | //int notifactionId = bundle.GetInt(JPushInterface.ExtraNotificationId); |
| | | ReceivingNotification(context, bundle); |
| | | //Shared.Common.CommonPage.Instance.SingOut(); |
| | | } |
| | | //接收到推送下来的自定义消息 |
| | | else if (JPushInterface.ActionMessageReceived == intent.Action) |
| | | { |
| | | bundle.GetString(JPushInterface.ExtraMessage);
|
| | | } |
| | | else |
| | | { |
| | | } |
| | | } |
| | | catch (System.Exception e) |
| | | { |
| | | |
| | | System.Console.WriteLine("极光推送出错:" + e.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 接收消息通知 |
| | | /// </summary> |
| | | /// <param name="context">Context.</param> |
| | | /// <param name="bundle">Bundle.</param> |
| | | private void ReceivingNotification(Context context, Bundle bundle) |
| | | { |
| | | String title = bundle.GetString(JPushInterface.ExtraNotificationTitle); |
| | | System.Console.WriteLine(TAG, " title : " + title); |
| | | String message = bundle.GetString(JPushInterface.ExtraAlert); |
| | | System.Console.WriteLine(TAG, "message : " + message); |
| | | String extras = bundle.GetString(JPushInterface.ExtraExtra); |
| | | System.Console.WriteLine(TAG, "extras : " + extras);
|
| | |
|
| | | //处理极光消息推送的逻辑函数
|
| | | Shared.Phone.UserCenter.HdlJiguangMsgPushLogic.Current.AdjustJiguangMsgPush(title, message, extras); |
| | | } |
| | | /// <summary> |
| | | /// 打开消息显示界面 |
| | | /// </summary> |
| | | /// <param name="context">Context.</param> |
| | | /// <param name="bundle">Bundle.</param> |
| | | private void OpenNotification(Context context, Bundle bundle) |
| | | { |
| | | |
| | | Intent i = new Intent(context, typeof(BaseActivity));//Intent intent=new Intent( 起始组件对象 , 目标 Service.class); |
| | | i.PutExtras(bundle); |
| | | i.SetFlags(ActivityFlags.NewTask); |
| | | context.StartActivity(i); |
| | | |
| | | String extras = bundle.GetString(JPushInterface.ExtraExtra); |
| | | //String myValue = ""; |
| | | try |
| | | { |
| | | VideoMethod(extras);
|
| | | //JSONObject extrasJson = new JSONObject(extras);
|
| | | //myValue = extrasJson.OptString("myKey");
|
| | |
|
| | | } |
| | | catch (Exception e) |
| | | { |
| | | System.Console.WriteLine(TAG, "Unexpected: extras is not a valid json", e); |
| | | return; |
| | | }
|
| | |
|
| | | //if (TYPE_THIS.equals(myValue))
|
| | | //{
|
| | | //Intent mIntent = new Intent(context, ThisActivity.class);
|
| | | //mIntent.putExtras(bundle);
|
| | | //mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
| | | //context.startActivity(mIntent);
|
| | | //}
|
| | | //else if (TYPE_ANOTHER.equals(myValue))
|
| | | //{
|
| | | //Intent mIntent = new Intent(context, AnotherActivity.class);
|
| | | //mIntent.putExtras(bundle);
|
| | | //mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
| | | //context.startActivity(mIntent);
|
| | | //}
|
| | | } |
| | | |
| | | /// <summary> |
| | | /// android通知栏点击打开可视对讲的方法 |
| | | /// </summary> |
| | | /// <param name="hiddenJson">云端推过来的数据</param> |
| | | private void VideoMethod(string hiddenJson) |
| | | {
|
| | | var hiddanJson = Newtonsoft.Json.Linq.JObject.Parse(hiddenJson); |
| | | if (hiddanJson == null) |
| | | { |
| | | return; |
| | | } |
| | | var json = Newtonsoft.Json.Linq.JObject.Parse(hiddanJson["HiddanJson"].ToString()); |
| | | if (json == null) |
| | | { |
| | | return; |
| | | } |
| | | Shared.Phone.VideoPhone.ESVideoInfo eSVideoInfo = new Shared.Phone.VideoPhone.ESVideoInfo(); |
| | | if (json["uuid"].ToString().Contains(",")) |
| | | { |
| | | var uuid = json["uuid"].ToString().Split(','); |
| | | eSVideoInfo.ESVideoUUID = uuid[0]; |
| | | |
| | | } |
| | | else |
| | | { |
| | | eSVideoInfo.ESVideoUUID = json["uuid"].ToString(); |
| | | } |
| | | |
| | | eSVideoInfo.DeviceName = Language.StringByID(Shared.R.MyInternationalizationString.theOutdoorUnit); |
| | | eSVideoInfo.ESRoomID = int.Parse(json["roomno"].ToString()); |
| | | if (!string.IsNullOrEmpty(json["unitno"].ToString())) |
| | | { |
| | | string str = json["unitno"].ToString(); |
| | | string str1 = str.Substring(0, 2).TrimStart('0'); |
| | | string str2 = str.Substring(2, 2).TrimStart('0'); |
| | | eSVideoInfo.RoomName = str1 + Language.StringByID(Shared.R.MyInternationalizationString.dong) + str2 + Language.StringByID(Shared.R.MyInternationalizationString.unit); |
| | | } |
| | | |
| | | Shared.Phone.VideoPhone.ESVideo.ShowESvideoVideoIntercom(eSVideoInfo);
|
| | |
|
| | | } |
| | | } |
| | | } |
| | | |
| | | namespace Shared |
| | |
| | | return stream.ToArray(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |