i have a service class, and a util class. in util class,i send a sms to a phone. but in util class ,there are many functions use params such as context,but the util extends nothing,just a simple class. how to do it ?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
If I understand you right, you will have to pass the context as an argument when creating whatever object you are making with the util class.
So, I assume in your service class, you are making a Util class which sends the sms... I'll just make up some code that may fit what you are doing...
Within your service class, do this.
Doing that will create a Util object which has the context of the service, just make sure the Util class has a proper constructor to retain the context (for later use). Do this using this in your Util class
Hope that helps.
Try like this:
Just like this. set all pendingIntent null.