草庐IT

pendingintent

全部标签

android - 小部件中的 OnClick PendingIntent 有时不起作用

我有一个小部件和4个按钮。这些按钮实际上是其他应用程序的快捷方式。我使用以下代码为每个按钮设置了一个onClick待处理Intent:Intenti=context.getPackageManager().getLaunchIntentForPackage(s);PendingIntentpi=PendingIntent.getActivity(context,0,i,Intent.FLAG_ACTIVITY_NEW_TASK);remoteViews.setOnClickPendingIntent(curIconId,pi);通常它工作正常,但有时它什么都不做,在logcat中我看到

android - 使用 PendingIntent 时不考虑 singleTask 和 singleInstance?

我有一个launchMode设置为singleTask的Activity:我有一个正在进行的通知,其中包含启动该Activity的PendingIntent:IntentactivityIntent=newIntent(this,MyActivity.class);TaskStackBuilderstackBuilder=TaskStackBuilder.create(this);stackBuilder.addParentStack(MyActivity.class);stackBuilder.addNextIntent(activityIntent);PendingIntentre

android - 广播 PendingIntent 和 AlarmManager.setAlarmClock() 会丢失额外的 Intent

我像这样创建一个PendingIntent:Intentintent=newIntent(context,AlarmReceiver.class);intent.setAction("Foobar");intent.putExtra(EXTRA_ALARM,alarm);intent.putExtra(EXTRA_TRYTWO,tryTwo);intent.putExtra(EXTRA_BEGAN_TIME,beganTime);returnPendingIntent.getBroadcast(context,(int)alarm.getId(),intent,PendingInten

android - PendingIntent 并不总是在 android 中启动

我在收到GCM推送通知消息后创建通知。这一切都完成了。但是当我点击通知时,有时它没有启动(PendingIntent)。大多数情况下,当我在收到通知后不久点击时就会出现问题。待定Intent实际上是我的第一个登录页面本身。这是源代码..publicvoidcreateNotification(Contextcontext,Stringmessage){NotificationManagernotificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);Noti

android - PendingIntents 保持缓存相同的对象

我在尝试通过Intent和未决Intent将数据传递给BroadcastReceiver时遇到了一些问题,涉及接近警报。更具体地说,我试图传递一个对象,其中包括用户不断变化的位置。我已经尝试了这里(不仅如此)提出的各种策略,但都没有奏效,当在BroadcastReceiver端检索Intent时,会导致空值或与首次创建的Intent相同。使用的策略:标记携带对象的Intent:FLAG_ACTIVITY_NEW_TASK+FLAG_ACTIVITY_CLEAR_TOP+FLAG_ACTIVITY_SINGLE_TOP结果:BroadacastReceiver端的空值标记使用初始Inte

Android - AppWidget pendingintent 不触发

我有一个应用程序小部件,其布局中有一个按钮。单击按钮时,会触发调用我的广播接收器的Intent。它工作得很好,但有时,在使用任务管理器中的“清除内存”按钮后,小部件会卡住-单击它没有任何反应。但如果它正在运行,它仍然可以从我的应用程序接收更新。我不确定未触发未决Intent是内存清除错误还是我的错。无论如何,这是代码:注册挂起的Intent(应用小部件的onUpdate方法)Intentintent=newIntent(context,ServiceControl.class);PendingIntentpendingIntent=PendingIntent.getBroadcast(

android - 重新启动后,小部件 onUpdate 未在单击按钮时设置 pendingIntent

我正在创建一个测试小部件,通过单击它的按钮来显示随机数。一切都独立地在我的Provider的onUpdate中,包括pendingIntent。它工作正常,但在重新启动手机后views.setOnClickPendingIntent无法正常工作,尽管RemoteViews重新创建没有问题,但按钮变得无响应。publicclassTestWidgetextendsAppWidgetProvider{staticHashMapbr=newHashMap();staticvoidupdateAppWidget(Contextcontext,finalAppWidgetManagerappWi

android - pendingintent.getservice 无法正常工作

我正在尝试使用pendingintent启动服务,这就是我正在尝试的方式btnSave.setOnClickListener(newOnClickListener(){@OverridepublicvoidonClick(Viewv){//TODOAuto-generatedmethodstubInfoLayout.setVisibility(LinearLayout.VISIBLE);mIntentService=newIntent(MainActivity.this,LocationService.class);mPendingIntent=PendingIntent.getSer

Android - 什么是 PendingIntent?

我是Android开发的新手,我不得不使用AlarmManager重复闹钟。这是我第一次有机会使用PendingIntent的地方。然而,在阅读了文档(http://developer.android.com/reference/android/app/PendingIntent.html)之后,我真的很困惑PendingIntent到底是什么。我的问题是:Q1。PendingIntent以何种方式“待处理”?很抱歉这个问题,但我想对PendingIntent的含义有一个直观的理解。Q2。文档说:APendingIntentitselfissimplyareferencetoatoke

android - AlarmManager:PendingIntent 在某些设备上从最近的应用程序中刷过应用程序后消失了

简单的演示GitHub项目:https://github.com/Try4W/AlarmManagerDemo在模拟器上(Android4.1.1、Android6):我使用AlarmManager安排新的PendingIntent通过adbshelldumpsysalarm检查Activity警报查看我的Intent从最近使用的应用中滑动关闭应用通过adbshelldumpsysalarm检查Activity警报查看我的IntentBroadcastReciver及时触发!在我的设备上(乐视一号/Android6):我使用AlarmManage安排新的PendingIntent通过a