How to debug with Android App Widget?

前端 未结 4 1071
有刺的猬
有刺的猬 2020-12-20 12:35

For normal Activity, I can set some breakpoints and click F11 in Eclipse to debug. However, it is not working when I develop app widget. So, how can I debug?

4条回答
  •  佛祖请我去吃肉
    2020-12-20 13:04

    Android Studio

    I did not find a "structured" way to explicitly debug an App Widget.

    My workaround:

    Make sure you have an Activity in your project - usually you will have at least a Setting Activity, but if not, just make a dummy Activity that doesn't have to do anything.

    In your Manifest, add this Activity and mark it as the launching activity:

    
        
            
            
        
    
    

    now you should place your breakpoint wherever you like to debug, and launch your application using the button. Now the code of the whole application is under the debug session and the debugger will stop at any breakpoint, including the widget.

    Note: before production, remove the launching intent filter from your manifest, if you don't mean for this Activity to be launched directly from the device launchpad

            
            
                
                
            
        
    

提交回复
热议问题