Skip to main content

Posts

Showing posts from 2016

Useful Link

ANDROID GEMS: http://www.android-gems.com/category https://github.com/matrixxun/ProductTour https://github.com/jcmore2/AppCrash https://github.com/sahildave/Search-View-Layout http://www.android-gems.com/lib/462 https://github.com/Yalantis/FlipViewPager.Draco https://github.com/sacot41/SCViewPager https://github.com/jianghejie/LinkedViewPager https://github.com/manupsunny/PinLock https://github.com/Trinea/android-open-project/tree/master/English%20Version http://javaant.com/viewpager-with-circle-indicator-in-android/#.Vq8nb9V97IV http://androidopentutorials.com/android-image-slideshow-using-viewpager/ Transition Effect https://github.com/kaichunlin/android-transition https://github.com/toddway/MaterialTransitions https://github.com/lgvalle/Material-Animations https://github.com/DesarrolloAntonio/FragmentTransactionExtended https://github.com/takahirom/PreLollipopTransition http://swarmnyc.com/whiteboard/android-frag...

Getting Latitude & Longitude while launching SplashScreen

public class Splash extends Activity {     private static final int SPLASH_DURATION = 7000;     private static final int PERMISSION_REQUEST_CODE = 1;     private static final int CPERMISSION_REQUEST_CODE = 2;     public static double lng;     public static double lat;     Context context;     SharedPreferences pref;     private boolean mIsBackButtonPressed;     private Handler myhandler;     private LocationManager mLocationManager = null;     private String provider = null;     private Marker mCurrentPosition = null;     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_splash);         context = this;         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, ...

Code Snippet

From any Java class  cal DataBase by using the following code : context = this; dbutil = new DbUtil(context); dbutil.open(); To set Database value into the Spinner through ArrayList: Spinner spnCatname; ArrayList<String> array = dbutil.getcategoryname(); ArrayAdapter<String> spinnerArray = new ArrayAdapter<String>(context,R.layout.spinner_text,                                                                                                                                         array); spnCatname.setAdapter(spinnerArray); How to call database value using Cursor?   // Nested Cursor Cursor cur = dbutil.getPro...

To make a ListView to be scrolled inside of ScrollView

To make a ListView to be scrolled inside of ScrollView: lv . setOnTouchListener ( new ListView . OnTouchListener () { @Override public boolean onTouch ( View v , MotionEvent event ) { int action = event . getAction (); switch ( action ) { case MotionEvent . ACTION_DOWN : // Disallow ScrollView to intercept touch events. v . getParent (). requestDisallowInterceptTouchEvent ( true ); break ; case MotionEvent . ACTION_UP : // Allow ScrollView to intercept touch events. v . getParent (). requestDisallowInterceptTouchEvent ( false ); break ; } // Handle ListView touch events. v . onTouchEvent ( event ); return true ; } }); Refer: http://stackoverflow.com/questions/6210895/listview-inside-scrollview-is-not-scrolling-on-android

Getting Data from Local JSON and set Json Data into a TextView which is to be swipable(View Pager) in Android

Create assets folder and put json.json file. Inside of an Activity: ViewPager myPager = null; int count1 = 0; Timer timer; ArrayList<String> title1; ArrayList<String> title2; JSONArray jsonArray; JSONObject jsonObject; String m; String movie; String category; InputStream inputstream; BufferedReader reader; int pager_position; callingJsonFunction(); getData(); setTime_ToSlide(); private void  callingJsonFunction () {     try {         inputstream = getResources().getAssets().open("json.json");         reader = new BufferedReader(new InputStreamReader(inputstream));         m = reader.toString();         StringBuilder total = new StringBuilder();         String line;         while ((line = reader.readLine()) != null) {             total.append(line);         }     ...

SearchView using CursorAdapter

Here  MYFRAGMENT is nothing but name of  a Fragment @Override public void onCreateOptionsMenu (Menu menu, MenuInflater inflater) {     inflater.inflate(R.menu.popup, menu);     final SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);     final SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();     searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));     searchView.setSubmitButtonEnabled(false);     searchView.setIconifiedByDefault(true);     //       searchView.setOnCloseListener(this);     SearchView. OnQueryTextListener textChangeListener = new SearchView. OnQueryTextListener () {         @Override         public boolean onQueryTextSubmit(String query) {             cartAdapt...

MarshMallow Permissions

Permission for MarshMallow: ReadContacts: private boolean checkPermission_READ_CONTACTS () {      int result = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS);      if (result == PackageManager.PERMISSION_GRANTED)          return true;      else          return false; } private void requestPermission () {    ActivityCompat.requestPermissions((Activity) context, new String[]{ Manifest.permission.READ_PHONE_STATE},  PERMISSION_REQUEST_CODE); } private boolean callCheckPermission () {     int result = ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS);     if (result == PackageManager.PERMISSION_GRANTED)          return true;      else          return false; } private void requestPermission_READ_CO...

How to use Gif Image SplashScreen in Android?

public class Splash extends Activity {     private static final int SPLASH_DURATION = 7000; //7 seconds      Context context;         private boolean mIsBackButtonPressed;         private Handler myhandler;  public void onCreate(Bundle savedInstanceState) {               super.onCreate(savedInstanceState);          setContentView(R.layout.activity_splash);         context = this;          getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,                 WindowManager.LayoutParams.FLAG_FULLSCREEN);          myhandler = new Handler();          myhandler.postDelayed(new Runnable() {              @Override           ...

Images from Gallery / Taking Photo by Programmatically in Android

Getting Image from Gallery & Capture Image: private Bitmap bitmap, b1; private byte[] img; private Uri mImageCaptureUri; productimage.setOnClickListener(new View.OnClickListener() {     @Override     public void onClick(View v) {         onPhotoClick() ;     } }); private void onPhotoClick() {     AlertDialog.Builder builder = new AlertDialog.Builder(context);     builder.setTitle("Select Picker").setItems(R.array.ImageSelection,             new DialogInterface.OnClickListener() {                 public void onClick(DialogInterface dialog, int which) {                     if (which == 0) {                         pickImage();                     } else {       ...

Text Font / Style / Text Spacing

To change TextSize by dynamically: tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); (or) textView.setTextSize(TypedValue.COMPLEX_UNIT_PX,getResources().                                                                                getDimension(R.dimen.textsize)); =================== How to add ttf(Font) file into an app for font? Let we consider the font is a_FuturaOrtoRg Bold.ttf. Step 1: Create an Asset Folder in your project.And paste a_FuturaOrtoRg Bold.ttf into it. Step 2:  Typeface tf = Typeface.createFromAsset(getApplicationContext().getAssets(), "a_FuturaOrtoRg Bold.ttf"); textview1.setTypeface(tf);           // TextView textview1,textview2; textview2.setTypeface(tf); =================== For underlined Text: textv...

Date & Time in Android

Date Picker AlertDialog Box: (XML file) In JAVA: public void alertDatePicker() {     LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);     View view = inflater.inflate(R.layout.date_picker, null, false);       int dialogTheme = R.style. DialogTheme ;     final DatePicker myDatePicker = (DatePicker) view.findViewById(R.id.myDatePicker);     myDatePicker.setMaxDate(System.currentTimeMillis());   //For disabling Future Dates     myDatePicker.setCalendarViewShown(true);     new AlertDialog.Builder(context, dialogTheme).setView(view)             .setPositiveButton("OK", new DialogInterface.OnClickListener() {                 @TargetApi(11)                 public void onClick(DialogInterface dialog, int id) {           ...

Fragment

To enable/disable menu items in Different fragments in same Activity: @Override public void onCreate(@Nullable Bundle savedInstanceState)  {     super.onCreate(savedInstanceState);     setHasOptionsMenu(true);  } @Override public void onPrepareOptionsMenu(Menu menu) {     //Disable the SearchView which is enabled in Product Chart     menu.findItem(R.id.action_search).setVisible(false);   // true to enable } ====================================================

Errors in Android

Error:Timeout waiting to lock buildscript class cache for build file 'F:\MARY SUDHA\Inside Workspace\Playstore-IGC\IG_9_1.8\tourguide\build.gradle' (C:\Users\IG\.gradle\caches\2.2.1\scripts\build_f3lw4lau3wiijmaef0tz0omcy\ProjectScript\buildscript). It is currently in use by another Gradle instance. Owner PID: unknown Our PID: 6052 Owner Operation: unknown Our operation: Initialize cache Lock file: C:\Users\IG\.gradle\caches\2.2.1\scripts\build_f3lw4lau3wiijmaef0tz0omcy\ProjectScript\buildscript\cache.properties.lock Delete cache.properties.lock after closing Android Studio. ==================== It will be updated as soon
Style in Progress bar: private void  progressBarFn() {      new  Thread( new  Runnable() {          public void  run() {              while  (progressStatus <  100 ) {                 handler.post( new  Runnable() {                      public void  run() {                         progressColor1();                         progressBar.setProgress(progressStatus);           ...

Activity Codes

How to make an Activity transparent over another Activity?   <style name="Theme.CustomTranslucent" parent="android:style/Theme.Translucent">         <item name="android:backgroundDimEnabled">true</item>         <item name="android:backgroundDimAmount">0.5</item>         <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>         <item name="android:background">@android:color/transparent</item>  </style>   In my activity 2 layout, I could eihter set android:background="@android:color/transparent" or not set any value at all to make it work. Refer: http://stackoverflow.com/questions/10481277/translucent-activity-filling-the-entire-screen Incase of AppcompatActivity: <style name="Theme.AppCompat.Translucent">     <item name="android:windowNoTitle">true</ite...