I know that you can't turn on GPS in your application without going to system preferences. But i've downloaded GPS on/off widget and this widget do the job. I've decompiled the apk to find how the programmer have done the job with no success, dex files doen't show the code but functions and informations. Idea on how did he does that ?
相关问题
- 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
Use the following function
buildAlertMessageNoGps() and launchGPSOptions()
to achieve your goal .
see The Link
You can look up the source code if he posted it. Sometimes people host their code on GIT and you can browse their entire project. Specifically unless you're familiar with decompiling code using dalvik.. then that is a tricky route.
If you want to toggle the GPS, just have your widget activate an activity that toggles the GPS via passing the state of the widget to the activity via an intent. Then have your activity parse this and then close itself.
However; I would prefer to do it through a service, which is an activity without a UI. This service can be launched with your app and when a particular broadcast is received, then execute some function, which would be triggered via your widget.
Specifically you'd need to look into one type of broadcast listening. There is the XML based intent filter which will IMMEDIATELY send those particular broadcasts to your app, which can be handled accordingly.
For instance, say your widget is a toggle button with a title. When you toggle the button have you widget code send a broadcast with an intent to your service with the state of the toggle button. Then in the service, you would control the state of the GPS or any other component on the phone.