Clear Android Maps history programmatically

那年仲夏 提交于 2019-12-11 07:15:16

问题


I want to programmatically clear the history of the android maps (and navigation) application.

I know there is a way to clear the browser history via

Browser.clearSearches(getContentResolver());

and the corresponding permission: com.android.browser.permission.WRITE_HISTORY_BOOKMARKS and this works fine (2.2.).

I couldn't find any way to clear the Maps-History though. Clearing the google/history online doesn't help either.

There are some apps in the market that promote to do that, so there must be an API for it, but i really couldn't find it yet.

I also messed around a bit with CLEAR_APP_CACHE and CLEAR_APP_USER_DATA but seems like they are signed/root-only permissions and delte too much anyways.


回答1:


Got a reply from Richard, developer of aClean:

To clear Google-Maps-Recent-Search-Suggestions:

SearchRecentSuggestions mapsrs = new SearchRecentSuggestions(this.getBaseContext(), "com.google.android.maps.SearchHistoryProvider", 1);
mapsrs.clearHistory();

Still doesn't clear recent destination of Navigation, tried but there seems to be no equivalent..?

IMPORTANT NOTE:

Once you do mapsrs.clearHistory(); Afterwards when the Maps-Application gets force-stopped afterwards, your Application will be killed, too. Probably I'm missing to unregister/unsync the Provider. But I have abandoned to try to reset it now anyways.




回答2:


This sounds like something that you'd need SU permissions for.



来源:https://stackoverflow.com/questions/4228922/clear-android-maps-history-programmatically

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