tag:blogger.com,1999:blog-25143769297122185362024-02-18T23:02:04.603-08:00Android-Rodies-TaskEnjoy Android Tutorial. Hope this will help every one.Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.comBlogger129125tag:blogger.com,1999:blog-2514376929712218536.post-14453998088710880492016-04-26T05:22:00.002-07:002016-04-26T05:23:51.137-07:00This is a common Utils class for used every where.<div dir="ltr" style="text-align: left;" trbidi="on">
<pre style="background-color: white; font-family: 'Courier New'; font-size: 9pt;"><span style="color: navy; font-weight: bold;">import </span>android.annotation.TargetApi;
<span style="color: navy; font-weight: bold;">import </span>android.app.Activity;
<span style="color: navy; font-weight: bold;">import </span>android.app.AlertDialog;
<span style="color: navy; font-weight: bold;">import </span>android.app.DatePickerDialog;
<span style="color: navy; font-weight: bold;">import </span>android.app.ProgressDialog;
<span style="color: navy; font-weight: bold;">import </span>android.content.ContentResolver;
<span style="color: navy; font-weight: bold;">import </span>android.content.ContentUris;
<span style="color: navy; font-weight: bold;">import </span>android.content.Context;
<span style="color: navy; font-weight: bold;">import </span>android.content.DialogInterface;
<span style="color: navy; font-weight: bold;">import </span>android.content.Intent;
<span style="color: navy; font-weight: bold;">import </span>android.content.SharedPreferences;
<span style="color: navy; font-weight: bold;">import </span>android.database.Cursor;
<span style="color: navy; font-weight: bold;">import </span>android.graphics.Typeface;
<span style="color: navy; font-weight: bold;">import </span>android.hardware.Camera;
<span style="color: navy; font-weight: bold;">import </span>android.net.ConnectivityManager;
<span style="color: navy; font-weight: bold;">import </span>android.net.NetworkInfo;
<span style="color: navy; font-weight: bold;">import </span>android.net.Uri;
<span style="color: navy; font-weight: bold;">import </span>android.os.Build;
<span style="color: navy; font-weight: bold;">import </span>android.os.Environment;
<span style="color: navy; font-weight: bold;">import </span>android.provider.ContactsContract;
<span style="color: navy; font-weight: bold;">import </span>android.provider.DocumentsContract;
<span style="color: navy; font-weight: bold;">import </span>android.provider.MediaStore;
<span style="color: navy; font-weight: bold;">import </span>android.provider.Settings;
<span style="color: navy; font-weight: bold;">import </span>android.telephony.TelephonyManager;
<span style="color: navy; font-weight: bold;">import </span>android.util.DisplayMetrics;
<span style="color: navy; font-weight: bold;">import </span>android.util.Patterns;
<span style="color: navy; font-weight: bold;">import </span>android.view.View;
<span style="color: navy; font-weight: bold;">import </span>android.view.Window;
<span style="color: navy; font-weight: bold;">import </span>android.view.inputmethod.InputMethodManager;
<span style="color: navy; font-weight: bold;">import </span>android.widget.Button;
<span style="color: navy; font-weight: bold;">import </span>android.widget.DatePicker;
<span style="color: navy; font-weight: bold;">import </span>android.widget.EditText;
<span style="color: navy; font-weight: bold;">import </span>android.widget.TextView;
<span style="color: navy; font-weight: bold;">import </span>android.widget.Toast;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.HttpEntity;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.HttpResponse;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.client.HttpClient;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.client.methods.HttpGet;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.impl.client.DefaultHttpClient;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.util.EntityUtils;
<span style="color: navy; font-weight: bold;">import </span>org.json.JSONException;
<span style="color: navy; font-weight: bold;">import </span>org.json.JSONObject;
<span style="color: navy; font-weight: bold;">import </span>java.io.File;
<span style="color: navy; font-weight: bold;">import </span>java.text.DecimalFormat;
<span style="color: navy; font-weight: bold;">import </span>java.text.SimpleDateFormat;
<span style="color: navy; font-weight: bold;">import </span>java.util.ArrayList;
<span style="color: navy; font-weight: bold;">import </span>java.util.Calendar;
<span style="color: navy; font-weight: bold;">import </span>java.util.Date;
<span style="color: navy; font-weight: bold;">import </span>java.util.HashSet;
<span style="color: navy; font-weight: bold;">import </span>java.util.Locale;
<span style="color: navy; font-weight: bold;">import </span>java.util.regex.Matcher;
<span style="color: navy; font-weight: bold;">import </span>java.util.regex.Pattern;
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * This is a common class for used every where.</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@author </span><span style="color: grey; font-style: italic;">Mayank</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@since </span><span style="color: grey; font-style: italic;">1.4</span><span style="color: grey; font-style: italic;"> */</span><span style="color: navy; font-weight: bold;">public class </span>Utils {
<span style="color: navy; font-weight: bold;">public static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">IS_SOCIAL_REGISTER </span>= <span style="color: green; font-weight: bold;">"Register"</span>;
<span style="color: navy; font-weight: bold;">public static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">SOCIAL_IS_REGISTER_TYPE </span>= <span style="color: green; font-weight: bold;">"RegisterType"</span>;
<span style="color: navy; font-weight: bold;">public static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">SOCIAL_PROVIDER </span>= <span style="color: green; font-weight: bold;">"SocialProvider"</span>;
<span style="color: navy; font-weight: bold;">public static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">IS_SOCIAL_LOGIN </span>= <span style="color: green; font-weight: bold;">"SocialType"</span>;
<span style="color: navy; font-weight: bold;">public static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">TAG </span>= <span style="color: green; font-weight: bold;">"URateIt"</span>;
<span style="color: navy; font-weight: bold;">public static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">APP_PREFS </span>= <span style="color: green; font-weight: bold;">"app_prefs"</span>;
<span style="color: navy; font-weight: bold;">public static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">APP_PREFS_NOTIFICATION_KEY </span>= <span style="color: green; font-weight: bold;">"app_prefs_notification"</span>;
<span style="color: navy; font-weight: bold;">public static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">NOTIFICATION_KEY </span>= <span style="color: green; font-weight: bold;">"notification_key"</span>;
<span style="color: navy; font-weight: bold;">public static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">ACCESS_KEY </span>= <span style="color: green; font-weight: bold;">"access_key"</span>;
<span style="color: navy; font-weight: bold;">public static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">ACCESS_KEY_NOT_FOUND </span>= <span style="color: green; font-weight: bold;">"access_key_not_defined"</span>;
<span style="color: navy; font-weight: bold;">public static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">USER_KEY </span>= <span style="color: green; font-weight: bold;">"user_key"</span>;
<span style="color: navy; font-weight: bold;">public static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">USER_KEY_NOT_FOUND </span>= <span style="color: green; font-weight: bold;">"user_key_not_defined"</span>;
<span style="color: navy; font-weight: bold;">public static final int </span><span style="color: #660e7a; font-style: italic; font-weight: bold;">MEDIA_TYPE_IMAGE </span>= <span style="color: blue;">1</span>;
<span style="color: navy; font-weight: bold;">public static final int </span><span style="color: #660e7a; font-style: italic; font-weight: bold;">MEDIA_TYPE_VIDEO </span>= <span style="color: blue;">2</span>;
<span style="color: navy; font-weight: bold;">public static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">IMAGE_DIRECTORY_NAME </span>= <span style="color: green; font-weight: bold;">"URateIt"</span>;
<span style="color: navy; font-weight: bold;">public static final int </span><span style="color: #660e7a; font-style: italic; font-weight: bold;">MEDIA_TYPE_AUDIO </span>= <span style="color: blue;">3</span>;
<span style="color: navy; font-weight: bold;">public static final </span>String <span style="color: #660e7a; font-style: italic; font-weight: bold;">root </span>= <span style="color: green; font-weight: bold;">"/mnt/sdcard/Android/data"</span>;
<span style="color: navy; font-weight: bold;">public static </span>String <span style="color: #660e7a; font-style: italic;">PREFS_FILE_NAME </span>= <span style="color: green; font-weight: bold;">"URateItPref"</span>;
<span style="color: navy; font-weight: bold;">public static </span>ProgressDialog <span style="color: #660e7a; font-style: italic;">loadingDialogGlobal</span>;
<span style="color: navy; font-weight: bold;">public static </span>Uri <span style="color: #660e7a; font-style: italic;">fileUri</span>;
<span style="color: navy; font-weight: bold;">static </span>SharedPreferences <span style="color: #660e7a; font-style: italic;">prefs</span>;
<span style="color: navy; font-weight: bold;">private static </span>File <span style="color: #660e7a; font-style: italic;">audioFolder</span>;
<span style="color: navy; font-weight: bold;">private static </span>File <span style="color: #660e7a; font-style: italic;">videoFolder</span>;
<span style="color: navy; font-weight: bold;">private static </span>File <span style="color: #660e7a; font-style: italic;">imageFolder</span>;
<span style="color: navy; font-weight: bold;">public static void </span>setAPIAccessKey(String access_key, Context context) {
SharedPreferences prefs;
prefs = context.getSharedPreferences(<span style="color: #660e7a; font-style: italic; font-weight: bold;">APP_PREFS</span>, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString(<span style="color: #660e7a; font-style: italic; font-weight: bold;">ACCESS_KEY</span>, access_key);
editor.commit();
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * check EditText is empty or not</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">edText </span><span style="color: grey; font-style: italic;">pass EditText for check is empty or not</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@return </span><span style="color: grey; font-style: italic;">true or false</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static boolean </span>isEmptyEditText(EditText edText) {
<span style="color: navy; font-weight: bold;">if </span>(edText.getText().toString().trim().length() > <span style="color: blue;">0</span>)
<span style="color: navy; font-weight: bold;">return false</span>;
<span style="color: navy; font-weight: bold;">else</span><span style="color: navy; font-weight: bold;"> return true</span>;
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * set custom fonts for custom text changes</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">mContext</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">mTextView</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">font</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static void </span>setCustomFontStyle(Context mContext, TextView mTextView, String font) {
Typeface face = Typeface.createFromAsset(mContext.getAssets(), <span style="color: green; font-weight: bold;">"fonts/" </span>+ font + <span style="color: green; font-weight: bold;">".ttf"</span>);
mTextView.setTypeface(face);
}
<span style="color: navy; font-weight: bold;">public static void </span>setTypeface(Context mContext, EditText mEditText) {
Typeface face = Typeface.createFromAsset(mContext.getAssets(), <span style="color: green; font-weight: bold;">"SEGOEUIL.ttf"</span>);
mEditText.setTypeface(face);
}
<span style="color: navy; font-weight: bold;">public static void </span>setTypeface(Context mContext, TextView mTextView) {
Typeface face = Typeface.createFromAsset(mContext.getAssets(), <span style="color: green; font-weight: bold;">"SEGOEUIL.ttf"</span>);
mTextView.setTypeface(face);
}
<span style="color: navy; font-weight: bold;">public static void </span>setTypeface(Context mContext, Button mbButton) {
Typeface face = Typeface.createFromAsset(mContext.getAssets(), <span style="color: green; font-weight: bold;">"SEGOEUIL.ttf"</span>);
mbButton.setTypeface(face);
}
<span style="color: grey; font-style: italic;">// -----------------------------------------------</span><span style="color: grey; font-style: italic;">
</span><span style="color: grey; font-style: italic;"> /**</span><span style="color: grey; font-style: italic;"> * Get the access key from shared preferences</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context </span><span style="color: grey; font-style: italic;">application context</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@return </span><span style="color: grey; font-style: italic;">access key</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static </span>String getAPIAccessKey(Context context) {
SharedPreferences prefs;
prefs = context.getSharedPreferences(<span style="color: #660e7a; font-style: italic; font-weight: bold;">APP_PREFS</span>, Context.MODE_PRIVATE);
<span style="color: navy; font-weight: bold;">return </span>prefs.getString(<span style="color: #660e7a; font-style: italic; font-weight: bold;">ACCESS_KEY</span>, <span style="color: #660e7a; font-style: italic; font-weight: bold;">ACCESS_KEY_NOT_FOUND</span>);
<span style="color: grey; font-style: italic;">// return "58623a74e11d56d61a2ee098fe993d1754e5a5fc737b7";</span><span style="color: grey; font-style: italic;"> </span>}
<span style="color: grey; font-style: italic;">// -----------------------------------------------</span><span style="color: grey; font-style: italic;">
</span><span style="color: grey; font-style: italic;"> /**</span><span style="color: grey; font-style: italic;"> * Set the user key on shared preferences</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context </span><span style="color: grey; font-style: italic;">application context</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static void </span>setUserAccessKey(String user_key, Context context) {
SharedPreferences prefs;
prefs = context.getSharedPreferences(<span style="color: #660e7a; font-style: italic; font-weight: bold;">APP_PREFS</span>, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString(<span style="color: #660e7a; font-style: italic; font-weight: bold;">USER_KEY</span>, user_key);
editor.commit();
}
<span style="color: grey; font-style: italic;">// -----------------------------------------------</span><span style="color: grey; font-style: italic;">
</span><span style="color: grey; font-style: italic;"> /**</span><span style="color: grey; font-style: italic;"> * Get the user key from shared preferences</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context </span><span style="color: grey; font-style: italic;">application context</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@return </span><span style="color: grey; font-style: italic;">user key</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static </span>String getUserAccessKey(Context context) {
SharedPreferences prefs;
prefs = context.getSharedPreferences(<span style="color: #660e7a; font-style: italic; font-weight: bold;">APP_PREFS</span>, Context.MODE_PRIVATE);
<span style="color: navy; font-weight: bold;">return </span>prefs.getString(<span style="color: #660e7a; font-style: italic; font-weight: bold;">USER_KEY</span>, <span style="color: #660e7a; font-style: italic; font-weight: bold;">USER_KEY_NOT_FOUND</span>);
<span style="color: grey; font-style: italic;">// return "f0cec1614a73303267f22ce6050ee09954e5dcb8c0c7a";</span><span style="color: grey; font-style: italic;"> </span>}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * set String Preference Value</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">prefName </span><span style="color: grey; font-style: italic;">Preference name</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">Value </span><span style="color: grey; font-style: italic;">Preference value</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static void </span>setPrefrencesString(Context context, String prefName, String Value) {
<span style="color: #660e7a; font-style: italic;">prefs </span>= context.getSharedPreferences(<span style="color: #660e7a; font-style: italic;">PREFS_FILE_NAME</span>, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = <span style="color: #660e7a; font-style: italic;">prefs</span>.edit();
editor.putString(prefName, Value);
editor.commit();
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * get String Preference Value</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">prefName</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@return</span><span style="color: grey; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static </span>String getPrefrencesString(Context context, String prefName) {
<span style="color: #660e7a; font-style: italic;">prefs </span>= context.getSharedPreferences(<span style="color: #660e7a; font-style: italic;">PREFS_FILE_NAME</span>, Context.MODE_PRIVATE);
<span style="color: navy; font-weight: bold;">if </span>(<span style="color: #660e7a; font-style: italic;">prefs</span>.contains(prefName))
<span style="color: navy; font-weight: bold;">return </span><span style="color: #660e7a; font-style: italic;">prefs</span>.getString(prefName, <span style="color: green; font-weight: bold;">""</span>);
<span style="color: navy; font-weight: bold;">else</span><span style="color: navy; font-weight: bold;"> return </span><span style="color: green; font-weight: bold;">""</span>;
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * set Integer Preference Value</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">prefName</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">Value</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static void </span>setPrefrencesInteger(Context context, String prefName, <span style="color: navy; font-weight: bold;">int </span>Value) {
<span style="color: #660e7a; font-style: italic;">prefs </span>= context.getSharedPreferences(<span style="color: #660e7a; font-style: italic;">PREFS_FILE_NAME</span>, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = <span style="color: #660e7a; font-style: italic;">prefs</span>.edit();
editor.putInt(prefName, Value);
editor.commit();
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * get Integer Preference Value</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">prefName</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@return</span><span style="color: grey; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static int </span>getPrefrencesInteger(Context context, String prefName) {
<span style="color: #660e7a; font-style: italic;">prefs </span>= context.getSharedPreferences(<span style="color: #660e7a; font-style: italic;">PREFS_FILE_NAME</span>, Context.MODE_PRIVATE);
<span style="color: navy; font-weight: bold;">return </span><span style="color: #660e7a; font-style: italic;">prefs</span>.getInt(prefName, <span style="color: blue;">0</span>);
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * remove all the preferences of your app. Note: only remove all which set</span><span style="color: grey; font-style: italic;"> * by using this sdk.</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static void </span>clearAllPrefrencesData(Context context) {
<span style="color: #660e7a; font-style: italic;">prefs </span>= context.getSharedPreferences(<span style="color: #660e7a; font-style: italic;">PREFS_FILE_NAME</span>, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = <span style="color: #660e7a; font-style: italic;">prefs</span>.edit();
editor.clear();
editor.commit();
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * Network operations of HttpClient</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">serverUrl</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@return</span><span style="color: grey; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static </span>String NetworkOperation(String serverUrl) {
String result = <span style="color: navy; font-weight: bold;">null</span>;
JSONObject jsonResult;
<span style="color: navy; font-weight: bold;">try </span>{
HttpClient client = <span style="color: navy; font-weight: bold;">new </span>DefaultHttpClient();
HttpGet get = <span style="color: navy; font-weight: bold;">new </span>HttpGet(serverUrl);
HttpResponse response = client.execute(get);
HttpEntity resp_entity = response.getEntity();
result = EntityUtils.toString(resp_entity);
<span style="color: navy; font-weight: bold;">if </span>(response.getStatusLine().getStatusCode() != <span style="color: blue;">200</span>) {
jsonResult = <span style="color: navy; font-weight: bold;">new </span>JSONObject();
jsonResult.put(<span style="color: green; font-weight: bold;">"response_code"</span>, <span style="color: green; font-weight: bold;">"9999"</span>);
jsonResult.put(<span style="color: green; font-weight: bold;">"response_message"</span>, <span style="color: green; font-weight: bold;">"Server error occurred while processing request. Please try again."</span>);
result = jsonResult.toString();
<span style="color: navy; font-weight: bold;">return </span>result;
}
} <span style="color: navy; font-weight: bold;">catch </span>(Exception e) {
<span style="color: navy; font-weight: bold;">try </span>{
jsonResult = <span style="color: navy; font-weight: bold;">new </span>JSONObject();
jsonResult.put(<span style="color: green; font-weight: bold;">"response_code"</span>, <span style="color: green; font-weight: bold;">"9999"</span>);
jsonResult.put(<span style="color: green; font-weight: bold;">"response_message"</span>, <span style="color: green; font-weight: bold;">"Server error occurred while processing request. Please try again."</span>);
result = jsonResult.toString();
<span style="color: navy; font-weight: bold;">return </span>result;
} <span style="color: navy; font-weight: bold;">catch </span>(JSONException jsone) {
}
}
<span style="color: navy; font-weight: bold;">return </span>result;
}
<span style="color: navy; font-weight: bold;">public static void </span>setNotificationKey(String access_key, Context context) {
SharedPreferences prefs;
prefs = context.getSharedPreferences(<span style="color: #660e7a; font-style: italic; font-weight: bold;">APP_PREFS_NOTIFICATION_KEY</span>, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString(<span style="color: #660e7a; font-style: italic; font-weight: bold;">NOTIFICATION_KEY</span>, access_key);
editor.commit();
}
<span style="color: navy; font-weight: bold;">public static </span>String getNotificationKey(Context context) {
SharedPreferences prefs;
prefs = context.getSharedPreferences(<span style="color: #660e7a; font-style: italic; font-weight: bold;">APP_PREFS_NOTIFICATION_KEY</span>, Context.MODE_PRIVATE);
<span style="color: navy; font-weight: bold;">return </span>prefs.getString(<span style="color: #660e7a; font-style: italic; font-weight: bold;">NOTIFICATION_KEY</span>, <span style="color: navy; font-weight: bold;">null</span>);
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * Checks whether network (WIFI/mobile) is available or not.</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context </span><span style="color: grey; font-style: italic;">application context.</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@return </span><span style="color: grey; font-style: italic;">true if network available,false otherwise.</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static boolean </span>isNetworkAvailable(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
<span style="color: navy; font-weight: bold;">if </span>(netInfo != <span style="color: navy; font-weight: bold;">null </span>&& netInfo.isConnectedOrConnecting()) {
<span style="color: navy; font-weight: bold;">return true</span>;
}
<span style="color: navy; font-weight: bold;">return false</span>;
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * check the email address is valid or not.</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">email </span><span style="color: grey; font-style: italic;">pass email id in string</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@return </span><span style="color: grey; font-style: italic;">true when its valid otherwise false</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static boolean </span>isEmailIdValid(String email) {
String expression = <span style="color: green; font-weight: bold;">"^[</span><span style="color: navy; font-weight: bold;">\\</span><span style="color: green; font-weight: bold;">w</span><span style="color: navy; font-weight: bold;">\\</span><span style="color: green; font-weight: bold;">.-]+@([</span><span style="color: navy; font-weight: bold;">\\</span><span style="color: green; font-weight: bold;">w</span><span style="color: navy; font-weight: bold;">\\</span><span style="color: green; font-weight: bold;">-]+</span><span style="color: navy; font-weight: bold;">\\</span><span style="color: green; font-weight: bold;">.)+[A-Z]{2,4}$"</span>;
CharSequence inputStr = email;
Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
<span style="color: navy; font-weight: bold;">if </span>(matcher.matches())
<span style="color: navy; font-weight: bold;">return true</span>;
<span style="color: navy; font-weight: bold;">else</span><span style="color: navy; font-weight: bold;"> return false</span>;
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * get unique id</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@return</span><span style="color: grey; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static </span>String getUniqueId(Context context) {
String androidId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
<span style="color: navy; font-weight: bold;">return </span>androidId;
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * get device id</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@return</span><span style="color: grey; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static </span>String getDeviceID(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
<span style="color: navy; font-weight: bold;">return </span>telephonyManager.getDeviceId();
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * show no internet available dialog</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">mContext</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static void </span>ShowNoInternetDialog(<span style="color: navy; font-weight: bold;">final </span>Context mContext) {
<span style="color: navy; font-weight: bold;">new </span>AlertDialog.Builder(mContext, AlertDialog.THEME_HOLO_LIGHT)
.setMessage(<span style="color: green; font-weight: bold;">"No internet available."</span>)
.setCancelable(<span style="color: navy; font-weight: bold;">false</span>)
.setPositiveButton(<span style="color: green; font-weight: bold;">"OK"</span>, <span style="color: navy; font-weight: bold;">new </span>DialogInterface.OnClickListener() {
@Override
<span style="color: navy; font-weight: bold;">public void </span>onClick(DialogInterface dialog, <span style="color: navy; font-weight: bold;">int </span>which) {
<span style="color: #660e7a;">mContext</span>.startActivity(<span style="color: navy; font-weight: bold;">new </span>Intent(Settings.ACTION_SETTINGS));
}
}).create().show();
}
<span style="color: grey; font-style: italic;">// Sanjay Added methods for image and video capture or pick from gallery 18/2/2015</span><span style="color: grey; font-style: italic;">
</span><span style="color: grey; font-style: italic;"> /**</span><span style="color: grey; font-style: italic;"> * for clear previous stored data</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static void </span>clearPreviousData(Context context) {
Appconfig.SocialID = <span style="color: green; font-weight: bold;">""</span>;
Appconfig.FullName = <span style="color: green; font-weight: bold;">""</span>;
Appconfig.Email = <span style="color: green; font-weight: bold;">""</span>;
Appconfig.AvatarImgURL = <span style="color: green; font-weight: bold;">""</span>;
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * for close the keyboard</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">mContext</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">v</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static void </span>closeKeyboard(Context mContext, View v) {
InputMethodManager inputManager = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
<span style="color: navy; font-weight: bold;">public static void </span>showGlobalLoading(Context mContext) {
<span style="color: grey; font-style: italic;">// </span><span style="color: #0073bf; font-style: italic; font-weight: bold;">TODO Auto-generated method stub</span><span style="color: #0073bf; font-style: italic; font-weight: bold;"> </span><span style="color: #660e7a; font-style: italic;">loadingDialogGlobal </span>= <span style="color: navy; font-weight: bold;">new </span>ProgressDialog(mContext, ProgressDialog.THEME_DEVICE_DEFAULT_LIGHT);
<span style="color: #660e7a; font-style: italic;">loadingDialogGlobal</span>.requestWindowFeature(Window.FEATURE_NO_TITLE);
<span style="color: #660e7a; font-style: italic;">loadingDialogGlobal</span>.setMessage(<span style="color: green; font-weight: bold;">"Loading..."</span>);
<span style="color: #660e7a; font-style: italic;">loadingDialogGlobal</span>.setCancelable(<span style="color: navy; font-weight: bold;">false</span>);
<span style="color: #660e7a; font-style: italic;">loadingDialogGlobal</span>.show();
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * Captures image in Common Directory</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">mContext</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">CAMERA_CAPTURE_IMAGE_REQUEST_CODE</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">camera</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static void </span>captureImage(Context mContext, <span style="color: navy; font-weight: bold;">int </span>CAMERA_CAPTURE_IMAGE_REQUEST_CODE, String camera) {
Intent intent = <span style="color: navy; font-weight: bold;">new </span>Intent(MediaStore.ACTION_IMAGE_CAPTURE);
<span style="color: #660e7a; font-style: italic;">fileUri </span>= <span style="font-style: italic;">getOutputMediaFileUri</span>(<span style="color: #660e7a; font-style: italic; font-weight: bold;">MEDIA_TYPE_IMAGE</span>);
intent.putExtra(MediaStore.EXTRA_OUTPUT, <span style="color: #660e7a; font-style: italic;">fileUri</span>);
<span style="color: navy; font-weight: bold;">if </span>(camera.equalsIgnoreCase(<span style="color: green; font-weight: bold;">"Front"</span>)) {
intent.putExtra(<span style="color: green; font-weight: bold;">"android.intent.extras.CAMERA_FACING"</span>, Camera.CameraInfo.CAMERA_FACING_FRONT);
} <span style="color: navy; font-weight: bold;">else if </span>(camera.equalsIgnoreCase(<span style="color: green; font-weight: bold;">"Back"</span>)) {
intent.putExtra(<span style="color: green; font-weight: bold;">"android.intent.extras.CAMERA_FACING"</span>, Camera.CameraInfo.CAMERA_FACING_BACK);
}
((Activity) mContext).startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);
}
<span style="color: navy; font-weight: bold;">public static </span>Uri getOutputMediaFileUri(<span style="color: navy; font-weight: bold;">int </span>type) {
<span style="color: navy; font-weight: bold;">return </span>Uri.fromFile(<span style="font-style: italic;">getOutputMediaFile</span>(type));
}
<span style="color: navy; font-weight: bold;">public static </span>File getOutputMediaFile(<span style="color: navy; font-weight: bold;">int </span>type) {
<span style="color: grey; font-style: italic;">// External sdcard location</span><span style="color: grey; font-style: italic;"> </span><span style="font-style: italic;">createFolderDirectory</span>();
<span style="color: grey; font-style: italic;">// File mediaStorageDir = new File(Environment.getExternalStorageDirectory(), IMAGE_DIRECTORY_NAME);</span><span style="color: grey; font-style: italic;">// // Create the storage directory if it does not exist</span><span style="color: grey; font-style: italic;">// if (!mediaStorageDir.exists()) {</span><span style="color: grey; font-style: italic;">// if (!mediaStorageDir.mkdirs()) {</span><span style="color: grey; font-style: italic;">// Log.d(IMAGE_DIRECTORY_NAME, "Oops! Failed create "</span><span style="color: grey; font-style: italic;">// + IMAGE_DIRECTORY_NAME + " directory");</span><span style="color: grey; font-style: italic;">// return null;</span><span style="color: grey; font-style: italic;">// }</span><span style="color: grey; font-style: italic;">// }</span><span style="color: grey; font-style: italic;"> // Create a media file name</span><span style="color: grey; font-style: italic;"> </span>String timeStamp = <span style="color: navy; font-weight: bold;">new </span>SimpleDateFormat(<span style="color: green; font-weight: bold;">"yyyyMMdd_HHmmss"</span>, Locale.getDefault()).format(<span style="color: navy; font-weight: bold;">new </span>Date());
File mediaFile;
<span style="color: navy; font-weight: bold;">if </span>(type == <span style="color: #660e7a; font-style: italic; font-weight: bold;">MEDIA_TYPE_IMAGE</span>) {
mediaFile = <span style="color: navy; font-weight: bold;">new </span>File(<span style="color: #660e7a; font-style: italic;">imageFolder</span>.getPath() + File.separator + <span style="color: green; font-weight: bold;">"IMG_" </span>+ timeStamp + <span style="color: green; font-weight: bold;">".jpg"</span>);
} <span style="color: navy; font-weight: bold;">else if </span>(type == <span style="color: #660e7a; font-style: italic; font-weight: bold;">MEDIA_TYPE_VIDEO</span>) {
mediaFile = <span style="color: navy; font-weight: bold;">new </span>File(<span style="color: #660e7a; font-style: italic;">videoFolder</span>.getPath() + File.separator + <span style="color: green; font-weight: bold;">"VID_" </span>+ timeStamp + <span style="color: green; font-weight: bold;">".mp4"</span>);
} <span style="color: navy; font-weight: bold;">else if </span>(type == <span style="color: #660e7a; font-style: italic; font-weight: bold;">MEDIA_TYPE_AUDIO</span>) {
mediaFile = <span style="color: navy; font-weight: bold;">new </span>File(<span style="color: #660e7a; font-style: italic;">audioFolder</span>.getPath() + File.separator + <span style="color: green; font-weight: bold;">"AUD_" </span>+ timeStamp + <span style="color: green; font-weight: bold;">".mp3"</span>);
} <span style="color: navy; font-weight: bold;">else </span>{
<span style="color: navy; font-weight: bold;">return null</span>;
}
<span style="color: navy; font-weight: bold;">return </span>mediaFile;
}
<span style="color: navy; font-weight: bold;">public static void </span>createFolderDirectory() {
<span style="color: grey; font-style: italic;">// root/ pkg/ type/ lang/ gender/</span><span style="color: grey; font-style: italic;">
</span><span style="color: grey; font-style: italic;"> </span>File packageFolder = <span style="font-style: italic;">createFolder</span>(<span style="color: #660e7a; font-style: italic; font-weight: bold;">root</span>, <span style="color: green; font-weight: bold;">"packagename"</span>);
<span style="font-style: italic;">createFolder</span>(packageFolder.getPath(), <span style="color: #660e7a; font-style: italic; font-weight: bold;">IMAGE_DIRECTORY_NAME</span>);
<span style="color: #660e7a; font-style: italic;">audioFolder </span>= <span style="font-style: italic;">createFolder</span>(<span style="color: #660e7a; font-style: italic; font-weight: bold;">root </span>+ <span style="color: green; font-weight: bold;">"/<span style="font-size: 9pt;">packagename</span><span style="color: green; font-size: 9pt;">/" </span><span style="font-size: 9pt;">+ </span><span style="color: #660e7a; font-size: 9pt; font-style: italic;">IMAGE_DIRECTORY_NAME</span><span style="font-size: 9pt;">, </span><span style="color: green; font-size: 9pt;">"audio"</span><span style="font-size: 9pt;">);</span></span> <span style="color: #660e7a; font-style: italic;">videoFolder </span>= <span style="font-style: italic;">createFolder</span>(<span style="color: #660e7a; font-style: italic; font-weight: bold;">root </span>+ <span style="color: green; font-weight: bold;">"/<span style="font-size: 9pt;">packagename</span><span style="color: green; font-size: 9pt;">/" </span><span style="font-size: 9pt;">+ </span><span style="color: #660e7a; font-size: 9pt; font-style: italic;">IMAGE_DIRECTORY_NAME</span><span style="font-size: 9pt;">, </span><span style="color: green; font-size: 9pt;">"video"</span><span style="font-size: 9pt;">);</span></span> <span style="color: #660e7a; font-style: italic;">imageFolder </span>= <span style="font-style: italic;">createFolder</span>(<span style="color: #660e7a; font-style: italic; font-weight: bold;">root </span>+ <span style="color: green; font-weight: bold;">"/<span style="font-size: 9pt;">packagename</span><span style="color: green; font-size: 9pt;">/" </span><span style="font-size: 9pt;">+ </span><span style="color: #660e7a; font-size: 9pt; font-style: italic;">IMAGE_DIRECTORY_NAME</span><span style="font-size: 9pt;">, </span><span style="color: green; font-size: 9pt;">"images"</span><span style="font-size: 9pt;">);</span></span> System.out.println(<span style="color: green; font-weight: bold;">"file directory created..."</span>);
}
<span style="color: navy; font-weight: bold;">public static </span>File createFolder(String path, String folderName) {
File SDCardRoot = <span style="color: navy; font-weight: bold;">new </span>File(path, folderName);
<span style="color: navy; font-weight: bold;">if </span>(!SDCardRoot.exists()) {
SDCardRoot.mkdir();
}
<span style="color: navy; font-weight: bold;">return </span>SDCardRoot;
}
<span style="color: navy; font-weight: bold;">public static void </span>pickImage(Context mContext, <span style="color: navy; font-weight: bold;">int </span>CAMERA_PICK_IMAGE_REQUEST_CODE) {
Intent intent = <span style="color: navy; font-weight: bold;">new </span>Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
((Activity) mContext).startActivityForResult(intent, CAMERA_PICK_IMAGE_REQUEST_CODE);
}
<span style="color: navy; font-weight: bold;">public static void </span>recordVideo(Context mContext, <span style="color: navy; font-weight: bold;">int </span>CAMERA_CAPTURE_VIDEO_REQUEST_CODE, String camera) {
Intent intent = <span style="color: navy; font-weight: bold;">new </span>Intent(MediaStore.ACTION_VIDEO_CAPTURE);
<span style="color: #660e7a; font-style: italic;">fileUri </span>= <span style="font-style: italic;">getOutputMediaFileUri</span>(<span style="color: #660e7a; font-style: italic; font-weight: bold;">MEDIA_TYPE_VIDEO</span>);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, <span style="color: blue;">1</span>);
intent.putExtra(MediaStore.EXTRA_OUTPUT, <span style="color: #660e7a; font-style: italic;">fileUri</span>);
<span style="color: navy; font-weight: bold;">if </span>(camera.equalsIgnoreCase(<span style="color: green; font-weight: bold;">"Front"</span>)) {
intent.putExtra(<span style="color: green; font-weight: bold;">"android.intent.extras.CAMERA_FACING"</span>, Camera.CameraInfo.CAMERA_FACING_FRONT);
} <span style="color: navy; font-weight: bold;">else if </span>(camera.equalsIgnoreCase(<span style="color: green; font-weight: bold;">"Back"</span>)) {
intent.putExtra(<span style="color: green; font-weight: bold;">"android.intent.extras.CAMERA_FACING"</span>, Camera.CameraInfo.CAMERA_FACING_BACK);
}
((Activity) mContext).startActivityForResult(intent, CAMERA_CAPTURE_VIDEO_REQUEST_CODE);
}
<span style="color: navy; font-weight: bold;">public static void </span>pickVideo(Context mContext, <span style="color: navy; font-weight: bold;">int </span>CAMERA_PICK_VIDEO_REQUEST_CODE) {
Intent intent = <span style="color: navy; font-weight: bold;">new </span>Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType(<span style="color: green; font-weight: bold;">"video/*"</span>);
((Activity) mContext).startActivityForResult(intent, CAMERA_PICK_VIDEO_REQUEST_CODE);
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * getpath of picked image or video</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">uri</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@return</span><span style="color: grey; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;">
</span><span style="color: grey; font-style: italic;"> </span>@TargetApi(Build.VERSION_CODES.KITKAT)
<span style="color: navy; font-weight: bold;">public static </span>String getPath(<span style="color: navy; font-weight: bold;">final </span>Context context, <span style="color: navy; font-weight: bold;">final </span>Uri uri) {
<span style="color: navy; font-weight: bold;">final boolean </span>isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
<span style="color: grey; font-style: italic;">// DocumentProvider</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">if </span>(isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
<span style="color: grey; font-style: italic;">// ExternalStorageProvider</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">if </span>(<span style="font-style: italic;">isExternalStorageDocument</span>(uri)) {
<span style="color: navy; font-weight: bold;">final </span>String docId = DocumentsContract.getDocumentId(uri);
<span style="color: navy; font-weight: bold;">final </span>String[] split = docId.split(<span style="color: green; font-weight: bold;">":"</span>);
<span style="color: navy; font-weight: bold;">final </span>String type = split[<span style="color: blue;">0</span>];
<span style="color: navy; font-weight: bold;">if </span>(<span style="color: green; font-weight: bold;">"primary"</span>.equalsIgnoreCase(type)) {
<span style="color: navy; font-weight: bold;">return </span>Environment.getExternalStorageDirectory() + <span style="color: green; font-weight: bold;">"/" </span>+ split[<span style="color: blue;">1</span>];
}
}
<span style="color: grey; font-style: italic;">// DownloadsProvider</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">else if </span>(<span style="font-style: italic;">isDownloadsDocument</span>(uri)) {
<span style="color: navy; font-weight: bold;">final </span>String id = DocumentsContract.getDocumentId(uri);
<span style="color: navy; font-weight: bold;">final </span>Uri contentUri = ContentUris.withAppendedId(
Uri.parse(<span style="color: green; font-weight: bold;">"content://downloads/public_downloads"</span>), Long.valueOf(id));
<span style="color: navy; font-weight: bold;">return </span><span style="font-style: italic;">getDataColumn</span>(context, contentUri, <span style="color: navy; font-weight: bold;">null</span>, <span style="color: navy; font-weight: bold;">null</span>);
}
<span style="color: grey; font-style: italic;">// MediaProvider</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">else if </span>(<span style="font-style: italic;">isMediaDocument</span>(uri)) {
<span style="color: navy; font-weight: bold;">final </span>String docId = DocumentsContract.getDocumentId(uri);
<span style="color: navy; font-weight: bold;">final </span>String[] split = docId.split(<span style="color: green; font-weight: bold;">":"</span>);
<span style="color: navy; font-weight: bold;">final </span>String type = split[<span style="color: blue;">0</span>];
Uri contentUri = <span style="color: navy; font-weight: bold;">null</span>;
<span style="color: navy; font-weight: bold;">if </span>(<span style="color: green; font-weight: bold;">"image"</span>.equals(type)) {
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} <span style="color: navy; font-weight: bold;">else if </span>(<span style="color: green; font-weight: bold;">"video"</span>.equals(type)) {
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} <span style="color: navy; font-weight: bold;">else if </span>(<span style="color: green; font-weight: bold;">"audio"</span>.equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
<span style="color: navy; font-weight: bold;">final </span>String selection = <span style="color: green; font-weight: bold;">"_id=?"</span>;
<span style="color: navy; font-weight: bold;">final </span>String[] selectionArgs = <span style="color: navy; font-weight: bold;">new </span>String[]{
split[<span style="color: blue;">1</span>]
};
<span style="color: navy; font-weight: bold;">return </span><span style="font-style: italic;">getDataColumn</span>(context, contentUri, selection, selectionArgs);
}
}
<span style="color: grey; font-style: italic;">// MediaStore (and general)</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">else if </span>(<span style="color: green; font-weight: bold;">"content"</span>.equalsIgnoreCase(uri.getScheme())) {
<span style="color: grey; font-style: italic;">// Return the remote address</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">if </span>(<span style="font-style: italic;">isGooglePhotosUri</span>(uri))
<span style="color: navy; font-weight: bold;">return </span>uri.getLastPathSegment();
<span style="color: navy; font-weight: bold;">return </span><span style="font-style: italic;">getDataColumn</span>(context, uri, <span style="color: navy; font-weight: bold;">null</span>, <span style="color: navy; font-weight: bold;">null</span>);
}
<span style="color: grey; font-style: italic;">// File</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">else if </span>(<span style="color: green; font-weight: bold;">"file"</span>.equalsIgnoreCase(uri.getScheme())) {
<span style="color: navy; font-weight: bold;">return </span>uri.getPath();
}
<span style="color: navy; font-weight: bold;">return null</span>;
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">uri </span><span style="color: grey; font-style: italic;">The Uri to check.</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@return </span><span style="color: grey; font-style: italic;">Whether the Uri authority is ExternalStorageProvider.</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static boolean </span>isExternalStorageDocument(Uri uri) {
<span style="color: navy; font-weight: bold;">return </span><span style="color: green; font-weight: bold;">"com.android.externalstorage.documents"</span>.equals(uri.getAuthority());
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">uri </span><span style="color: grey; font-style: italic;">The Uri to check.</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@return </span><span style="color: grey; font-style: italic;">Whether the Uri authority is DownloadsProvider.</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static boolean </span>isDownloadsDocument(Uri uri) {
<span style="color: navy; font-weight: bold;">return </span><span style="color: green; font-weight: bold;">"com.android.providers.downloads.documents"</span>.equals(uri.getAuthority());
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * Get the value of the data column for this Uri. This is useful for</span><span style="color: grey; font-style: italic;"> * MediaStore Uris, and other file-based ContentProviders.</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context </span><span style="color: grey; font-style: italic;">The context.</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">uri </span><span style="color: grey; font-style: italic;">The Uri to query.</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">selection </span><span style="color: grey; font-style: italic;">(Optional) Filter used in the query.</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">selectionArgs </span><span style="color: grey; font-style: italic;">(Optional) Selection arguments used in the query.</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@return </span><span style="color: grey; font-style: italic;">The value of the _data column, which is typically a file path.</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static </span>String getDataColumn(Context context, Uri uri, String selection,
String[] selectionArgs) {
Cursor cursor = <span style="color: navy; font-weight: bold;">null</span>;
<span style="color: navy; font-weight: bold;">final </span>String column = <span style="color: green; font-weight: bold;">"_data"</span>;
<span style="color: navy; font-weight: bold;">final </span>String[] projection = {
column
};
<span style="color: navy; font-weight: bold;">try </span>{
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
<span style="color: navy; font-weight: bold;">null</span>);
<span style="color: navy; font-weight: bold;">if </span>(cursor != <span style="color: navy; font-weight: bold;">null </span>&& cursor.moveToFirst()) {
<span style="color: navy; font-weight: bold;">final int </span>index = cursor.getColumnIndexOrThrow(column);
<span style="color: navy; font-weight: bold;">return </span>cursor.getString(index);
}
} <span style="color: navy; font-weight: bold;">finally </span>{
<span style="color: navy; font-weight: bold;">if </span>(cursor != <span style="color: navy; font-weight: bold;">null</span>)
cursor.close();
}
<span style="color: navy; font-weight: bold;">return null</span>;
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">uri </span><span style="color: grey; font-style: italic;">The Uri to check.</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@return </span><span style="color: grey; font-style: italic;">Whether the Uri authority is MediaProvider.</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static boolean </span>isMediaDocument(Uri uri) {
<span style="color: navy; font-weight: bold;">return </span><span style="color: green; font-weight: bold;">"com.android.providers.media.documents"</span>.equals(uri.getAuthority());
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">uri </span><span style="color: grey; font-style: italic;">The Uri to check.</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@return </span><span style="color: grey; font-style: italic;">Whether the Uri authority is Google Photos.</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static boolean </span>isGooglePhotosUri(Uri uri) {
<span style="color: navy; font-weight: bold;">return </span><span style="color: green; font-weight: bold;">"com.google.android.apps.photos.content"</span>.equals(uri.getAuthority());
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * Function to display simple Alert Dialog or Toast</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context </span><span style="color: grey; font-style: italic;">- application context</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">title </span><span style="color: grey; font-style: italic;">- alert dialog title</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">message </span><span style="color: grey; font-style: italic;">- alert message</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">toast </span><span style="color: grey; font-style: italic;">- show as toast or dialog</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static void </span>showAlertDialog(Context context, String title, String message, <span style="color: navy; font-weight: bold;">boolean </span>toast) {
<span style="color: navy; font-weight: bold;">if </span>(toast) {
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
} <span style="color: navy; font-weight: bold;">else </span>{
AlertDialog alertDialog = <span style="color: navy; font-weight: bold;">null</span>;
<span style="color: navy; font-weight: bold;">if </span>(!((Activity) context).isFinishing()) {
<span style="color: navy; font-weight: bold;">if </span>(alertDialog == <span style="color: navy; font-weight: bold;">null</span>)
alertDialog = <span style="color: navy; font-weight: bold;">new </span>AlertDialog.Builder(context).create();
<span style="color: grey; font-style: italic;">// Setting Dialog Title</span><span style="color: grey; font-style: italic;"> </span>alertDialog.setTitle(title);
<span style="color: grey; font-style: italic;">// Setting Dialog Message</span><span style="color: grey; font-style: italic;"> </span>alertDialog.setMessage(message);
<span style="color: grey; font-style: italic;">// Setting OK Button</span><span style="color: grey; font-style: italic;"> </span>alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL, <span style="color: green; font-weight: bold;">"OK"</span>, <span style="color: navy; font-weight: bold;">new </span>DialogInterface.OnClickListener() {
<span style="color: navy; font-weight: bold;">public void </span>onClick(DialogInterface dialog, <span style="color: navy; font-weight: bold;">int </span>which) {
dialog.dismiss();
}
});
<span style="color: grey; font-style: italic;">// Showing Alert Message</span><span style="color: grey; font-style: italic;"> </span>alertDialog.show();
}
}
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * use for getting device height</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">mContext</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@return </span><span style="color: grey; font-style: italic;">height of your device</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static int </span>getDeviceHeight(Context mContext) {
DisplayMetrics displaymetrics = <span style="color: navy; font-weight: bold;">new </span>DisplayMetrics();
((Activity) mContext).getWindowManager().getDefaultDisplay()
.getMetrics(displaymetrics);
<span style="color: navy; font-weight: bold;">return </span>displaymetrics.heightPixels;
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * use for getting device width</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">mContext</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@return </span><span style="color: grey; font-style: italic;">width of your device</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static int </span>getDeviceWidth(Context mContext) {
DisplayMetrics displaymetrics = <span style="color: navy; font-weight: bold;">new </span>DisplayMetrics();
((Activity) mContext).getWindowManager().getDefaultDisplay()
.getMetrics(displaymetrics);
<span style="color: navy; font-weight: bold;">return </span>displaymetrics.widthPixels;
}
<span style="color: navy; font-weight: bold;">public static void </span>hideKeyboard(Context mContext, View v) {
<span style="color: grey; font-style: italic;">// </span><span style="color: #0073bf; font-style: italic; font-weight: bold;">TODO Auto-generated method stub</span><span style="color: #0073bf; font-style: italic; font-weight: bold;"> </span>InputMethodManager imm = (InputMethodManager) mContext
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
<span style="color: navy; font-weight: bold;">public static boolean </span>isWebsiteUrlValid(String url) {
<span style="color: navy; font-weight: bold;">return </span>Patterns.WEB_URL.matcher(url).matches();
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * set login type</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">mContext</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">string</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static void </span>setLoginStatus(Context mContext, String string) {
<span style="font-style: italic;">setPrefrencesBoolean</span>(mContext, mContext.getResources().getString(R.string.pref_is_login_urateit), <span style="color: navy; font-weight: bold;">false</span>);
<span style="font-style: italic;">setPrefrencesBoolean</span>(mContext, mContext.getResources().getString(R.string.pref_is_login_linkedin), <span style="color: navy; font-weight: bold;">false</span>);
<span style="font-style: italic;">setPrefrencesBoolean</span>(mContext, mContext.getResources().getString(R.string.pref_is_login_facebook), <span style="color: navy; font-weight: bold;">false</span>);
<span style="font-style: italic;">setPrefrencesBoolean</span>(mContext, mContext.getResources().getString(R.string.pref_is_login_twitter), <span style="color: navy; font-weight: bold;">false</span>);
<span style="color: navy; font-weight: bold;">if </span>(string.equals(mContext.getResources().getString(R.string.pref_is_login_urateit))) {
<span style="font-style: italic;">setPrefrencesBoolean</span>(mContext, mContext.getResources().getString(R.string.pref_is_login_urateit), <span style="color: navy; font-weight: bold;">true</span>);
} <span style="color: navy; font-weight: bold;">else if </span>(string.equals(mContext.getResources().getString(R.string.pref_is_login_linkedin))) {
<span style="font-style: italic;">setPrefrencesBoolean</span>(mContext, mContext.getResources().getString(R.string.pref_is_login_linkedin), <span style="color: navy; font-weight: bold;">true</span>);
} <span style="color: navy; font-weight: bold;">else if </span>(string.equals(mContext.getResources().getString(R.string.pref_is_login_facebook))) {
<span style="font-style: italic;">setPrefrencesBoolean</span>(mContext, mContext.getResources().getString(R.string.pref_is_login_facebook), <span style="color: navy; font-weight: bold;">true</span>);
} <span style="color: navy; font-weight: bold;">else if </span>(string.equals(mContext.getResources().getString(R.string.pref_is_login_twitter))) {
<span style="font-style: italic;">setPrefrencesBoolean</span>(mContext, mContext.getResources().getString(R.string.pref_is_login_twitter), <span style="color: navy; font-weight: bold;">true</span>);
}
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * set Boolean Preference Value</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">prefName</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">Value</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static void </span>setPrefrencesBoolean(Context context, String prefName, Boolean Value) {
<span style="color: #660e7a; font-style: italic;">prefs </span>= context.getSharedPreferences(<span style="color: #660e7a; font-style: italic;">PREFS_FILE_NAME</span>, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = <span style="color: #660e7a; font-style: italic;">prefs</span>.edit();
editor.putBoolean(prefName, Value);
editor.commit();
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * get log in status</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">mContext</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@return</span><span style="color: grey; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static boolean </span>getLoginStatus(Context mContext) {
<span style="color: navy; font-weight: bold;">if </span>(<span style="font-style: italic;">getPrefrencesBoolean</span>(mContext, mContext.getResources().getString(R.string.pref_is_login_urateit))) {
<span style="color: navy; font-weight: bold;">return true</span>;
} <span style="color: navy; font-weight: bold;">else if </span>(<span style="font-style: italic;">getPrefrencesBoolean</span>(mContext, mContext.getResources().getString(R.string.pref_is_login_linkedin))) {
<span style="color: navy; font-weight: bold;">return true</span>;
} <span style="color: navy; font-weight: bold;">else if </span>(<span style="font-style: italic;">getPrefrencesBoolean</span>(mContext, mContext.getResources().getString(R.string.pref_is_login_facebook))) {
<span style="color: navy; font-weight: bold;">return true</span>;
} <span style="color: navy; font-weight: bold;">else if </span>(<span style="font-style: italic;">getPrefrencesBoolean</span>(mContext, mContext.getResources().getString(R.string.pref_is_login_twitter))) {
<span style="color: navy; font-weight: bold;">return true</span>;
} <span style="color: navy; font-weight: bold;">else </span>{
<span style="color: navy; font-weight: bold;">return false</span>;
}
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * get Boolean Preference Value</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">context</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">prefName</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@return</span><span style="color: grey; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">*/</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static boolean </span>getPrefrencesBoolean(Context context, String prefName) {
<span style="color: #660e7a; font-style: italic;">prefs </span>= context.getSharedPreferences(<span style="color: #660e7a; font-style: italic;">PREFS_FILE_NAME</span>, Context.MODE_PRIVATE);
<span style="color: navy; font-weight: bold;">return </span><span style="color: #660e7a; font-style: italic;">prefs</span>.getBoolean(prefName, <span style="color: navy; font-weight: bold;">false</span>);
}
<span style="color: navy; font-weight: bold;">public static </span>ArrayList<String> getNameEmailDetails(Context context) {
ArrayList<String> emlRecs = <span style="color: navy; font-weight: bold;">new </span>ArrayList<String>();
HashSet<String> emlRecsHS = <span style="color: navy; font-weight: bold;">new </span>HashSet<String>();
ContentResolver cr = context.getContentResolver();
String[] PROJECTION = <span style="color: navy; font-weight: bold;">new </span>String[]{ContactsContract.RawContacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.PHOTO_ID,
ContactsContract.CommonDataKinds.Email.DATA,
ContactsContract.CommonDataKinds.Photo.CONTACT_ID};
String order = <span style="color: green; font-weight: bold;">"CASE WHEN "</span><span style="color: green; font-weight: bold;"> </span>+ ContactsContract.Contacts.DISPLAY_NAME
+ <span style="color: green; font-weight: bold;">" NOT LIKE '%@%' THEN 1 ELSE 2 END, "</span><span style="color: green; font-weight: bold;"> </span>+ ContactsContract.Contacts.DISPLAY_NAME
+ <span style="color: green; font-weight: bold;">", "</span><span style="color: green; font-weight: bold;"> </span>+ ContactsContract.CommonDataKinds.Email.DATA
+ <span style="color: green; font-weight: bold;">" COLLATE NOCASE"</span>;
String filter = ContactsContract.CommonDataKinds.Email.DATA + <span style="color: green; font-weight: bold;">" NOT LIKE ''"</span>;
Cursor cur = cr.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, PROJECTION, filter, <span style="color: navy; font-weight: bold;">null</span>, order);
<span style="color: navy; font-weight: bold;">if </span>(cur != <span style="color: navy; font-weight: bold;">null</span>) {
<span style="color: navy; font-weight: bold;">if </span>(cur.moveToFirst()) {
<span style="color: navy; font-weight: bold;">do </span>{
<span style="color: grey; font-style: italic;">// names comes in hand sometimes</span><span style="color: grey; font-style: italic;"> </span>String name = cur.getString(<span style="color: blue;">1</span>);
String emlAddr = cur.getString(<span style="color: blue;">3</span>);
<span style="color: grey; font-style: italic;">// keep unique only</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">if </span>(emlRecsHS.add(emlAddr.toLowerCase())) {
emlRecs.add(name + <span style="color: green; font-weight: bold;">", " </span>+ emlAddr);
}
} <span style="color: navy; font-weight: bold;">while </span>(cur.moveToNext());
}
cur.close();
}
<span style="color: navy; font-weight: bold;">return </span>emlRecs;
}
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * use to show datepicker</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">mContext</span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;"> </span><span style="color: grey; font-style: italic;">* </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">format </span><span style="color: grey; font-style: italic;">of the date format</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@param </span><span style="color: #3d3d3d; font-style: italic; font-weight: bold;">mTextView </span><span style="color: grey; font-style: italic;">in which you have to set selected date</span><span style="color: grey; font-style: italic;"> */</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">public static void </span>showDatePickerDialog(<span style="color: navy; font-weight: bold;">final </span>Context mContext, <span style="color: navy; font-weight: bold;">final </span>String format, <span style="color: navy; font-weight: bold;">final </span>TextView mTextView) {
<span style="color: navy; font-weight: bold;">final </span>Calendar dateTime = Calendar.getInstance();
<span style="color: navy; font-weight: bold;">new </span>DatePickerDialog(mContext, <span style="color: navy; font-weight: bold;">new </span>DatePickerDialog.OnDateSetListener() {
@Override
<span style="color: navy; font-weight: bold;">public void </span>onDateSet(DatePicker view, <span style="color: navy; font-weight: bold;">int </span>year, <span style="color: navy; font-weight: bold;">int </span>monthOfYear,
<span style="color: navy; font-weight: bold;">int </span>dayOfMonth) {
<span style="color: grey; font-style: italic;">// SimpleDateFormat dateFormatter = new SimpleDateFormat(format);</span><span style="color: grey; font-style: italic;"> </span><span style="color: #660e7a;">dateTime</span>.set(year, monthOfYear, dayOfMonth);
String dateText = dayOfMonth + <span style="color: green; font-weight: bold;">"-" </span>+ monthOfYear + <span style="color: green; font-weight: bold;">"-" </span>+ year + <span style="color: green; font-weight: bold;">" " </span>+ <span style="color: #660e7a;">dateTime</span>.get(Calendar.HOUR) + <span style="color: green; font-weight: bold;">":" </span>+ <span style="color: navy; font-weight: bold;">new </span>DecimalFormat(<span style="color: green; font-weight: bold;">"#0"</span>).format(<span style="color: #660e7a;">dateTime</span>.get(Calendar.MINUTE));
<span style="color: #660e7a;">mTextView</span>.setText(dateText);
Appconfig.schedule = dateText;
<span style="color: navy; font-weight: bold;">new </span>DecimalFormat(<span style="color: green; font-weight: bold;">"#0"</span>).format(<span style="color: #660e7a;">dateTime</span>.get(Calendar.MINUTE));
}
}, dateTime.get(Calendar.YEAR), dateTime.get(Calendar.MONTH),
dateTime.get(Calendar.DAY_OF_MONTH)).show();
}
}</pre>
</div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com1tag:blogger.com,1999:blog-2514376929712218536.post-17425659498150485132016-04-26T05:05:00.003-07:002016-04-26T05:38:48.379-07:00API parsing MyClientPost For sending Image to server Part 3<div dir="ltr" style="text-align: left;" trbidi="on">
<pre style="background-color: white; font-family: 'Courier New'; font-size: 9pt;"><span style="color: navy; font-weight: bold;">import </span>android.app.ProgressDialog;
<span style="color: navy; font-weight: bold;">import </span>android.content.Context;
<span style="color: navy; font-weight: bold;">import </span>android.os.AsyncTask;
<span style="color: navy; font-weight: bold;">import </span>android.util.Log;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.HttpEntity;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.HttpResponse;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.NameValuePair;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.client.HttpClient;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.client.entity.UrlEncodedFormEntity;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.client.methods.HttpPost;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.impl.client.DefaultHttpClient;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.message.BasicNameValuePair;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.util.EntityUtils;
<span style="color: navy; font-weight: bold;">import </span>org.json.JSONException;
<span style="color: navy; font-weight: bold;">import </span>org.json.JSONObject;
<span style="color: navy; font-weight: bold;">import </span>java.util.ArrayList;
<span style="color: navy; font-weight: bold;">import </span>java.util.Iterator;
<span style="color: navy; font-weight: bold;">import </span>java.util.List;
<span style="color: navy; font-weight: bold;">import </span>java.util.Map;
<span style="color: navy; font-weight: bold;">import </span>java.util.Map.Entry;
<span style="color: navy; font-weight: bold;">import </span>util.Utils;
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * This is used for post data from API.</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@author </span><span style="color: grey; font-style: italic;">Mayank</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@since </span><span style="color: grey; font-style: italic;">1.4</span><span style="color: grey; font-style: italic;"> */</span><span style="color: navy; font-weight: bold;">public class </span>MyClientPost <span style="color: navy; font-weight: bold;">extends </span>AsyncTask<Map<String, Object>, String, String> {
<span style="color: navy; font-weight: bold;">public </span>ProgressDialog <span style="color: #660e7a; font-weight: bold;">dialog</span>;
<span style="color: navy; font-weight: bold;">private </span>String <span style="color: #660e7a; font-weight: bold;">message</span>;
<span style="color: navy; font-weight: bold;">private </span>Context <span style="color: #660e7a; font-weight: bold;">context</span>;
<span style="color: navy; font-weight: bold;">private </span>OnPostCallComplete <span style="color: #660e7a; font-weight: bold;">onpostcallcomplete</span>;
<span style="color: navy; font-weight: bold;">private </span>JSONObject <span style="color: #660e7a; font-weight: bold;">jsonResult</span>;
<span style="color: navy; font-weight: bold;">public </span>MyClientPost(Context context, String progressMessage, OnPostCallComplete onPostCallComplete2) {
<span style="color: #660e7a; font-weight: bold;">message </span>= progressMessage;
<span style="color: navy; font-weight: bold;">this</span>.<span style="color: #660e7a; font-weight: bold;">context </span>= context;
<span style="color: navy; font-weight: bold;">this</span>.<span style="color: #660e7a; font-weight: bold;">onpostcallcomplete </span>= onPostCallComplete2;
<span style="color: navy; font-weight: bold;">if </span>(!(<span style="color: #660e7a; font-weight: bold;">message</span>.equals(<span style="color: green; font-weight: bold;">""</span>))) {
<span style="color: #660e7a; font-weight: bold;">dialog </span>= <span style="color: navy; font-weight: bold;">new </span>ProgressDialog(context);
<span style="color: #660e7a; font-weight: bold;">dialog</span>.setMessage(progressMessage);
}
}
@Override
<span style="color: navy; font-weight: bold;">protected void </span>onPreExecute() {
<span style="color: grey; font-style: italic;">// </span><span style="color: #0073bf; font-style: italic; font-weight: bold;">TODO Auto-generated method stub</span><span style="color: #0073bf; font-style: italic; font-weight: bold;"> </span><span style="color: navy; font-weight: bold;">super</span>.onPreExecute();
<span style="color: navy; font-weight: bold;">if </span>(!(<span style="color: #660e7a; font-weight: bold;">message</span>.equals(<span style="color: green; font-weight: bold;">""</span>))) {
<span style="color: #660e7a; font-weight: bold;">dialog</span>.setCancelable(<span style="color: navy; font-weight: bold;">false</span>);
<span style="color: #660e7a; font-weight: bold;">dialog</span>.show();
}
}
@Override
<span style="color: navy; font-weight: bold;">protected </span>String doInBackground(Map<String, Object>... params) {
String result = <span style="color: navy; font-weight: bold;">null</span>;
<span style="color: navy; font-weight: bold;">if </span>(!isCancelled()) {
Map<String, Object> passed_params = params[<span style="color: blue;">0</span>];
<span style="color: grey; font-style: italic;">// API call URL</span><span style="color: grey; font-style: italic;"> </span>String serverUrl = (String) passed_params.get(<span style="color: green; font-weight: bold;">"url"</span>);
Log.v(Utils.TAG, <span style="color: green; font-weight: bold;">"API url: " </span>+ serverUrl);
<span style="color: grey; font-style: italic;">// parameter data to send</span><span style="color: grey; font-style: italic;"> </span>@SuppressWarnings(<span style="color: green; font-weight: bold;">"unchecked"</span>)
Map<String, String> methodParameter = (Map<String, String>) passed_params.get(<span style="color: green; font-weight: bold;">"method_parameters"</span>);
<span style="color: navy; font-weight: bold;">try </span>{
HttpClient client = <span style="color: navy; font-weight: bold;">new </span>DefaultHttpClient();
HttpPost post = <span style="color: navy; font-weight: bold;">new </span>HttpPost(serverUrl);
Iterator<Entry<String, String>> iterator = methodParameter.entrySet().iterator();
List<NameValuePair> nameValuePairs = <span style="color: navy; font-weight: bold;">new </span>ArrayList<NameValuePair>(methodParameter.size());
<span style="color: navy; font-weight: bold;">while </span>(iterator.hasNext()) {
Entry<String, String> param = iterator.next();
nameValuePairs.add(<span style="color: navy; font-weight: bold;">new </span>BasicNameValuePair(param.getKey(), param.getValue()));
}
Log.v(Utils.TAG, <span style="color: green; font-weight: bold;">"post latlng " </span>+ nameValuePairs.toString());
UrlEncodedFormEntity entity = <span style="color: navy; font-weight: bold;">new </span>UrlEncodedFormEntity(nameValuePairs);
post.setEntity(entity);
HttpResponse response = client.execute(post);
HttpEntity resp_entity = response.getEntity();
result = EntityUtils.toString(resp_entity);
<span style="color: grey; font-style: italic;">// System.out.println("result in post 80: "+result);</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">if </span>(response.getStatusLine().getStatusCode() != <span style="color: blue;">200</span>) {
Log.v(Utils.TAG, <span style="color: green; font-weight: bold;">"post status code " </span>+ response.getStatusLine().getStatusCode());
<span style="color: #660e7a; font-weight: bold;">jsonResult </span>= <span style="color: navy; font-weight: bold;">new </span>JSONObject();
<span style="color: #660e7a; font-weight: bold;">jsonResult</span>.put(<span style="color: green; font-weight: bold;">"response_code"</span>, <span style="color: green; font-weight: bold;">"9999"</span>);
<span style="color: #660e7a; font-weight: bold;">jsonResult</span>.put(<span style="color: green; font-weight: bold;">"response_message"</span>, <span style="color: green; font-weight: bold;">"85 Server error occurred while processing request. Please try again."</span>);
result = <span style="color: #660e7a; font-weight: bold;">jsonResult</span>.toString();
<span style="color: navy; font-weight: bold;">return </span>result;
}
} <span style="color: navy; font-weight: bold;">catch </span>(Exception e) {
Log.v(Utils.TAG, <span style="color: green; font-weight: bold;">"post exception " </span>+ e.getMessage());
<span style="color: navy; font-weight: bold;">try </span>{
<span style="color: #660e7a; font-weight: bold;">jsonResult </span>= <span style="color: navy; font-weight: bold;">new </span>JSONObject();
<span style="color: #660e7a; font-weight: bold;">jsonResult</span>.put(<span style="color: green; font-weight: bold;">"response_code"</span>, <span style="color: green; font-weight: bold;">"9999"</span>);
<span style="color: #660e7a; font-weight: bold;">jsonResult</span>.put(<span style="color: green; font-weight: bold;">"response_message"</span>, <span style="color: green; font-weight: bold;">"94 Server error occurred while processing request. Please try again."</span>);
result = <span style="color: #660e7a; font-weight: bold;">jsonResult</span>.toString();
<span style="color: navy; font-weight: bold;">return </span>result;
} <span style="color: navy; font-weight: bold;">catch </span>(JSONException jsone) {
jsone.printStackTrace();
}
}
}
<span style="color: grey; font-style: italic;">//System.out.println("result in post: "+result);</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">return </span>result;
}
@Override
<span style="color: navy; font-weight: bold;">protected void </span>onPostExecute(String result) {
<span style="color: grey; font-style: italic;">// </span><span style="color: #0073bf; font-style: italic; font-weight: bold;">TODO Auto-generated method stub</span><span style="color: #0073bf; font-style: italic; font-weight: bold;"> </span><span style="color: navy; font-weight: bold;">super</span>.onPostExecute(result);
<span style="color: navy; font-weight: bold;">if </span>(!(<span style="color: #660e7a; font-weight: bold;">message</span>.equals(<span style="color: green; font-weight: bold;">""</span>))) {
<span style="color: navy; font-weight: bold;">if </span>(<span style="color: #660e7a; font-weight: bold;">dialog </span>!= <span style="color: navy; font-weight: bold;">null</span>) {
<span style="color: #660e7a; font-weight: bold;">dialog</span>.hide();
<span style="color: #660e7a; font-weight: bold;">dialog</span>.dismiss();
}
}
System.out.println(<span style="color: green; font-weight: bold;">"result in onPostExecute: " </span>+ result);
<span style="color: navy; font-weight: bold;">try </span>{
<span style="color: #660e7a; font-weight: bold;">onpostcallcomplete</span>.response(result);
} <span style="color: navy; font-weight: bold;">catch </span>(JSONException e) {
e.printStackTrace();
}
}
<span style="color: navy; font-weight: bold;">public interface </span>OnPostCallComplete {
<span style="color: navy; font-weight: bold;">public void </span>response(String result) <span style="color: navy; font-weight: bold;">throws </span>JSONException;
}
}</pre>
<pre style="background-color: white; font-family: 'Courier New'; font-size: 9pt;"></pre>
<pre style="background-color: white; font-family: 'Courier New'; font-size: 9pt;">Download Jar files from here.</pre>
<pre style="background-color: white; font-family: 'Courier New'; font-size: 9pt;"></pre>
<pre style="background-color: white;"><span style="font-family: "courier new";"><span style="font-size: 12px;">https://drive.google.com/file/d/0B53Ze24TLSktWjQyeE9tbF9JVkk/view?usp=sharing</span></span></pre>
<pre style="background-color: white;"><span style="font-family: "courier new";"><span style="font-size: 12px;">
</span></span></pre>
<pre style="background-color: white;"><span style="font-family: "courier new";"><span style="font-size: 12px;">https://drive.google.com/file/d/0B53Ze24TLSktZGtFVzRQdFBvbFE/view?usp=sharing</span></span></pre>
<pre style="background-color: white;"><span style="font-family: "courier new";"><span style="font-size: 12px;">
</span></span></pre>
<pre style="background-color: white;"><span style="font-family: "courier new";"><span style="font-size: 12px;">https://drive.google.com/file/d/0B53Ze24TLSktck9JZDd5YkhoOW8/view?usp=sharing</span></span></pre>
<pre style="background-color: white;"><span style="font-family: "courier new";"><span style="font-size: 12px;">
</span></span></pre>
<pre style="background-color: white;"><span style="font-family: "courier new";"><span style="font-family: "courier new"; font-size: 12px;">Picasso: https://drive.google.com/file/d/0B53Ze24TLSktb1lzWmRFeUxEaXM/view?usp=sharing</span></span></pre>
<pre style="background-color: white;"><span style="font-family: "courier new";"><span style="font-size: 12px;">
</span></span></pre>
<pre style="background-color: white;"><span style="font-family: "courier new";"><span style="font-size: 12px;">
</span></span></pre>
<pre style="background-color: white;"><span style="font-family: "courier new";"><span style="font-size: 12px;"><pre style="font-family: 'courier new'; font-size: 9pt;">Call from activity</pre>
<pre style="font-family: 'courier new'; font-size: 9pt;">
</pre>
<pre style="font-size: 12px;"><span style="font-family: courier new;"> Map<String, String> get_params = new HashMap<String, String>();
</span><span style="font-family: 'courier new';">get_params </span><span style="font-family: 'courier new';">.put("type", type);</span>
<span style="font-family: courier new;"> Map<String, Object> api_params = new HashMap<String, Object>();
api_params.put("url", getResources().getString(URL, Utils.getAPIAccessKey(context), Utils.getUserAccessKey(context)));
api_params.put("method_parameters", </span><span style="font-family: 'courier new';">get_params </span><span style="font-family: 'courier new';">);</span>
<span style="font-family: courier new;"> System.out.println(api_params.values().toString());
MyClientPost posting = new MyClientPost(context, "Please wait", onGetCallComplete);
posting.execute(api_params);</span></pre>
<div style="font-size: 12px;">
<span style="font-family: courier new;">
</span></div>
<div>
<span style="font-size: 12px;">MyClientPost.OnPostCallComplete </span><span style="font-size: 12px;">onGetCallComplete </span><span style="font-size: 12px;">= new MyClientPost.OnPostCallComplete() {</span>
<span style="font-size: 12px;"> @Override
public void response(String result) {
try {
</span><span style="font-size: 12px;">JSONObject</span><span style="font-size: 12px;"> jobj = new JSONObject(result);</span></div>
<div>
<span style="font-size: 12px;"> String response_code = jobj.getString("response_code");
if (response_code.equals(getResources().getString(R.string.success_code))) {
JSONArray userContacts = jobj.getJSONArray("arrayname");</span></div>
<div>
<span style="font-size: 12px;"> for (int i = 0; i < </span><span style="font-size: 12px;">arrayname</span><span style="font-size: 12px;">.length(); i++) {</span></div>
<div>
<span style="font-size: 12px;">}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};</span></div>
</span></span></pre>
</div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com1tag:blogger.com,1999:blog-2514376929712218536.post-51511430877465549492016-04-26T05:04:00.003-07:002016-04-26T05:48:27.801-07:00API parsing MyClientGet For sending Image to server Part 2<div dir="ltr" style="text-align: left;" trbidi="on">
<pre style="background-color: white; font-family: 'Courier New'; font-size: 9pt;"><span style="color: navy; font-weight: bold;">import </span>android.app.ProgressDialog;
<span style="color: navy; font-weight: bold;">import </span>android.content.Context;
<span style="color: navy; font-weight: bold;">import </span>android.os.AsyncTask;
<span style="color: navy; font-weight: bold;">import </span>util.Utils;
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * This is used for get data from API.</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@author </span><span style="color: grey; font-style: italic;">Mayank</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@since </span><span style="color: grey; font-style: italic;">1.4</span><span style="color: grey; font-style: italic;"> */</span><span style="color: navy; font-weight: bold;">public class </span>MyClientGet <span style="color: navy; font-weight: bold;">extends </span>AsyncTask<String, String, String> {
<span style="color: navy; font-weight: bold;">private </span>ProgressDialog <span style="color: #660e7a; font-weight: bold;">dialog</span>;
<span style="color: navy; font-weight: bold;">private </span>String <span style="color: #660e7a; font-weight: bold;">message</span>;
<span style="color: navy; font-weight: bold;">private </span>Context <span style="color: #660e7a; font-weight: bold;">context</span>;
<span style="color: navy; font-weight: bold;">private </span>OnGetCallComplete <span style="color: #660e7a; font-weight: bold;">ongetcallcomplete</span>;
<span style="color: navy; font-weight: bold;">public </span>MyClientGet(Context ctx, String progressMessage, OnGetCallComplete onGetCallComplete) {
<span style="color: #660e7a; font-weight: bold;">message </span>= progressMessage;
<span style="color: navy; font-weight: bold;">this</span>.<span style="color: #660e7a; font-weight: bold;">context </span>= ctx;
<span style="color: navy; font-weight: bold;">this</span>.<span style="color: #660e7a; font-weight: bold;">ongetcallcomplete </span>= onGetCallComplete;
<span style="color: navy; font-weight: bold;">if </span>(!(<span style="color: #660e7a; font-weight: bold;">message</span>.equals(<span style="color: green; font-weight: bold;">""</span>))) {
<span style="color: #660e7a; font-weight: bold;">dialog </span>= <span style="color: navy; font-weight: bold;">new </span>ProgressDialog(ctx);
<span style="color: #660e7a; font-weight: bold;">dialog</span>.setMessage(progressMessage);
}
}
@Override
<span style="color: navy; font-weight: bold;">protected void </span>onPreExecute() {
<span style="color: grey; font-style: italic;">// TODO Auto-generated method stub</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">super</span>.onPreExecute();
<span style="color: navy; font-weight: bold;">if </span>(!(<span style="color: #660e7a; font-weight: bold;">message</span>.equals(<span style="color: green; font-weight: bold;">""</span>))) {
<span style="color: #660e7a; font-weight: bold;">dialog</span>.setCancelable(<span style="color: navy; font-weight: bold;">false</span>);
<span style="color: #660e7a; font-weight: bold;">dialog</span>.show();
}
}
@Override
<span style="color: navy; font-weight: bold;">protected </span>String doInBackground(String... params) {
<span style="color: grey; font-style: italic;">// </span><span style="color: #0073bf; font-style: italic; font-weight: bold;">TODO Auto-generated method stub</span><span style="color: #0073bf; font-style: italic; font-weight: bold;"> </span>String result = <span style="color: navy; font-weight: bold;">null</span>;
<span style="color: navy; font-weight: bold;">if </span>(!isCancelled()) {
String serverurl = params[<span style="color: blue;">0</span>];
result = Utils.NetworkOperation(serverurl);
}
<span style="color: navy; font-weight: bold;">return </span>result;
}
@Override
<span style="color: navy; font-weight: bold;">protected void </span>onPostExecute(String result) {
<span style="color: grey; font-style: italic;">// </span><span style="color: #0073bf; font-style: italic; font-weight: bold;">TODO Auto-generated method stub</span><span style="color: #0073bf; font-style: italic; font-weight: bold;"> </span><span style="color: navy; font-weight: bold;">super</span>.onPostExecute(result);
<span style="color: navy; font-weight: bold;">if </span>(!(<span style="color: #660e7a; font-weight: bold;">message</span>.equals(<span style="color: green; font-weight: bold;">""</span>))) {
<span style="color: navy; font-weight: bold;">if </span>(<span style="color: #660e7a; font-weight: bold;">dialog </span>!= <span style="color: navy; font-weight: bold;">null</span>) {
<span style="color: #660e7a; font-weight: bold;">dialog</span>.hide();
<span style="color: #660e7a; font-weight: bold;">dialog</span>.dismiss();
}
}
<span style="color: #660e7a; font-weight: bold;">ongetcallcomplete</span>.response(result);
}
<span style="color: navy; font-weight: bold;">protected void </span>onProgressUpdate(String... progress) {
}
<span style="color: navy; font-weight: bold;">public interface </span>OnGetCallComplete {
<span style="color: navy; font-weight: bold;">public void </span>response(String result);
}
}</pre>
<pre style="background-color: white; font-family: 'Courier New'; font-size: 9pt;">
</pre>
<pre style="background-color: white;"><span style="font-family: 'courier new'; font-size: 12px;"> MyClientGet </span><span style="font-family: courier new;"><span style="font-size: 12px;">myclientget = new MyClientGet(context, "", onAccessKeyCallComplete);
myclientget.execute(getResources().getString(URL, "param"));</span></span></pre>
<pre style="background-color: white;"><span style="font-family: courier new;"><span style="font-size: 12px;">
</span></span></pre>
<pre style="background-color: white;"><span style="font-family: courier new;"><span style="font-size: 12px;">
</span></span></pre>
<pre style="background-color: white;"><span style="font-family: courier new;"><span style="font-size: 12px;">/**
* Get AccessKey call Done.
*/
MyClientGet.OnGetCallComplete onAccessKeyCallComplete = new MyClientGet.OnGetCallComplete() {
@Override
public void response(String result) {
try {
jobj = new JSONObject(result);
String response_code = jobj.getString("response_code");
if (response_code.equals(getResources().getString(R.string.success_code))) {
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};</span></span></pre>
<pre style="background-color: white;"><span style="font-family: courier new;"><span style="font-size: 12px;">
</span></span></pre>
</div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-49112795532060693282016-04-26T05:03:00.000-07:002016-04-26T05:24:54.468-07:00API parsing MyClientMultipartPost For sending Image to server Part 1<div dir="ltr" style="text-align: left;" trbidi="on">
<pre style="background-color: white; font-family: 'Courier New'; font-size: 9pt;"><span style="color: navy; font-weight: bold;">import </span>android.app.ProgressDialog;
<span style="color: navy; font-weight: bold;">import </span>android.content.Context;
<span style="color: navy; font-weight: bold;">import </span>android.os.AsyncTask;
<span style="color: navy; font-weight: bold;">import </span>android.util.Log;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.HttpEntity;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.HttpResponse;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.client.HttpClient;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.client.methods.HttpPost;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.entity.mime.MultipartEntity;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.impl.client.DefaultHttpClient;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.protocol.BasicHttpContext;
<span style="color: navy; font-weight: bold;">import </span>org.apache.http.protocol.HttpContext;
<span style="color: navy; font-weight: bold;">import </span>org.json.JSONException;
<span style="color: navy; font-weight: bold;">import </span>org.json.JSONObject;
<span style="color: navy; font-weight: bold;">import </span>java.io.BufferedReader;
<span style="color: navy; font-weight: bold;">import </span>java.io.InputStream;
<span style="color: navy; font-weight: bold;">import </span>java.io.InputStreamReader;
<span style="color: grey; font-style: italic;">/**</span><span style="color: grey; font-style: italic;"> * This is used for post data from API.</span><span style="color: grey; font-style: italic;"> *</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@author </span><span style="color: grey; font-style: italic;">Mayank</span><span style="color: grey; font-style: italic;"> * </span><span style="color: grey; font-style: italic; font-weight: bold;">@since </span><span style="color: grey; font-style: italic;">1.4</span><span style="color: grey; font-style: italic;"> */</span><span style="color: navy; font-weight: bold;">public class </span>MyClientMultipartPost <span style="color: navy; font-weight: bold;">extends </span>AsyncTask<Void, Void, Void> {
<span style="color: navy; font-weight: bold;">private final </span>String <span style="color: #660e7a; font-weight: bold;">ApiLink</span>;
<span style="color: navy; font-weight: bold;">private final </span>MultipartEntity <span style="color: #660e7a; font-weight: bold;">multipartentity</span>;
<span style="color: navy; font-weight: bold;">public </span>ProgressDialog <span style="color: #660e7a; font-weight: bold;">dialog</span>;
<span style="color: navy; font-weight: bold;">private </span>String <span style="color: #660e7a; font-weight: bold;">message</span>;
<span style="color: navy; font-weight: bold;">private </span>Context <span style="color: #660e7a; font-weight: bold;">context</span>;
<span style="color: navy; font-weight: bold;">private </span>OnPostCallComplete <span style="color: #660e7a; font-weight: bold;">onpostcallcomplete</span>;
<span style="color: navy; font-weight: bold;">private </span>JSONObject <span style="color: #660e7a; font-weight: bold;">jsonResult</span>;
<span style="color: navy; font-weight: bold;">private </span>String <span style="color: #660e7a; font-weight: bold;">json</span>;
<span style="color: navy; font-weight: bold;">public </span>MyClientMultipartPost(Context context, String progressMessage,
OnPostCallComplete onPostCallComplete2, String ApiLink,
MultipartEntity multipartentity) {
<span style="color: #660e7a; font-weight: bold;">message </span>= progressMessage;
<span style="color: navy; font-weight: bold;">this</span>.<span style="color: #660e7a; font-weight: bold;">context </span>= context;
<span style="color: navy; font-weight: bold;">this</span>.<span style="color: #660e7a; font-weight: bold;">ApiLink </span>= ApiLink;
<span style="color: navy; font-weight: bold;">this</span>.<span style="color: #660e7a; font-weight: bold;">multipartentity </span>= multipartentity;
<span style="color: navy; font-weight: bold;">this</span>.<span style="color: #660e7a; font-weight: bold;">onpostcallcomplete </span>= onPostCallComplete2;
<span style="color: navy; font-weight: bold;">if </span>(!(<span style="color: #660e7a; font-weight: bold;">message</span>.equals(<span style="color: green; font-weight: bold;">""</span>))) {
<span style="color: #660e7a; font-weight: bold;">dialog </span>= <span style="color: navy; font-weight: bold;">new </span>ProgressDialog(context);
<span style="color: #660e7a; font-weight: bold;">dialog</span>.setMessage(progressMessage);
}
}
@Override
<span style="color: navy; font-weight: bold;">protected void </span>onPreExecute() {
<span style="color: grey; font-style: italic;">// </span><span style="color: #0073bf; font-style: italic; font-weight: bold;">TODO Auto-generated method stub</span><span style="color: #0073bf; font-style: italic; font-weight: bold;"> </span><span style="color: navy; font-weight: bold;">super</span>.onPreExecute();
<span style="color: navy; font-weight: bold;">if </span>(!(<span style="color: #660e7a; font-weight: bold;">message</span>.equals(<span style="color: green; font-weight: bold;">""</span>))) {
<span style="color: #660e7a; font-weight: bold;">dialog</span>.setCancelable(<span style="color: navy; font-weight: bold;">false</span>);
<span style="color: #660e7a; font-weight: bold;">dialog</span>.show();
}
}
@Override
<span style="color: navy; font-weight: bold;">protected </span>Void doInBackground(Void... params) {
String result = <span style="color: navy; font-weight: bold;">null</span>;
<span style="color: navy; font-weight: bold;">if </span>(!isCancelled()) {
InputStream is = <span style="color: navy; font-weight: bold;">null</span>;
JSONObject jObj = <span style="color: navy; font-weight: bold;">null</span>;
<span style="color: grey; font-style: italic;">// Utils.Log(getClass().getSimpleName(), "Url : " + ApiLink + " Params : " + multipartentity.toString());</span><span style="color: grey; font-style: italic;"> </span>System.out.println(<span style="color: green; font-weight: bold;">"create poll data " </span>+ <span style="color: #660e7a; font-weight: bold;">ApiLink</span>);
<span style="color: navy; font-weight: bold;">try </span>{
HttpClient httpclient = <span style="color: navy; font-weight: bold;">new </span>DefaultHttpClient();
HttpContext localContext = <span style="color: navy; font-weight: bold;">new </span>BasicHttpContext();
HttpPost httppost = <span style="color: navy; font-weight: bold;">new </span>HttpPost(<span style="color: #660e7a; font-weight: bold;">ApiLink</span>);
httppost.setEntity(<span style="color: #660e7a; font-weight: bold;">multipartentity</span>);
HttpResponse response = httpclient.execute(httppost, localContext);
<span style="color: navy; font-weight: bold;">if </span>(response == <span style="color: navy; font-weight: bold;">null</span>) {
} <span style="color: navy; font-weight: bold;">else </span>{
HttpEntity entity = response.getEntity();
is = entity.getContent();
<span style="color: grey; font-style: italic;">// Log.e("log_tag", ""+is.toString());</span><span style="color: grey; font-style: italic;"> </span>}
} <span style="color: navy; font-weight: bold;">catch </span>(Exception e) {
e.printStackTrace();
<span style="color: grey; font-style: italic;">// Log.e("log_tag", "Error in http connection " + e.toString());</span><span style="color: grey; font-style: italic;"> </span>}
<span style="color: grey; font-style: italic;">// convert response to string</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">try </span>{
BufferedReader reader = <span style="color: navy; font-weight: bold;">new </span>BufferedReader(<span style="color: navy; font-weight: bold;">new </span>InputStreamReader(is, <span style="color: green; font-weight: bold;">"iso-8859-1"</span>), <span style="color: blue;">8</span>);
StringBuilder sb = <span style="color: navy; font-weight: bold;">new </span>StringBuilder();
String line = <span style="color: navy; font-weight: bold;">null</span>;
<span style="color: navy; font-weight: bold;">while </span>((line = reader.readLine()) != <span style="color: navy; font-weight: bold;">null</span>) {
sb.append(line + <span style="color: green; font-weight: bold;">"</span><span style="color: navy; font-weight: bold;">\n</span><span style="color: green; font-weight: bold;">"</span>);
}
is.close();
<span style="color: #660e7a; font-weight: bold;">json </span>= sb.toString();
Log.i(<span style="color: green; font-weight: bold;">"res"</span>, <span style="color: #660e7a; font-weight: bold;">json</span>);
} <span style="color: navy; font-weight: bold;">catch </span>(Exception e) {
<span style="color: grey; font-style: italic;">// Log.e("log_tag", "Error converting result " + e.toString());</span><span style="color: grey; font-style: italic;"> </span>e.printStackTrace();
}
}
<span style="color: grey; font-style: italic;">//System.out.println("result in post: "+result);</span><span style="color: grey; font-style: italic;"> </span><span style="color: navy; font-weight: bold;">return null</span>;
}
@Override
<span style="color: navy; font-weight: bold;">protected void </span>onPostExecute(Void result) {
<span style="color: grey; font-style: italic;">// </span><span style="color: #0073bf; font-style: italic; font-weight: bold;">TODO Auto-generated method stub</span><span style="color: #0073bf; font-style: italic; font-weight: bold;"> </span><span style="color: navy; font-weight: bold;">super</span>.onPostExecute(result);
<span style="color: navy; font-weight: bold;">if </span>(!(<span style="color: #660e7a; font-weight: bold;">message</span>.equals(<span style="color: green; font-weight: bold;">""</span>))) {
<span style="color: navy; font-weight: bold;">if </span>(<span style="color: #660e7a; font-weight: bold;">dialog </span>!= <span style="color: navy; font-weight: bold;">null</span>) {
<span style="color: #660e7a; font-weight: bold;">dialog</span>.hide();
<span style="color: #660e7a; font-weight: bold;">dialog</span>.dismiss();
}
}
System.out.println(<span style="color: green; font-weight: bold;">"result in onPostExecute: " </span>+ result);
<span style="color: navy; font-weight: bold;">try </span>{
<span style="color: #660e7a; font-weight: bold;">onpostcallcomplete</span>.response(<span style="color: #660e7a; font-weight: bold;">json</span>);
} <span style="color: navy; font-weight: bold;">catch </span>(JSONException e) {
e.printStackTrace();
}
}
<span style="color: navy; font-weight: bold;">public interface </span>OnPostCallComplete {
<span style="color: navy; font-weight: bold;">public void </span>response(String result) <span style="color: navy; font-weight: bold;">throws </span>JSONException;
}
}</pre>
<pre style="background-color: white; font-family: 'Courier New'; font-size: 9pt;"></pre>
</div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-61307087828414527662014-09-16T05:54:00.000-07:002014-09-16T05:56:34.645-07:00Material Design Animation<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="preview-bar">
<div class="preview-wrapper">
This document is a preview.
</div>
</div>
<div class="qp-ui qp-ui-side-nav-drawer" data-qp-ui-data-id="qp:5" data-qp-ui="{ 'SideNavDrawer': {} }" id="side-nav">
<div class="side-nav-wrapper">
<span id="logo"><img alt="Google logo" src="http://material-design.storage.googleapis.com/images/Google_Logo.svg" height="142" width="320" /></span>
<br />
<div class="legal">
</div>
</div>
</div>
<div id="grid-cont">
<br />
<section class="grid_outer chapter">
<h1 class="chapter-title">
Authentic Motion</h1>
<div class="chapter-content">
<br />
<figure>
<div class="media">
</div>
</figure>
<br />
<div class="chapter-intro">
Perceiving an object's tangible form helps us understand how to
manipulate it. Observing an object's motion tells us whether it is light
or heavy, flexible or rigid, small or large. Motion in the world of
material design is not only beautiful, it builds meaning about the
spatial relationships, functionality, and intention of the system.
</div>
<br />
<nav class="chapter-toc">
<h1>
Contents</h1>
<ul>
<li><a class="gweb-smoothscroll-control qp-ui" data-qp-ui-data-id="qp:e" data-qp-ui="{ 'SmoothScroll': {} }" href="http://www.google.com/design/spec/animation/authentic-motion.html#authentic-motion-mass-weight">Mass and Weight</a></li>
</ul>
</nav>
<br />
<div class="article-list">
<div class="article qp-ui" data-qp-ui-data-id="qp:f" data-qp-ui="{ 'ScrollSpy': {} }" id="authentic-motion-mass-weight">
<h2 class="article-title qp-ui" data-qp-ui-data-id="qp:g" data-qp-ui="{ 'ResponsiveZippy': {} }">
Mass and Weight
</h2>
<div class="article-content">
<div class="article-intro">
Physical objects have mass and move only when forces are applied to
them. Consequently, objects can’t start or stop instantaneously.
Animation with abrupt starts and stops or rapid changes in direction
appears unnatural and can be an unexpected and unpleasant disruption for
the user.
</div>
<div class="module-list">
<div id="mass-weight-best-practices">
<br />
<section class="moduleE1">
<h3>
Best Practices</h3>
<div class="module-body">
A critical aspect of motion for material design is to retain the
feeling of physicality without sacrificing elegance, simplicity, beauty,
and the magic of a seamless user experience. Here are some guidelines
to help translate these concepts into animations.</div>
<div class="figure-group">
<div class="figure-row">
<br />
<figure class="example do">
<div class="media">
<div class="qp-ui qp-ui-video-player qp-ui-video-player-mouse" data-qp-ui-data-id="qp:h" data-qp-ui="{ 'VideoPlayer': {} }">
<label class="caption-title" for="animation-authentic-motion-authenticMotion_massAndWeight_ex1-do-1">Do.</label>
Motion with swift acceleration and gentle deceleration feels natural and delightful.
</div>
</div>
</figure>
</div>
</div>
</section>
</div>
<div id="mass-weight-best-practices-2">
<br />
<section class="moduleE1">
<div class="figure-group">
<div class="figure-row">
<br />
<figure class="example dont">
<div class="media">
<div class="qp-ui qp-ui-video-player qp-ui-video-player-mouse" data-qp-ui-data-id="qp:i" data-qp-ui="{ 'VideoPlayer': {} }">
<label class="caption-title" for="animation-authentic-motion-authenticMotion_massAndWeight_ex2-dont-1">Don't.</label>
Linear motion feels mechanical. An abrupt change in velocity at both the
beginning and end of the animation curve means the object
instantaneously starts and stops, which is unrealistic.
</div>
</div>
</figure>
</div>
</div>
</section>
</div>
<div id="mass-weight-special-cases">
<br />
<section class="moduleE1">
<h4>
Special Cases: Entering and Exiting Frame</h4>
<div class="module-body">
When an object enters the frame, ensure it's moving at its peak
velocity. This behavior emulates natural movement: a person entering the
frame of vision does not begin walking at the edge of the frame but
well before it. Similarly, when an object exits the frame, have it
maintain its velocity, rather than slowing down as it exits the frame.
Easing in when entering and slowing down when exiting draw the user's
attention to that motion, which, in most cases, isn't the effect you
want.</div>
<div class="figure-group">
<div class="figure-row">
<br />
<figure class="example do">
<div class="media">
<div class="qp-ui qp-ui-video-player qp-ui-video-player-mouse" data-qp-ui-data-id="qp:j" data-qp-ui="{ 'VideoPlayer': {} }">
<label class="caption-title" for="videos-authenticMotion_massAndWeight_ex3_do-do-1">Do.</label>
Enter and exit frame at peak velocity. The ball enters and exits frame at peak velocity, creating a confident transit
</div>
</div>
</figure>
<figure class="example dont"><div class="qp-ui qp-ui-video-player qp-ui-video-player-mouse" data-qp-ui-data-id="qp:k" data-qp-ui="{ 'VideoPlayer': {} }">
<label class="caption-title" for="animation-authenticmotion-massandweight-authenticmotion_massandweight_example6-dont-2">Don't.</label>
Speed up when entering or slow down when exiting. Don’t distract the user with unnecessary changes in velocity.
</div>
</figure>
</div>
</div>
</section>
</div>
<div id="mass-weight-making-adjustments">
<br />
<section class="moduleB1">
<h3>
Making adjustments</h3>
<div class="module-body">
Not all objects move the same way. Lighter/smaller objects may
accelerate or decelerate faster, because they have less mass and require
less force to do so. Larger/heavier objects may need more time to reach
peak speed and come to rest. Think about how this applies to the
various UI elements in your app and consider how their motion should be
represented.</div>
</section>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-59171440712417557632014-09-16T05:49:00.004-07:002014-09-16T05:51:25.251-07:00Material Design<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="preview-bar">
<div class="preview-wrapper">
This document is a preview.
</div>
</div>
<div class="qp-ui qp-ui-side-nav-drawer" data-qp-ui-data-id="qp:5" data-qp-ui="{ 'SideNavDrawer': {} }" id="side-nav">
<div class="side-nav-wrapper">
<span id="logo"><img alt="Google logo" src="http://material-design.storage.googleapis.com/images/Google_Logo.svg" height="280" width="640" /></span>
<br />
<nav>
<dl>
<dt class="qp-ui goog-zippy-header goog-zippy-expanded" data-qp-ui-data-id="qp:6" data-qp-ui="{ 'SideNavZippy': true }" role="tab" tabindex="0"><br /></dt>
<div style="overflow: hidden;">
<br />
<dd></dd></div>
<dt class="qp-ui goog-zippy-header goog-zippy-collapsed" data-qp-ui-data-id="qp:7" data-qp-ui="{ 'SideNavZippy': false }" role="tab" tabindex="0"><br /></dt>
<dt class="qp-ui goog-zippy-header goog-zippy-collapsed" data-qp-ui-data-id="qp:8" data-qp-ui="{ 'SideNavZippy': false }" role="tab" tabindex="0"><br /></dt>
<dt class="qp-ui goog-zippy-header goog-zippy-collapsed" data-qp-ui-data-id="qp:9" data-qp-ui="{ 'SideNavZippy': false }" role="tab" tabindex="0"><br /></dt>
<dt class="qp-ui goog-zippy-header goog-zippy-collapsed" data-qp-ui-data-id="qp:a" data-qp-ui="{ 'SideNavZippy': false }" role="tab" tabindex="0"><br /></dt>
<dt class="qp-ui goog-zippy-header goog-zippy-collapsed" data-qp-ui-data-id="qp:b" data-qp-ui="{ 'SideNavZippy': false }" role="tab" tabindex="0"><br /></dt>
<dt class="qp-ui goog-zippy-header goog-zippy-collapsed" data-qp-ui-data-id="qp:c" data-qp-ui="{ 'SideNavZippy': false }" role="tab" tabindex="0"><br /></dt>
<dt class="qp-ui goog-zippy-header goog-zippy-collapsed" data-qp-ui-data-id="qp:d" data-qp-ui="{ 'SideNavZippy': false }" role="tab" tabindex="0"><br /></dt>
</dl>
</nav>
<br />
<div class="legal">
</div>
</div>
</div>
<div id="grid-cont">
<br />
<section class="grid_outer chapter">
<h1 class="chapter-title">
Introduction</h1>
<div class="chapter-content">
<br />
<figure>
<div class="media">
<div>
<div style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;">
<source></source>
<img alt="" src="http://material-design.storage.googleapis.com/images/materialdesign-goals-landingimage_large_xhdpi.png" height="178" width="320" />
</div>
</div>
</div>
</figure>
<br />
<div class="chapter-intro">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
We challenged ourselves to create a visual language for our users that
synthesizes the classic principles of good design with the innovation
and possibility of technology and science.
This is material design.
This spec is a living document that will be updated as we continue to
develop the tenets and specifics of material design.
</div>
<br />
<nav class="chapter-toc">
<h1>
Contents</h1>
<ul>
<li><a class="gweb-smoothscroll-control qp-ui" data-qp-ui-data-id="qp:e" data-qp-ui="{ 'SmoothScroll': {} }" href="http://www.google.com/design/spec/material-design/introduction.html#introduction-goals">Goals</a></li>
<li><a class="gweb-smoothscroll-control qp-ui" data-qp-ui-data-id="qp:f" data-qp-ui="{ 'SmoothScroll': {} }" href="http://www.google.com/design/spec/material-design/introduction.html#introduction-principles">Principles</a></li>
</ul>
</nav>
<br />
<div class="article-list">
<div class="article qp-ui" data-qp-ui-data-id="qp:g" data-qp-ui="{ 'ScrollSpy': {} }" id="introduction-goals">
<h2 class="article-title qp-ui" data-qp-ui-data-id="qp:h" data-qp-ui="{ 'ResponsiveZippy': {} }">
Goals
</h2>
<div class="article-content">
<div class="module-list">
<div id="goals-goals-1">
<br />
<section class="moduleE1">
<div class="module-body">
Create a visual language that synthesizes classic principles of good
design with the innovation and possibility of technology and science.
</div>
<div class="figure-group">
<div class="figure-row">
<br />
<figure>
<div class="media">
<div>
<source></source>
<img alt="" src="http://material-design.storage.googleapis.com/images/materialdesign-goals-swirlanddot_large_xhdpi.png" height="189" width="400" />
</div>
</div>
</figure>
</div>
</div>
</section>
</div>
<div id="goals-goals-2">
<br />
<section class="moduleE1">
<div class="module-body">
Develop a single underlying system that allows for a unified experience
across platforms and device sizes. Mobile precepts are fundamental, but
touch, voice, mouse, and keyboard are all first-class input methods.
</div>
<div class="figure-group">
<div class="figure-row">
<br />
<figure>
<div class="media">
<div>
<source></source>
<img alt="" src="http://material-design.storage.googleapis.com/images/materialdesign-goals-cutrectangles_large_xhdpi.png" height="189" width="400" />
</div>
</div>
</figure>
</div>
</div>
</section>
</div>
</div>
</div>
</div>
<div class="article qp-ui" data-qp-ui-data-id="qp:i" data-qp-ui="{ 'ScrollSpy': {} }" id="introduction-principles">
<h2 class="article-title qp-ui" data-qp-ui-data-id="qp:j" data-qp-ui="{ 'ResponsiveZippy': {} }">
Principles
</h2>
<div class="article-content">
<div class="module-list">
<div id="principles-principles-1">
<br />
<section class="moduleC1 moduleC2">
<div class="figure-group">
<div class="figure-row">
<br />
<figure>
<div class="media">
<div>
<source></source>
<img alt="" src="http://material-design.storage.googleapis.com/images/materialdesign-principles-layersquares_large_xhdpi.png" height="400" width="400" />
</div>
</div>
<figcaption>
<div class="caption-title">
Material is the metaphor</div>
<br />A material metaphor is the unifying theory of a rationalized space
and a system of motion. The material is grounded in tactile reality,
inspired by the study of paper and ink, yet technologically advanced and
open to imagination and magic.<br /><br />
Surfaces and edges of the material provide visual cues that are grounded
in reality. The use of familiar tactile attributes helps users quickly
understand affordances. Yet the flexibility of the material creates new
affordances that supercede those in the physical world, without breaking
the rules of physics.<br /><br />
The fundamentals of light, surface, and movement are key to conveying
how objects move, interact, and exist in space in relation to each
other. Realistic lighting shows seams, divides space, and indicates
moving parts.
</figcaption>
</figure>
<figure>
<div class="media">
<div>
<source></source>
<img alt="" src="http://material-design.storage.googleapis.com/images/materialdesign-principles-circleplus_large_xhdpi.png" height="400" width="400" />
</div>
</div>
<figcaption>
<div class="caption-title">
Bold, graphic, intentional</div>
<br />The foundational elements of print-based design—typography, grids,
space, scale, color, and use of imagery—guide visual treatments. These
elements do far more than please the eye; they create hierarchy,
meaning, and focus. Deliberate color choices, edge-to-edge imagery,
large-scale typography, and intentional white space create a bold and
graphic interface that immerses the user in the experience.<br /><br />
An emphasis on user actions makes core functionality immediately apparent and provides waypoints for the user.
</figcaption>
</figure>
<figure>
<div class="media">
<div>
<source></source>
<img alt="" src="http://material-design.storage.googleapis.com/images/materialdesign-principles-flyingsquare_large_xhdpi.png" height="400" width="400" />
</div>
</div>
<figcaption>
<div class="caption-title">
Motion provides meaning</div>
<br />Motion respects and reinforces the user as the prime mover. Primary
user actions are inflection points that initiate motion, transforming
the whole design. <br /><br />
All action takes place in a single environment. Objects are presented to
the user without breaking the continuity of experience even as they
transform and reorganize.<br /><br />
Motion is meaningful and appropriate, serving to focus attention and
maintain continuity. Feedback is subtle yet clear. Transitions are
efficient yet coherent.
</figcaption>
</figure>
</div>
</div>
</section>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-73109446873966318122014-08-25T03:05:00.002-07:002014-08-25T03:07:24.440-07:00ActivitySceneTransitionBasic<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
This sample demonstrates how to the use <code><a href="http://developer.android.com/reference/android/app/Activity.html">Activity</a></code> scene
transitions when transitioning from one activity to another. Uses a combination
of <code>moveImage</code> and <code>changeBounds</code> to nicely transition
from a grid of images to an activity with a large image and detail text.<br />
<br />
<br />
<br />
<br />
<div style="text-align: left;">
<a href="https://blogger.googleusercontent.com/img/proxy/AVvXsEgnPQaMdZjuO2XRsgE20MhKhwqTak2Mfg77Qp6V21fisX6gtRafhItghwGEaDzuOVP-7iAz_bK1aQ_t1TIOxoMFFx1NLmPPRd2DI9PsS6cbeDEVEiQDahuQAkMecHPAY5WoSHbeTc9CjFFsv2a6NzuFgWzWNyB7KL1Xj3nC_1YpQoYeJFTrH5C3PSqXLQ=" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img alt="" border="0" src="http://developer.android.com/preview/images/ActivitySceneTransitionBasic.png" height="375" /></a><a href="http://github.com/googlesamples/android-ActivitySceneTransition"></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<a href="http://github.com/googlesamples/android-ActivitySceneTransition">Get it on GitHub</a></div>
<!-- Blogger automated replacement: "https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=http%3A%2F%2Fdeveloper.android.com%2Fpreview%2Fimages%2FActivitySceneTransitionBasic.png&container=blogger&gadget=a&rewriteMime=image%2F*" with "https://blogger.googleusercontent.com/img/proxy/AVvXsEgnPQaMdZjuO2XRsgE20MhKhwqTak2Mfg77Qp6V21fisX6gtRafhItghwGEaDzuOVP-7iAz_bK1aQ_t1TIOxoMFFx1NLmPPRd2DI9PsS6cbeDEVEiQDahuQAkMecHPAY5WoSHbeTc9CjFFsv2a6NzuFgWzWNyB7KL1Xj3nC_1YpQoYeJFTrH5C3PSqXLQ=" -->Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-37267449603951943052014-08-25T03:03:00.005-07:002014-08-25T03:03:51.453-07:00Camera2Video<div dir="ltr" style="text-align: left;" trbidi="on">
This sample demonstrates how to record video using the Camera2 API.<br />
<a href="http://github.com/googlesamples/android-Camera2Video">Get it on GitHub</a></div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-83733741659210022972014-08-25T03:03:00.002-07:002014-08-25T03:03:25.859-07:00Camera2Basic<div dir="ltr" style="text-align: left;" trbidi="on">
This sample demonstrates the basic use of the Camera2 API. The sample code
demonstrates how you can display camera preview and take pictures.<br />
<br />
<a href="http://github.com/googlesamples/android-Camera2Basic">Get it on GitHub</a></div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-8832330172083313662014-08-25T03:02:00.003-07:002014-08-25T03:02:53.397-07:00 Android L Developer Preview BasicManagedProfile<div dir="ltr" style="text-align: left;" trbidi="on">
This sample demonstrates how to create a managed profile. You can also:<br />
<ul>
<li>Enable or disable other apps, and set restrictions on them.</li>
<li>Configure intents to be forwarded between the primary account and the
managed profile.</li>
<li>Wipe all the data associated with the managed profile.</li>
</ul>
<div class="note">
<strong>Note:</strong> There can be only one managed profile on
a device at a time.</div>
<div class="note">
<br /></div>
<div class="note">
<img alt="" height="375" src="http://developer.android.com/preview/images/BasicManagedProfile.png" /> </div>
<div class="note">
<a href="http://github.com/googlesamples/android-BasicManagedProfile">Get it on GitHub</a> </div>
</div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-47315510733745359582014-03-22T02:52:00.001-07:002014-03-22T02:52:17.742-07:00Developer Preview<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="wear-section-header" style="text-align: left;">
<h2>
</h2>
<div class="wear-h1">
<h2>
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">Developer Preview</span></span></h2>
</div>
<h2>
</h2>
<div class="wear-subhead">
<h2>
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">
Your app’s notifications will already appear on Android wearables. <br />
With the new Android Wear APIs you can customize and extend those notifications.</span></span></h2>
<div class="wear-breakout cols">
<div class="col-3-wide">
<img alt="" src="http://developer.android.com/wear/images/screens/14_circle_voicereply.png" />
Receive Voice Replies<br />
<div class="wear-small">
Add actions to your notifications to allow users to
reply by voice or touch. The system delivers the text to your app on the
phone.
</div>
<div class="wear-small">
<a href="http://developer.android.com/wear/notifications/remote-input.html">Learn about input actions</a>
</div>
</div>
<div class="col-3-wide">
<div class="wear-inset-video-container">
<img class="gif" src="http://developer.android.com/wear/images/screens/pages_animated.gif" />
</div>
Add Notification Pages<br />
<div class="wear-small">
Add additional pages to your notification that are
visible on the wearable device to provide detailed information on the
wrist.
</div>
<div class="wear-small">
<a href="http://developer.android.com/wear/notifications/pages.html">Learn about pages</a>
</div>
</div>
<div class="col-3-wide">
<img alt="" src="http://developer.android.com/wear/images/screens/11_stack_B.png" />
Stack Multiple Notifications<br />
<div class="wear-small">
Your app should consolidate similar notifications. On a
wearable, you can stack them together so the details for each are
immediately available.
</div>
<div class="wear-small">
<a href="http://developer.android.com/wear/notifications/stacks.html">Learn about stacks</a></div>
<div class="wear-small">
<br /></div>
You can also trigger your notifications contextually using existing Android APIs. For example, use <a href="http://developer.android.com/training/location/geofencing.html">geofences</a> to provide glanceable information to your users when they are at home, or use the <a href="http://developer.android.com/training/location/activity-recognition.html">activity detection APIs</a> to send messages to your users’ wrists while they are bicycling.
<br />
See the <a href="http://developer.android.com/wear/design/index.html">Android Wear Developer Preview Design Principles</a> for more suggestions on creating great wearable experiences.<br />
<div class="wear-small">
</div>
</div>
</div>
<h2>
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"> </span></span></h2>
<h2>
<span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;"> </span></span></h2>
</div>
<h2>
</h2>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-45213786446465900782014-03-22T02:49:00.001-07:002014-03-22T02:50:30.365-07:00Android Wear<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="wrap">
<div class="wear-section-header">
<div class="wear-h1">
Extending Android to Wearables</div>
<div class="wear-subhead">
Android Wear extends the Android platform to a new generation of wearable devices. <br />
The user experience is designed specifically for wearables. </div>
<div class="wear-subhead">
</div>
</div>
<div class="wear-body">
<div class="wear-breakout cols">
<div class="col-3-wide">
<div class="wear-inset-video-container">
</div>
<div class="wear-small">
<br /></div>
<div class="wear-small">
<br /></div>
<div class="wear-small">
</div>
<div class="wear-inset-video-container">
<img class="gif" src="http://developer.android.com/wear/images/screens/reservation_animated.gif" /><br />
Say “Ok Google” to ask questions and get stuff done. </div>
<div class="wear-small">
<br /></div>
</div>
<div class="col-3-wide">
<img alt="Image of a Hangouts message" src="http://developer.android.com/wear/images/screens/circle_message2.png" />
<br />
<div class="wear-small">
Get glanceable, actionable information at just the right time throughout the day.
</div>
</div>
<div class="col-3-wide">
<img alt="Image showing " src="http://developer.android.com/wear/images/screens/fitness-24.png" />
<br />
<div class="wear-small">
A wide range of sensors is available to your applications, from accelerometers to heart rate monitors.
</div>
</div>
</div>
The Android Wear Developer Preview lets you create
wearable experiences for your existing Android apps and see how they
will appear on square and round Android wearables.
<br />
Later this year, we’ll be launching the Android Wear SDK, enabling even more customized experiences.
</div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-57824060361719285362014-03-20T21:58:00.002-07:002014-03-20T21:58:39.216-07:00When will we get it, how does it work?<div dir="ltr" style="text-align: left;" trbidi="on">
It’ll be a little while before we see Wear-running smartwatches on shelves - the first are planned for mid-late 2014 - but Google is already in the process of releasing an early version of the Wear SDK to developers. For the less geeky among you, SDK stands for software development kit, and is used to produce software for any particular system.<br /><br />It’s what developers will use to make Wear-compatible apps. And judging by how fast some of these developers are, it won’t take long.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5Q8RduPwqZERqaiSjCrLhD-OtpkAUn20NPnk-AtL3Wze0FANmhuHDAFPxZp5U8QRGvLuB2c_ncoSDMoscYss0VVF3jy57awjuN1UsAew5wVmF0BSFsqu8NeNyPmoIDDOgzy9Ukr6ycIw/s1600/android-wear-2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5Q8RduPwqZERqaiSjCrLhD-OtpkAUn20NPnk-AtL3Wze0FANmhuHDAFPxZp5U8QRGvLuB2c_ncoSDMoscYss0VVF3jy57awjuN1UsAew5wVmF0BSFsqu8NeNyPmoIDDOgzy9Ukr6ycIw/s1600/android-wear-2.jpg" height="213" width="320" /></a></div>
<b>Some Android watches are rounder than others</b><br />
<b> </b>Something one of Google’s talking heads said in the Android Wear developer demo video tells us much about how the software works. Director of Engineering on Android David Singleton said the apps are "still running on phones and tablets," but "provide richer experiences for the new form factor." The Wear part of an app sounds like it'll function a little like a plug-in for Android apps.<br /><br />At present Android Wear devices are intended to be paired with Android phones or tablets. It’s just how the Samsung Galaxy Gear and Sony SmartWatch 2 operate, except this time around they’ll be working within the walls of the same system. Apps than run on a Wear device won’t – necessarily – be fundamentally separate from the apps you run on your phone.<br /><br />The Google developer blog entry confirms this – Wear can use “existing Android APIs” to function. APIs are what control how apps operate within the Android system, and will be fundamental in making Wear watches feel much like your Android phone in use.<br /><b> </b><br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-43838780958387949942014-03-20T21:56:00.003-07:002014-03-20T21:56:47.008-07:00What is Android Wear?<div dir="ltr" style="text-align: left;" trbidi="on">
Android Wear is an extension of the Android mobile operating system designed to power wearable gadgets – primarily smartwatches. Although it has just been announced, it’s no small-scale operation. Many of the biggest mobile phone brands are working with the software already.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGqL6vtGxzghFl9ryMkLhqpk7bHVNzq5cIGCxLuLEADwdEhAYeLBKVPtq2iZzew_nkaJSNg4_9z0I6qr99bqPqO3EwzkYg3y8p6eLaY9Wkk8FEYbzP2_CFDkLAAbguKwjTTjImZWaPlUI/s1600/android-wear-promo.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGqL6vtGxzghFl9ryMkLhqpk7bHVNzq5cIGCxLuLEADwdEhAYeLBKVPtq2iZzew_nkaJSNg4_9z0I6qr99bqPqO3EwzkYg3y8p6eLaY9Wkk8FEYbzP2_CFDkLAAbguKwjTTjImZWaPlUI/s1600/android-wear-promo.jpg" height="179" width="320" /></a></div>
<div id="r1PostCPBlock" style="background-color: white; border: medium none; color: black; left: -99999px; overflow: hidden; position: absolute; text-align: left; text-decoration: none;">
Android
Wear will bring us the Google watch we’ve all been waiting for (well,
some of us). However, there are plenty more questions to ask about this
new version of Android.<br /><span>Read more at <a href="http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99" style="color: #003399;">http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99</a></span></div>
Android Wear will bring us the Google watch we’ve all been waiting for (well, some of us). However, there are plenty more questions to ask about this new version of Android.<br />
<br />
<br />
<div id="r1PostCPBlock" style="background-color: white; border: medium none; color: black; left: -99999px; overflow: hidden; position: absolute; text-align: left; text-decoration: none;">
<h2>
What is Android Wear?</h2>
Android
Wear is an extension of the Android mobile operating system designed to
power wearable gadgets – primarily smartwatches. Although it has just
been announced, it’s no small-scale operation. Many of the biggest
mobile phone brands are working with the software already. <br /><span>Read more at <a href="http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99" style="color: #003399;">http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99</a></span><div id="r1PostCPBlock" style="background-color: white; border: medium none; color: black; left: -99999px; overflow: hidden; position: absolute; text-align: left; text-decoration: none;">
<h2>
What is Android Wear?</h2>
Android
Wear is an extension of the Android mobile operating system designed to
power wearable gadgets – primarily smartwatches. Although it has just
been announced, it’s no small-scale operation. Many of the biggest
mobile phone brands are working with the software already. <br /><span>Read more at <a href="http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99" style="color: #003399;">http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99</a></span></div>
</div>
<div id="r1PostCPBlock" style="background-color: white; border: medium none; color: black; left: -99999px; overflow: hidden; position: absolute; text-align: left; text-decoration: none;">
<div id="r1PostCPBlock" style="background-color: white; border: medium none; color: black; left: -99999px; overflow: hidden; position: absolute; text-align: left; text-decoration: none;">
Android
Wear is an extension of the Android mobile operating system designed to
power wearable gadgets – primarily smartwatches. Although it has just
been announced, it’s no small-scale operation. Many of the biggest
mobile phone brands are working with the software already. <br /><span>Read more at <a href="http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99" style="color: #003399;">http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99</a></span><div id="r1PostCPBlock" style="background-color: white; border: medium none; color: black; left: -99999px; overflow: hidden; position: absolute; text-align: left; text-decoration: none;">
Android
Wear is an extension of the Android mobile operating system designed to
power wearable gadgets – primarily smartwatches. Although it has just
been announced, it’s no small-scale operation. Many of the biggest
mobile phone brands are working with the software already. <br /><span>Read more at <a href="http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99" style="color: #003399;">http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99</a></span></div>
</div>
Android
Wear is an extension of the Android mobile operating system designed to
power wearable gadgets – primarily smartwatches. Although it has just
been announced, it’s no small-scale operation. Many of the biggest
mobile phone brands are working with the software already. <br /><span>Read more at <a href="http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99" style="color: #003399;">http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99</a></span></div>
<div id="r1PostCPBlock" style="background-color: white; border: medium none; color: black; left: -99999px; overflow: hidden; position: absolute; text-align: left; text-decoration: none;">
Android
Wear is an extension of the Android mobile operating system designed to
power wearable gadgets – primarily smartwatches. Although it has just
been announced, it’s no small-scale operation. Many of the biggest
mobile phone brands are working with the software already. <br />
Read more at <a href="http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99" style="color: #003399;">http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99</a></div>
<div id="r1PostCPBlock" style="background-color: white; border: medium none; color: black; left: -99999px; overflow: hidden; position: absolute; text-align: left; text-decoration: none;">
Android
Wear is an extension of the Android mobile operating system designed to
power wearable gadgets – primarily smartwatches. Although it has just
been announced, it’s no small-scale operation. Many of the biggest
mobile phone brands are working with the software already. <br />
Read more at <a href="http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99" style="color: #003399;">http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99</a></div>
<div id="r1PostCPBlock" style="background-color: white; border: medium none; color: black; left: -99999px; overflow: hidden; position: absolute; text-align: left; text-decoration: none;">
Android
Wear is an extension of the Android mobile operating system designed to
power wearable gadgets – primarily smartwatches. Although it has just
been announced, it’s no small-scale operation. Many of the biggest
mobile phone brands are working with the software already. <br />
Read more at <a href="http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99" style="color: #003399;">http://www.trustedreviews.com/opinions/what-is-android-wear-a-guide-to-google-s-smartwatch-os#fpBRiQq4mZZUI0ly.99</a></div>
</div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-30363017851954686542014-03-20T02:26:00.001-07:002014-03-20T02:26:25.702-07:00Is there any way to detect if the clock is round?<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.804800033569336px;">If I understood correctly it'll be using standard Android resources, meaning you can just put your layout in layout-circle and you're done.</span></div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-3333439203246586522014-03-20T02:24:00.002-07:002014-03-20T02:24:43.145-07:00Android Wear Preview app - which smartphones are compatible?<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="background-color: white; border: 0px; clear: both; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
I don't think there is a device specific restriction, but according to <a href="http://developer.android.com/wear/preview/start.html#SetupApp" rel="nofollow" style="background-color: transparent; border: 0px; color: #4a6b82; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;">developer.android.com</a></div>
<pre style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;">Note: The Android Wear Preview app is compatible with Android 4.3 </code></pre>
<pre style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;">and higher and is not available for the Android emulator.
</code></pre>
<div style="background-color: white; border: 0px; clear: both; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.804800033569336px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
Edit: I think BLE is used for communication between smartphone and watch. So obviously that would be hardware restriction.</div>
</div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-65902641623294070302014-03-20T02:18:00.002-07:002014-03-20T02:18:37.787-07:00Tutorial: Android Wear with Genymotion<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 21px; line-height: 29.399999618530273px;">Hi, for people who does not have a phone with Android 4.3 or above, we can not try the Android Wear Preview. :'(</span><br style="background-color: white; box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 21px; line-height: 29.399999618530273px;" /><span style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 21px; line-height: 29.399999618530273px;">And here is a way you can try, use Genymotion Nexus 4 with Android 4.3 and it works!</span><br />
<span style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 21px; line-height: 29.399999618530273px;"><br /></span>
<ol style="background-color: white; box-sizing: border-box; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; margin-bottom: 10px; margin-top: 0px;">
<li style="box-sizing: border-box;">Setup a Nexus 4 with Android 4.3 in <a href="http://www.genymotion.com/" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; box-sizing: border-box; color: #428bca; text-decoration: none;">Genymotion</a>.</li>
<li style="box-sizing: border-box;">Start both the Nexus 4 and <a href="http://developer.android.com/wear/preview/start.html" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; box-sizing: border-box; color: #428bca; text-decoration: none;">Android Wear emulator</a>.</li>
<li style="box-sizing: border-box;">You should first install Google Play Services on the Nexus 4:</li>
<ol style="box-sizing: border-box; margin-bottom: 0px; margin-top: 0px;">
<li style="box-sizing: border-box;">Download the <a href="http://goo.im/gapps/gapps-jb-20130813-signed.zip" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; box-sizing: border-box; color: #428bca; text-decoration: none;">zip</a> file</li>
<li style="box-sizing: border-box;">Drag it into the Nexus 4</li>
<li style="box-sizing: border-box;">Reboot the device, and now you are able to install "Android Wear Preview" on Play Store</li>
</ol>
<li style="box-sizing: border-box;">Open Terminal, use adb tools:<div style="box-sizing: border-box; margin-bottom: 10px;">
<code style="background-color: #f9f2f4; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 2px 4px; white-space: nowrap;">./adb devices</code></div>
</li>
<li style="box-sizing: border-box;"><div style="box-sizing: border-box; margin-bottom: 10px;">
you shoud see 2 devices,</div>
<div style="box-sizing: border-box; margin-bottom: 10px;">
<code style="background-color: #f9f2f4; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; padding: 2px 4px; white-space: nowrap;">./adb -s [device name of Nexus 4] forward tcp:5601 tcp:5601</code></div>
</li>
<li style="box-sizing: border-box;">Done!</li>
</ol>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitSQfy_ST77NJSsLGdIOej7prW2JMXsG5WMEYE0xGsU-r7hxP5n0rN2UH4j36GgqUeX1tp4L_I3lZSVBVOyKMcrrDK0Xfwoiprf8AtD7D9YwJkjLDHnzEt03HdqeOL-PlyqRH7wTQEa_U/s1600/AndroidWear_Genymotiton_400.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitSQfy_ST77NJSsLGdIOej7prW2JMXsG5WMEYE0xGsU-r7hxP5n0rN2UH4j36GgqUeX1tp4L_I3lZSVBVOyKMcrrDK0Xfwoiprf8AtD7D9YwJkjLDHnzEt03HdqeOL-PlyqRH7wTQEa_U/s1600/AndroidWear_Genymotiton_400.png" height="320" width="206" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://developer.android.com/wear/preview/start.html">Read More</a></div>
<div>
<span style="color: #333333; font-family: Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 14px; line-height: 20px;"><br /></span></span></div>
</div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-28767797040537772142014-01-04T02:36:00.003-08:002014-01-04T02:36:34.991-08:00QuickReturn Listview<div dir="ltr" style="text-align: left;" trbidi="on">
<h2>
<a href="https://plus.google.com/u/0/113646442457708412671/posts"></a>
</h2>
This is a implementation of the QuickReturn UI (aka <a href="http://www.androidviews.net/2012/11/scrolling-tricks/">Scrolling Tricks</a> in AndroidViews) developed by <a href="https://plus.google.com/113735310430199015092">Roman Nurik</a> and <a href="https://plus.google.com/118292708268361843293/posts">Nick Butcher</a> for a <a href="http://developer.android.com/reference/android/widget/ListView.html"><code>ListView</code></a>.<br />
Lars recently added a QuickReturn UI for a footer, Just like in the <a href="https://play.google.com/store/apps/details?id=com.google.android.apps.plus&hl=en">Google+ app</a>.<br />
<br />
<br />
<a href="https://github.com/LarsWerkman/QuickReturnListView"><img alt="" class="alignnone size-full wp-image-186" height="50" src="http://www.androidviews.net/wp-content/uploads/2012/10/dl_github.png" title="Download from GitHub" width="230" /></a><br />
<h2>
</h2>
</div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-17364802850850618582014-01-04T02:35:00.004-08:002014-01-04T02:35:48.482-08:00NewPopupMenu<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="padded_text sgl_ttl">
<h2>
</h2>
</div>
Inspired by Google Music’s Android app, this android library will create a nice styled <code><a href="https://developer.android.com/reference/android/widget/PopupMenu.html">PopupMenu</a></code> for you.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiQHwNz6sAGZStKxliUe9OUHFD3ilSpxX6FU1xDycfROnUB9g73s5I7D3aC6tFYPl1qbFHGw3QNSsRGXNG6_gJcEqKE3f0ERw-puxGMm2_DRnbXDFLajIeEd6b5g_G6r94ZKJerBmSKWw/s1600/template.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="144" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiQHwNz6sAGZStKxliUe9OUHFD3ilSpxX6FU1xDycfROnUB9g73s5I7D3aC6tFYPl1qbFHGw3QNSsRGXNG6_gJcEqKE3f0ERw-puxGMm2_DRnbXDFLajIeEd6b5g_G6r94ZKJerBmSKWw/s320/template.png" width="320" /></a></div>
<br />
<br />
<a href="https://github.com/u1aryz/Android-NewPopupMenu"><img alt="" src="http://www.androidviews.net/wp-content/uploads/2012/10/dl_github.png" title="Github" /></a><br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-91086849110852526232014-01-04T02:14:00.002-08:002014-01-04T02:15:31.516-08:00CardsUI<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="padded_text sgl_ttl">
<h2>
</h2>
</div>
Google’s Now popular Cards UI has everyone fascinated.<br />
Now a library I created mimicking that behaviour is available.<br />
The view might still be a little flaky, and the View’s code is not
well documented, but the example really shows you how simple it all is.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-WW3IZBKqZnDor1zKrzL8WTvACS0QCQJHEC1xpVWruY5I08OUGgp4_AdP_WTRkjKMEFsBHm4e_rl5x1pD2x1cMBTOfiz_1t7hb0fhFE5PNa8Y7bvIA_XFthxnsz5q2jLZQ-YsFoZ4GUg/s1600/template.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="145" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-WW3IZBKqZnDor1zKrzL8WTvACS0QCQJHEC1xpVWruY5I08OUGgp4_AdP_WTRkjKMEFsBHm4e_rl5x1pD2x1cMBTOfiz_1t7hb0fhFE5PNa8Y7bvIA_XFthxnsz5q2jLZQ-YsFoZ4GUg/s320/template.png" width="320" /></a></div>
<br />
<div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes" data-settings=" minimize scroll-mouseover" id="crayon-52c7dea551d70" style="clear: both; float: none; font-size: 12px ! important; height: auto; line-height: 15px ! important; margin-bottom: 12px; margin-top: 12px;">
<div class="crayon-main" style="overflow: hidden; position: relative; z-index: 1;">
<table class="crayon-table"><tbody>
<tr class="crayon-row"><td class="crayon-nums " data-settings="show"><br /></td><td class="crayon-code"></td></tr>
</tbody></table>
</div>
</div>
You can download the <a href="https://bitbucket.org/nadavfima/cardsui-for-android/downloads/CardsExample.apk" target="_blank">example APK</a>.<br />
or Clone the lib from Bitbucket or Github<br />
<a href="https://bitbucket.org/nadavfima/cardsui-for-android"><img alt="Clone from Bitbucket" class="alignnone size-full wp-image-185" height="50" src="http://www.androidviews.net/wp-content/uploads/2012/10/dl_bitbucket.png" width="230" /></a><br />
<a href="https://github.com/nadavfima/cardsui-for-android"><img alt="Download from GitHub" class="alignnone size-full wp-image-186" height="50" src="http://www.androidviews.net/wp-content/uploads/2012/10/dl_github.png" width="230" /></a><br />
<h2>
<b>Some Awesome Forks:</b></h2>
<br />
<a href="https://github.com/Androguide/cardsui-for-android">https://github.com/Androguide/cardsui-for-android</a></div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-34056949441111633262014-01-04T02:13:00.000-08:002014-01-04T02:13:04.452-08:00ICS CalendarView [Backport]<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="padded_text sgl_ttl">
<h2>
</h2>
</div>
The Andorid 4.0 <a href="https://developer.android.com/reference/android/widget/CalendarView.html"><code>CalendarView</code></a> backported to Android 2.1<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglAqYljjvOreKT9QlOwshmW1LEm7HjmDkstYihg7Kk14Luc5qB4HFf4FBWZLDqh2-M-3OPHIMuv6r9zEEGf0fV_mppP-kKgkCpgfnFcHzwXLimKfbqqJlfUtZ-mcuPc1axHl2AZWXBBsY/s1600/template.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="143" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglAqYljjvOreKT9QlOwshmW1LEm7HjmDkstYihg7Kk14Luc5qB4HFf4FBWZLDqh2-M-3OPHIMuv6r9zEEGf0fV_mppP-kKgkCpgfnFcHzwXLimKfbqqJlfUtZ-mcuPc1axHl2AZWXBBsY/s320/template.png" width="320" /></a></div>
<br />
<a href="https://github.com/SimonVT/android-calendarview"><img alt="" src="http://www.androidviews.net/wp-content/uploads/2012/10/dl_github.png" title="Github" /></a></div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-52340793067472367722014-01-04T02:11:00.001-08:002014-01-04T02:11:43.871-08:00PagedDragDropGrid<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="padded_text sgl_ttl">
<h2>
</h2>
</div>
By <a href="https://github.com/mrKlar">Nicolas Desjardins</a><br />
An Android <code><a href="https://developer.android.com/reference/android/view/ViewGroup.html">ViewGroup</a></code> that implements a paged grid with drag’n'drop movable items.<br />
Inspired by <a href="https://github.com/blahti">Bill Lahti</a>‘s article <a href="http://blahti.wordpress.com/2011/10/03/drag-drop-for-android-gridview/">Drag-Drop for an Android GridView</a>.<br />
<br />
<br />
<a href="https://github.com/mrKlar/PagedDragDropGrid"><img alt="" src="http://www.androidviews.net/wp-content/uploads/2012/10/dl_github.png" title="Github" /></a></div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-50135591016053000292014-01-04T02:09:00.003-08:002014-01-04T02:09:29.884-08:00Holo ColorPicker<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="padded_text sgl_ttl">
<h2>
</h2>
</div>
By <a href="https://github.com/LarsWerkman">Lars Werkman</a><br />
A beautiful Android Holo themed color picker designed by <a href="https://plus.google.com/115374955104579332297">Marie Schweiz</a> and <a href="https://plus.google.com/118292708268361843293/posts">Nick Butcher</a> and developed by <a href="https://github.com/LarsWerkman">Lars Werkman</a>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyHowXi8lBggjtFKtQ84GQjBCvZe4FiBfme0U0kkjvMXz6QD7QfFsWBJvs2_TGo4B_UfpnF9a6UkoIPujLy7AYx-5gq6HMHrFIEn3m-LM-DtOwC7yBROUaIqUkCsWZu7PEmf_efoRq3Oc/s1600/template.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="145" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyHowXi8lBggjtFKtQ84GQjBCvZe4FiBfme0U0kkjvMXz6QD7QfFsWBJvs2_TGo4B_UfpnF9a6UkoIPujLy7AYx-5gq6HMHrFIEn3m-LM-DtOwC7yBROUaIqUkCsWZu7PEmf_efoRq3Oc/s320/template.png" width="320" /></a></div>
<br />
<a href="https://github.com/LarsWerkman/HoloColorPicker"><img alt="Download from GitHub" class="alignnone size-full wp-image-186" height="50" src="http://www.androidviews.net/wp-content/uploads/2012/10/dl_github.png" width="230" /></a></div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-62601508502189821592014-01-04T02:08:00.002-08:002014-01-04T02:08:36.899-08:00StaggeredGridView<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="padded_text sgl_ttl">
<h2>
</h2>
</div>
This is a modified version of Android’s experimental <code>StaggeredGridView</code>.
The StaggeredGridView allows the user to create a GridView with uneven
rows similar to how Pinterest looks. Includes own OnItemClickListener
and OnItemLongClickListener, selector, and fixed position restore.<br />
To use StaggeredGridView in your projects, simply add this project to
your workspace then add it as a library project to your current
project.<br />
By <a href="https://plus.google.com/113531944997955252758/posts">Maurycy Wojtowicz</a><br />
Demo link: <a href="https://github.com/maurycyw/StaggeredGridViewDemo">https://github.com/maurycyw/StaggeredGridViewDemo</a><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsk_jjwEnqyKsHpb1xZ_LJVy6mrDrrDgMuXdHeOeSpkpK9sDxUvCPLErPJe-QFM37ikapcbn7H86C95hwWa5puFReNRb3M-0l9WaZ1cMvUb__1u-hraXH551niSyWXFsh1R5upQcI5lfg/s1600/template.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="143" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsk_jjwEnqyKsHpb1xZ_LJVy6mrDrrDgMuXdHeOeSpkpK9sDxUvCPLErPJe-QFM37ikapcbn7H86C95hwWa5puFReNRb3M-0l9WaZ1cMvUb__1u-hraXH551niSyWXFsh1R5upQcI5lfg/s320/template.png" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<a href="https://github.com/maurycyw/StaggeredGridView"><img alt="Download from GitHub" class="alignnone size-full wp-image-186" height="50" src="http://www.androidviews.net/wp-content/uploads/2012/10/dl_github.png" width="230" /></a></div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0tag:blogger.com,1999:blog-2514376929712218536.post-39087891747814939922014-01-04T02:07:00.002-08:002014-01-04T02:07:21.690-08:00Parallax ScrollView<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="padded_text sgl_ttl">
<h2>
</h2>
</div>
A Parallax ScrollView which takes a background and foreground view, in the ParallexScrollView.<br />
By <a href="https://plus.google.com/100798804818525823038/posts">Christopher Jenkins</a>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxDhIy-ep6p42bRjzZdtYjX1qg02LjgWVNKQDzqzY_S5E_uaTWqeOlBpaoug6krdW9LvzQSas-OXN98SYXKVC5iGhebp3ty28OE4Wn1y-V80YsL_fdMcMHuEkFzhbfS6h34RzmW3gB9fc/s1600/template.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="145" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxDhIy-ep6p42bRjzZdtYjX1qg02LjgWVNKQDzqzY_S5E_uaTWqeOlBpaoug6krdW9LvzQSas-OXN98SYXKVC5iGhebp3ty28OE4Wn1y-V80YsL_fdMcMHuEkFzhbfS6h34RzmW3gB9fc/s320/template.png" width="320" /></a></div>
<br />
<a href="https://github.com/chrisjenx/ParallaxScrollView"><img alt="Download from GitHub" class="alignnone size-full wp-image-186" height="50" src="http://www.androidviews.net/wp-content/uploads/2012/10/dl_github.png" width="230" /></a></div>
Anonymoushttp://www.blogger.com/profile/06865802798741827490noreply@blogger.com0