希望您能理解我的问题与我的英语基础...
Hope you will understand my question with my basic english...
在我的应用程序,我允许用户有一个按钮,启动了他选择的应用程序。我没有得到任何问题,使所有已安装应用程序的列表,让意图并启动已选定的应用程序。
In my application, I allow the user to have a button that launch the application of his choice. I get no problem to make a list of all installed apps, get the Intent and launch the choosen app.
不过,我想保存相应的意图,在下次用户使用我的应用程序的设置,但设置只允许我保存基本数据类型(整数,布尔,字符串等)
But I would like to save the corresponding intent in the settings for the next time the user use my application, but settings only allow me to save basic data type ( Integer, boolean, Strings, etc. )
所以,我的问题是如何保存的意图在一个聪明的办法。
So, my question is how to save an intent in a smart way.
我希望你能帮助我找到一个解决方案。
I hope you can help me to find a solution.
推荐答案您应该使用 myIntent.toURI()存储意图,并使用 Intent.getIntent(字符串URI)恢复意图。
You should use myIntent.toURI() to store the Intent, and use Intent.getIntent(String uri) to restore the Intent.
public void saveIntent(Intent intent) { mSharedPrefs.edit().putString(SOME_KEY, intent.toURI())mit(); } public Intent restoreIntent() { String uri = mSharedPrefs.getString(SOME_KEY, *mSomeDefaultUri*); return Intent.getIntent(uri); }更多推荐
任何解决方法,以保存设置的意图是什么?
发布评论