Posts

Showing posts from April, 2014

Design Android Settings page in application with Custom Strings.xml

Image
Hi Guys,

In this tuttorial I would like to explain about the android settings screen and also how can a developers can customize there own strings.xml file ex. you can name your string.xml file as strings_common.xml or xyz.xml.




Please find the source code from below link. Hope this will help to some of the developers.
https://www.dropbox.com/s/dqvmji1swuw7bmj/SettingsPageDesign.zip

Fragments Video player with remote url

Image
If any one like this than please find out the source code from Below link
https://www.dropbox.com/s/qwhyyooydzl26a4/FragmentVideoPlayer.zip

Write Utils Class in Android

public class Utils
{

public static void showToast(Context context, String message)
{
Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
   toast.show();
toast.setGravity(Gravity.CLIP_HORIZONTAL | Gravity.CENTER_HORIZONTAL, 0, 0);

}

public static int convertToDIP(Context context, int pixels) {
   return Math.round(pixels * context.getResources().getDisplayMetrics()
     .density);
   // DIP
 }

public static String getDeviceName()
{
String manufacturer = Build.MANUFACTURER;
String model = Build.MODEL;
if (model.startsWith(manufacturer))
{
return capitalize(model);
}
else
{
return capitalize(manufacturer) + " " + model;
}
}

private static String capitalize(String s)
{
if (s == null || s.length() == 0)
{
return "";
}
char first = s.charAt(0);
if (Character.isUpperCase(first))
{
return s;
}
else
{
return Character.toUpperCase(first) + s.substring(1);
}
}


public static boolean isEmpty(String key)
{
return (key.toString().trim().equals("") || key.toString().trim().equals("null…

Changing locale programmatically

privatestaticvoid setLocale(String newLocale ){Locale locale =newLocale( newLocale );Locale.setDefault( locale );Configuration config =newConfiguration(); config.locale = locale; context.getResources().updateConfiguration( config, context.getResources().getDisplayMetrics());}