Reputation: 177
I am customizing an Android app, I have to initialize some parameters myself and don't want that user should be able to specify the values for them. I modified Java code and assigned the values for some parameters (which were earlier taking values from R.java), removed those parameters in the preferences.xml, now user don't see them. But there are still some of the parameters which when I initialize in the java code and remove them from the preferences.xml, it crashes the application at start time, do I have to make the changes in R.java?
The second approach to this problem is to pass the preferences.xml file from server to android app, I can easily modify the app so that it connect to server and after authentication the preference.xml file is parsed it, but the question is how will I able to make the android make to use that preference.xml? This approach is not digestible because if there will be no preferences.xml (as expected that after starting the application, user's authentication will occur and then preferences.xml will be pushed) the application will not start.
Third approach is to initialize the parameters in the code, and with out removing it from preferences.xml just hide the options from user, for example following code is in preferences.xml and I have already initialized the parameters in the code but want to get rid of the following piece of code from preferences.xml
<PreferenceCategory android:title="@string/pref_audio">
<CheckBoxPreference android:key="@string/pref_echo_cancellation_key" android:defaultValue="true"
android:title="@string/pref_echo_cancellation" android:summary="@string/pref_echo_cancellation_summary"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_echo_canceller_calibration_key"
android:title="@string/pref_echo_canceller_calibration" />
<PreferenceScreen android:title="@string/pref_codecs"
android:key="@string/pref_codecs_key">
<CheckBoxPreference android:key="@string/pref_codec_speex16_key"
android:title="@string/pref_codec_speex16"/>
<CheckBoxPreference android:key="@string/pref_codec_speex8_key"
android:title="@string/pref_codec_speex8"/>
<CheckBoxPreference android:key="@string/pref_codec_ilbc_key"
android:title="@string/pref_codec_ilbc"
android:shouldDisableView="true"
android:summary="@string/pref_ilbc_summary"/>
<CheckBoxPreference android:key="@string/pref_codec_amr_key"
android:title="@string/pref_codec_amr"
android:defaultValue="true"
android:shouldDisableView="true" />
<CheckBoxPreference android:key="@string/pref_codec_gsm_key"
android:title="@string/pref_codec_gsm"/>
<CheckBoxPreference android:key="@string/pref_codec_g722_key"
android:defaultValue="false"
android:title="@string/pref_codec_g722"/>
android:title="@string/pref_codec_silk8"/>
<CheckBoxPreference android:key="@string/pref_codec_pcmu_key"
android:title="@string/pref_codec_pcmu"/>
<CheckBoxPreference android:key="@string/pref_codec_pcma_key"
android:title="@string/pref_codec_pcma"/>
</PreferenceScreen>
</PreferenceCategory>
Any tag through which I can hide these options or any other help considering approach 1 or 2 ???/
Regards
Upvotes: 1
Views: 357
Reputation: 55
Please do not modify the R.java file.Those values are provided by the system.do not manipulate them.Try not to initialize the parameters in you code.This might help.
Upvotes: 1