private bool IsNotificationPermissionSet() { ComponentName cn = new ComponentName(this, Java.Lang.Class.FromType(typeof(TsumTsumNotificationListener))); string flat = Android.Provider.Settings.Secure.GetString(this.ContentResolver, "enabled_notification_listeners"); return(flat != null && flat.Contains(cn.FlattenToString())); }
public static bool IsNotificationListenerEnabled() { ComponentName cn = new ComponentName(Application.Context, Java.Lang.Class.FromType(typeof(Catcher)).Name); string flat = Settings.Secure.GetString(Application.Context.ContentResolver, "enabled_notification_listeners"); if (flat != null && flat.Contains(cn.FlattenToString())) { return(true); } return(false); }
public void ExecuteBadge(Context context, ComponentName componentName, int badgeCount) { var extra = new Bundle(); extra.PutInt(BundleBadgeCount, badgeCount); extra.PutString(BundleComponentName, componentName.FlattenToString()); if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) { context.ContentResolver.Call(Uri.Parse(ContentUrl), "setAppUnreadCount", null, extra); } }
private void SaveFolder(FolderModel folder) { System.IO.FileStream @out = null; try { @out = (System.IO.FileStream)OpenFileOutput(string.Format("folder{0:D}", folder.Id), Android.Content.FileCreationMode.Private); @out.WriteByte(byte.Parse(string.Format("{0:D}\n", folder.Width))); @out.WriteByte(byte.Parse(string.Format("{0:D}\n", folder.Height))); foreach (ActivityInfo appInFolder in folder.Apps) { ComponentName name = new ComponentName(appInFolder.PackageName, appInFolder.Name); @out.WriteByte(byte.Parse((name.FlattenToString() + "\n"))); } } catch (FileNotFoundException e) { System.Console.WriteLine(e.Message); System.Console.Write(e.StackTrace); } catch (IOException e) { System.Console.WriteLine(e.ToString()); System.Console.Write(e.StackTrace); } finally { if (@out != null) { try { @out.Close(); } catch (IOException e) { System.Console.WriteLine(e.ToString()); System.Console.Write(e.StackTrace); } } } }
/// <summary> /// Updates the widget display image based on the new state /// </summary> /// <param name="context">Context.</param> /// <param name="newState">New state.</param> private void UpdateWidgetDisplay(Context context, int newState) { var appWidgetManager = AppWidgetManager.GetInstance(context); var remoteViews = new RemoteViews(context.PackageName, Resource.Layout.initial_layout); Log.Debug(APP_NAME, "this.GetType().ToString(): {0}", this.GetType().ToString()); var thisWidget = new ComponentName(context, this.Class); Log.Debug(APP_NAME, thisWidget.FlattenToString()); Log.Debug(APP_NAME, "remoteViews: {0}", remoteViews.ToString()); int imgResource = Resource.Drawable.bluetooth_off; switch ((Android.Bluetooth.State)newState) { case Android.Bluetooth.State.Off: case Android.Bluetooth.State.TurningOn: { imgResource = Resource.Drawable.bluetooth_off; break; } case Android.Bluetooth.State.On: case Android.Bluetooth.State.TurningOff: { imgResource = Resource.Drawable.bluetooth_on; break; } default: { imgResource = Resource.Drawable.bluetooth_off; break; } } remoteViews.SetImageViewResource(Resource.Id.imgBluetooth, imgResource); appWidgetManager.UpdateAppWidget(thisWidget, remoteViews); }