首页 \ 问答 \ Android:空PendingIntent(Android : Null PendingIntent)

Android:空PendingIntent(Android : Null PendingIntent)

我正在尝试为包含通知的广播接收器创建一个PendingIntent,并以某种方式获取返回的空PendingIntent。 它没有任何意义,因为只有一个指定的情况会返回一个空的PendingIntent,并且如果PendingIntent.FLAG_NO_CREATE作为标志选项传递。

这是我的PendingIntent代码..在调试器之后pendIntent = null。

    Intent notificationIntent = new Intent(context, LocalPushBroadcastReceiver.class);
    notificationIntent.putExtra(LocalPushBroadcastReceiver.NOTIFICATION_ID_ARG, pushId);
    notificationIntent.putExtra(LocalPushBroadcastReceiver.NOTIFICATION_ARG, notification);
    notificationIntent.setData(Uri.parse("LocalPush:" + pushId + notification.toString()));
    PendingIntent pendIntent = PendingIntent.getBroadcast(context, 0, notificationIntent, 0);

我已经尝试了许多其他旗帜/选项。 我试着从onClick / onStart /到处调用这段代码。 我使用的是最新版本的Android Studio,并且正在使用最新的sdk版本25进行编译。LocalPushBroadcastReceiver在清单中正确定义。

这很奇怪,因为我有这个完全相同的代码在另一个应用程序中的另一台机器上工作,我无法弄清楚我缺少什么配置。 我会很感激任何想法。 谢谢!


I am trying to create a PendingIntent for a broadcast receiver containing a notification and I am somehow getting a null PendingIntent returned. It makes no sense because there is only 1 case specified that would return a null PendingIntent and that is if PendingIntent.FLAG_NO_CREATE is passed as a flag option.

This is my PendingIntent code.. After in debugger pendIntent = null.

    Intent notificationIntent = new Intent(context, LocalPushBroadcastReceiver.class);
    notificationIntent.putExtra(LocalPushBroadcastReceiver.NOTIFICATION_ID_ARG, pushId);
    notificationIntent.putExtra(LocalPushBroadcastReceiver.NOTIFICATION_ARG, notification);
    notificationIntent.setData(Uri.parse("LocalPush:" + pushId + notification.toString()));
    PendingIntent pendIntent = PendingIntent.getBroadcast(context, 0, notificationIntent, 0);

I have tried many other flag / options. I tried calling this code from onClick / onStart / everywhere. I am on the latest version of Android Studio and am compiling with the latest sdk version 25. Also LocalPushBroadcastReceiver is defined in manifest properly.

It's weird because I have this exact same code working on another machine in another application and I can't figure out what configuration I am missing. I would be grateful for any ideas. Thanks!


原文:https://stackoverflow.com/questions/42664494
更新时间:2022-10-08 16:10

最满意答案

有一些重要的事情需要了解:

1)PPAPI本身仅支持某些内置插件,如闪存。 您可以启用其他的但仅使用命令行flages,因此它不适用于任何实际用途。

2)你可以使用PPAPI的地方是NACL / pNACL插件,你通常只谈论使用NACL(Native Client)而不是担心API的名称; NACL专门设计为不允许您访问系统API,例如HWND或任何使用HWND的内容。

所以简短的回答是“不,没有办法做你想做的事”。 更长的答案是,您最想要做的就是根据需要重写以使用OpenGL ES w / NACL。 好消息是,这与移动平台上提供的OpenGL相同,因此对于游戏,您可以利用它。


There are a couple of important things to know about this:

1) PPAPI by itself is only supported for certain built-in plugins, such as flash. You can enable additional ones but only using command-line flages, so it's not viable for any real use.

2) The one place you can use PPAPI is in a NACL/pNACL plugin, where you generally just talk about using NACL (Native Client) rather than worrying about the name of the API; NACL is designed specifically to not allow you to access system APIs such as the HWND or anything that would use an HWND.

So the short answer is "no, there is no way to do what you want". The longer answer is that most likely what you want to do will require rewriting as needed to use OpenGL ES w/ NACL. The good news is that this is the same OpenGL that is available on mobile platforms, so with a game you might be able to leverage that.

相关问答

更多
  • WindowInteropHelper是你的朋友。 它有一个构造函数接受一个Window参数,一个Handle属性返回其窗口句柄。 Window window = Window.GetWindow(this); var wih = new WindowInteropHelper(window); IntPtr hWnd = wih.Handle; WindowInteropHelper is your friend. It has a constructor that accepts a Window p ...
  • 墨菲定律,我在问完后就找到了答案。 win32gui模块具有设置透明度键的功能。 win32gui.SetLayeredWindowAttributes SetLayeredWindowAttributes(hwnd, Key, Alpha, Flags) Sets the opacity and transparency color key of a layered window. Parameters hwnd : PyHANDLE handle to the l ...
  • 欢迎来到不是为C ++设计的win32世界。 这是一个很好的第一次尝试。 我试图制作一个通用框架数百次,然后说它不值得再花时间了。 你的WinMain()也会有所帮助,但我看到的一个大问题是你对CreateWindowEx()调用。 你发送的最后一个参数是0.比你以后检索它时SetWindowLong(hWnd, GWL_USERDATA, (long) ((LPCREATESTRUCT)lParam)->lpCreateParams); 你说它是指向类的指针。 你的意思是: hWnd = ...
  • 有一些重要的事情需要了解: 1)PPAPI本身仅支持某些内置插件,如闪存。 您可以启用其他的但仅使用命令行flages,因此它不适用于任何实际用途。 2)你可以使用PPAPI的地方是NACL / pNACL插件,你通常只谈论使用NACL(Native Client)而不是担心API的名称; NACL专门设计为不允许您访问系统API,例如HWND或任何使用HWND的内容。 所以简短的回答是“不,没有办法做你想做的事”。 更长的答案是,您最想要做的就是根据需要重写以使用OpenGL ES w / NACL。 好 ...
  • 按钮句柄不相等,但您没有为它们设置控件ID。 您可以通过在CreateWindowEx调用中添加以下内容来完成此操作: hBtns[i][j] = CreateWindowEx( NULL, _T("Button"), NULL, WS_CHILD | WS_VISIBLE | BS_BITMAP | BS_NOTIFY, x, y, size/nBtnsNew, size/nBt ...
  • 你混淆了ctypes和win32gui 。 你得到的hwnd是通过ctypes获得的,并且是一个LP_c_long对象。 这就是为什么win32gui.MoveWindow不接受它。 你应该通过它 ctypes.windll.user32.MoveWindow(titles[5][0], 0, 0, 760, 500, True) 如果你想使用win32gui.MoveWindow ,你可以直接使用python函数作为回调函数。 例如, import win32gui def enumHandler(h ...
  • 这不可能来自JavaScript,但它应该可以从C ++扩展。 This is not possible from JavaScript, but it should be possible from a C++ extension.
  • 您必须小心不要将基本上非托管类型(如HWND)暴露给C#代码。 C#编译器不允许您传递此类型的值。 这里适当的互操作类型是IntPtr,它可以存储句柄值。 因此,使您的C ++ / CLI方法如下所示: void VideoCapture::SetVideoWindow(IntPtr windowHandle) { VideoWindow = (HWND)windowHandle.ToPointer(); } 您现在可以简单地将panel1.Handle传递给类型为IntPtr的方法。 You m ...
  • 更新:您可能还想查看WinForms的NativeWindow类 , 该类可用于包装本机HWWND并侦听发送到该窗口的窗口消息。 我想你需要Win32 API函数MoveWindow来设置窗口B( HWND )的位置(和尺寸)。 您可以通过P / Invoke从.NET调用此API函数。 为了检索窗口B的当前位置和大小,您可能还需要通过P / Invoke调用GetWindowRect 。 下面的代码可能不是开箱即用的,也许有更简单的解决方案,但它可能会给你一个起点,以及上面的链接: // the foll ...
  • 建议的解决方案 我建议使用这个签名的简单“AirRepair”类: public class AirRepair : Decorator { public HwndHost Win32Host ... // DP bound to HwndHost public Geometry RepairArea ... // Default is entire decorated control, // or use OpacityMask } ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。