Pages

Friday, 16 May 2014

Android button with nice design

FButton is a custom Button of Android with "Flat UI" concept. It's customizable and it looks how flat design should look nowadays.

library available on github : https://github.com/hoang8f/android-flat-button

Android Social Networks : Facebook, Twitter, LinkedIn, Google


Android Social Networks is a library which makes working with social networks easier. It contains a common interface for Twitter, LinkedIn, Facebook and Google Plus, just build SocialNetworkManager and configure your AndroidManiferst and your users can login, post messages or photos and manage friends.

Git hub : https://github.com/antonkrasov/AndroidSocialNetworks

Wednesday, 9 April 2014

android.database.sqlite.SQLiteDatabase.rawQuery() is not updating a column

Following is it's solution

public void set_datetime_next(Reminder r, String _newVal) {     
    String[] args = { new Integer(r.getID()).toString() };
    String query =
        "UPDATE " + DBConst.TABLE
      + " SET "   + DBConst.f_DATETIME_NEXT + "=" + _newVal
      + " WHERE " + DBConst.f_ID +"=?";
    Log.i(TAG, query);
    Cursor cu = db.rawQuery(query, args);
    cu.moveToFirst();
    cu.close();
}

While that makes sense, what really puzzles me is the requirement of calling moveToFirst() (or some other function which would "work with" the cursor in some way).
Without the call to both moveToFirst() and close(), the row was never updated. close() by itself, after the rawQuery(), did nothing

Wednesday, 2 April 2014

Android google map v2 using mapView

Following url have nice sample for this
https://gist.github.com/joshdholtz/4522551#file-some_layout-xml

--------------------------------------
Example

public class SomeFragment extends Fragment {
 
 MapView mapView;
 GoogleMap map;
 
 @Override
 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  View v = inflater.inflate(R.layout.some_layout, container, false);
 
   // Gets the MapView from the XML layout and creates it
  mapView = (MapView) v.findViewById(R.id.mapview);
  mapView.onCreate(savedInstanceState);
 
  // Gets to GoogleMap from the MapView and does initialization stuff
  map = mapView.getMap();
  map.getUiSettings().setMyLocationButtonEnabled(false);
  map.setMyLocationEnabled(true);
 
  // Needs to call MapsInitializer before doing any CameraUpdateFactory calls
  try {
   MapsInitializer.initialize(this.getActivity());
  } catch (GooglePlayServicesNotAvailableException e) {
   e.printStackTrace();
  }
  
  // Updates the location and zoom of the MapView
  CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(43.1, -87.9), 10);
  map.animateCamera(cameraUpdate);
 
  return v;
 }
 
 @Override
 public void onResume() {
  mapView.onResume();
  super.onResume();
 }
 
 @Override
 public void onDestroy() {
  super.onDestroy();
  mapView.onDestroy();
 }
 
 @Override
 public void onLowMemory() {
  super.onLowMemory();
  mapView.onLowMemory();
 }
 
}

Following is manifest file

 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
  
  
  
   
    
    
   
  
 
 
 


Layout file

    
    
 

Wednesday, 8 January 2014

android convert string to md5 properly

I found some converter have problem with "0". if string have "00" at start then in result some "0" are missing. Following function working well to convert string to md5
public String MD5(String md5) {
   try {
        java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
        byte[] array = md.digest(md5.getBytes());
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < array.length; ++i) {
          sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));
       }
        return sb.toString();
    } catch (java.security.NoSuchAlgorithmException e) {
    }
    return null;
}