草庐IT

getBroadcast

全部标签

android - Pendingintent getbroadcast lost parcelable data

问题来了。我的程序在Android6.0上运行完美。将设备更新到android7.0.Pendingintent无法将parcelable数据传递给boradcastreceiver。这是代码。拉响警报publicstaticvoidsetAlarm(@NonNullContextcontext,@NonNullTodotodo){AlarmManageralarmManager=(AlarmManager)context.getSystemService(context.ALARM_SERVICE);Intentintent=newIntent(context,AlarmReceiv

pendingIntent.getBroadcast在“通知抽屉”中不做默认通知/触摸事件-Android Studio 2.3.3 + Java

我已经通过pendingIntent.getBroadcast将通知操作处理程序连接到了通知中的操作。操作正常工作,当我使用默认点击事件上的通知时,它可以正常工作。当通知在托盘中时,我的问题就到了,我在抽屉中还有其他通知,我正在尝试对通知上的默认点击/触摸事件编程,以广播到接收器并运行操作。这是一些代码:UrialertSound=Uri.parse("android.resource://"+ctx.getPackageName()+"/raw/page_the_doctor");NotificationCompat.BuildernotificationBuilder=newNotific

android - PendingIntent.getBroadcast() 安全问题?

我正在查看documentation对于PendingIntent.getBroadcast(Context,int,Intent,int)它提到了......Forsecurityreasons,theIntentyousupplyhereshouldalmostalwaysbeanexplicitintent,thatisspecifyanexplicitcomponenttobedeliveredtothroughIntent.setClass安全原因到底是什么?如果其他应用程序仍然可以仅使用您的包名称和组件名称创建一个Intent,是什么让显式Intent更安全?我在NIST.

android - PendingIntent.getBroadcast 无法解析

我正在androidstudio0.89中编写一个针对API级别20的小部件。在我的AppWidgetProvider中,我试图创建一个待处理的Intent来响应按下的按钮。我的问题是IDE无法识别PendingIntent中的任何方法。这是我的代码:@OverridepublicvoidonUpdate(Contextcontext,AppWidgetManagerappWidgetManager,int[]appWidgetIds){RemoteViewsviews=newRemoteViews(context.getPackageName(),R.layout.widdlewid

android - 我应该在 AlarmManager 中使用 PendingIntent.getService() 还是 getBroadcast?

我的应用需要在每天的特定时间从网络上获取一些数据。所以我使用AlarmManager来安排任务并且工作正常。但是在查看各种示例时,似乎有两种方法可以处理待处理Intent时的AlarmManager。当警报响起时,使用PendingIntent.getBroadcast()调用广播接收器,在该接收器内部启动执行实际工作的服务。另一种方法是使用PendingIntent.getService()并在警报响起时直接调用服务。有人可以向我解释这两种方法之间的区别,以便我决定依赖哪一种吗?编辑:还有一个问题是使用getService()时在哪里获取唤醒锁?例如,当使用广播接收器时,我在onRe