Launching activity from widget

后端 未结 9 1176
深忆病人
深忆病人 2020-11-29 00:26

I\'m trying to do something which really ought to be quite easy, but it\'s driving me crazy. I\'m trying to launch an activity when a home screen widget is pressed, such as

9条回答
  •  误落风尘
    2020-11-29 01:10

    I know this thread is ancient, but... Other answers describe your burnt Toast problem. As to why your pop-up activity doesn't launch on touch, you may need to enable the "update" action in order to launch and call your onUpdate() method. For that I think you need to add the "APPWIDGET_UPDATE" action like this:

    
        
            
            
            
        
    
    

    Likewise add the APPWIDGET_ENABLED and APPWIDGET_DISABLED actions if you intend to override those methods too.

    It seems to be a very unusual API that requires you to declare the overridden methods that you want called. The usual way to get your custom version of a parent is to simply override/implement them. Maybe there's a good reason for this strange pattern, but it is not a Java pattern that I've seen before. I therefore think it is likely to trip up a great deal of app widget authors. As if app widgets were not confusing enough without this mechanism.

提交回复
热议问题