A fellow kept complaining that his Remote Desktop (mstsc) connection to the office is super slow. I told him that I had the same problem since I moved from Windows XP to Windows 7 & he found the following solution:
Run the following command line:
netsh interface tcp set global autotuninglevel=disabled
to undo it:
netsh interface tcp set global autotuninglevel=normal
For full details check this post. It's not optimal, but it works & I didn't notice any problem since.
Tuesday, May 24, 2011
Friday, May 13, 2011
Memory debugging and Android application
Using DDMS
*. Compile & run the application on an enumlator in debug (e.g. Manifest.xml, android:debuggable="true").
*. open DDMS
Checking the heap status:
*. Select your application, click on 'Show heap updates' on the toolbar.
*. Play around with your application and check the results.
Checking the allocations:
*. Select the allocation tracker tab, click on 'Start Tracking'
*. Press 'Get Allocations' when you want to check the allocations.
Note: do not use both heap status & allocations - the heap monitoring will cause a lot of allocations.
*. Compile & run the application on an enumlator in debug (e.g. Manifest.xml, android:debuggable="true").
*. open DDMS
Checking the heap status:
*. Select your application, click on 'Show heap updates' on the toolbar.
*. Play around with your application and check the results.
Checking the allocations:
*. Select the allocation tracker tab, click on 'Start Tracking'
*. Press 'Get Allocations' when you want to check the allocations.
Note: do not use both heap status & allocations - the heap monitoring will cause a lot of allocations.
Labels:
Android
Tuesday, May 3, 2011
Display ListPreference value in the preferences screen
One missing feature in the preferences activity in Android applications is to display the selected value of a ListPreference. By default, to view the selected value of a ListPreference you must click the preference and see what's selected in the combo box.
Here's an example how to create a preferences activity which displays the selected value of any number of ListPreferences in the activity.
Notes:
Here's an example how to create a preferences activity which displays the selected value of any number of ListPreferences in the activity.
public class MyPreferenceActivity extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener {
private ArrayList<ListPreference> mListPreferences;
private String[] mListPreferencesKeys = new String[] {
"prefKey1", // The 'android:key' value of the ListPreference
"prefKey2" // The 'android:key' value of the ListPreference
....
....
....
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
mListPreferences = new ArrayList<ListPreference>();
SharedPreferences sharedPrefs = getPreferenceManager().getSharedPreferences();
sharedPrefs.registerOnSharedPreferenceChangeListener(this);
for (String prefKey : mListPreferencesKeys) {
ListPreference pref = (ListPreference)getPreferenceManager().findPreference(prefKey);
mListPreferences.add(pref);
onSharedPreferenceChanged(sharedPrefs, prefKey);
}
}
@Override
public void onSharedPreferenceChanged(SharedPreferences pref, String prefKey) {
for (ListPreference listPref : mListPreferences) {
if (listPref.getKey().equals(prefKey))
listPref.setSummary(listPref.getEntry());
}
}
}
Notes:
- This code will update the values if the user selects a new value
- If you're defining preferences keys in the strings.xml file, make the mListPreferencesKeys list an integer list, and get the string at run time using 'getString'
Labels:
Android
Subscribe to:
Posts (Atom)