Emulate a broadcast in Android

萝らか妹 提交于 2019-11-30 22:04:30

Go to the folder where your android-sdk is installed and then to platform-tools. There will be some executables. One of them is 'adb'.

When in the folder, execute

./adb shell am broadcast -a android.intent.action.KEY_LOCATION_CHANGED -c android.intent.category.HOME -n com.dennis.test/.LocationBroadcastReceiver

or on windows

adb shell am broadcast -a android.intent.action.KEY_LOCATION_CHANGED -c android.intent.category.HOME -n com.dennis.test/.LocationBroadcastReceiver

mobibob

You should also be able to use MockLocation to generate from your executable or a JUnit. I have not used it, but that is its purpose.

It is probably functionally similar to @user1258903's answer, but should be able to send far away locations (i.e., the North Pole, mom's house, bottom of the ocean, etc.) That way you can test out your computations and maps integration, etc. that you might have.

How to emulate GPS location in the Android Emulator?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!