2012-08-15 57 views
0

我正在开发一个应用程序,我想知道当用户从不是onCreate()的方法启动我的应用程序时,用户有多大的音量。我已经创建了一个基于我的onCreate内的当前卷的int,但因为它不能返回任何东西,我不知道如何从那里获取我的int。使用onCreate()中生成的int I非常重要。创建返回在应用程序启动时获得的值的方法

这怎么办?

+1

后,你已经完成了代码

写入喜好

SharedPreferences pref = context.getSharedPreferences("MyAppPreferences", Context.MODE_PRIVATE); /* * Get the editor for this object. The editor interface abstracts the implementation of * updating the SharedPreferences object. */ SharedPreferences.Editor editor = pref.edit(); /* * Write the keys and values to the Editor */ editor.putInt("VolumLevel", 60); /* * Commit the changes. Return the result of the commit. */ e.commit(); 

READ。它会给这个问题提供背景 – nandeesh 2012-08-15 17:47:08

回答

0

@pawegio权利,如果你想使用相同的音量水平用户设置,使用偏好。 这是如何从喜好

SharedPreferences pref = context.getSharedPreferences("MyAppPreferences", MODE_PRIVATE); 
int volLevel = pref.getInt("VolumLevel", 50 /*Default if value wasn't setup yet*/); 

return volLevel; 
相关问题