Friday, April 11, 2014

ListView-Swipe To Delete list in android.

Fragment

ANDROID – Upload an image to a server -- Base64

http://www.coderzheaven.com/category/uploaing-a-file/

http://sunil-android.blogspot.in/2013/03/image-upload-on-server.html

FIND PATH OF IMAGE FROM THE MOBILE DEVICE 

http://www.androidsnippets.com/get-file-path-of-gallery-image 

http://stackoverflow.com/questions/19834842/android-gallery-on-kitkat-returns-different-uri-for-intent-action-get-content 

BEST Example to get image path

http://viralpatel.net/blogs/pick-image-from-galary-android-app/

/**
 * Get a file path from a Uri. This will get the the path for Storage Access
 * Framework Documents, as well as the _data field for the MediaStore and
 * other file-based ContentProviders.
 *
 * @param context The context.
 * @param uri The Uri to query.
 * @author paulburke
 */
public static String getPath(final Context context, final Uri uri) {

    final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;

    // DocumentProvider
    if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
        // ExternalStorageProvider
        if (isExternalStorageDocument(uri)) {
            final String docId = DocumentsContract.getDocumentId(uri);
            final String[] split = docId.split(":");
            final String type = split[0];

            if ("primary".equalsIgnoreCase(type)) {
                return Environment.getExternalStorageDirectory() + "/" + split[1];
            }

            // TODO handle non-primary volumes
        }
        // DownloadsProvider
        else if (isDownloadsDocument(uri)) {

            final String id = DocumentsContract.getDocumentId(uri);
            final Uri contentUri = ContentUris.withAppendedId(
                    Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));

            return getDataColumn(context, contentUri, null, null);
        }
        // MediaProvider
        else if (isMediaDocument(uri)) {
            final String docId = DocumentsContract.getDocumentId(uri);
            final String[] split = docId.split(":");
            final String type = split[0];

            Uri contentUri = null;
            if ("image".equals(type)) {
                contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
            } else if ("video".equals(type)) {
                contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
            } else if ("audio".equals(type)) {
                contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
            }

            final String selection = "_id=?";
            final String[] selectionArgs = new String[] {
                    split[1]
            };

            return getDataColumn(context, contentUri, selection, selectionArgs);
        }
    }
    // MediaStore (and general)
    else if ("content".equalsIgnoreCase(uri.getScheme())) {
        return getDataColumn(context, uri, null, null);
    }
    // File
    else if ("file".equalsIgnoreCase(uri.getScheme())) {
        return uri.getPath();
    }

    return null;
}

/**
 * Get the value of the data column for this Uri. This is useful for
 * MediaStore Uris, and other file-based ContentProviders.
 *
 * @param context The context.
 * @param uri The Uri to query.
 * @param selection (Optional) Filter used in the query.
 * @param selectionArgs (Optional) Selection arguments used in the query.
 * @return The value of the _data column, which is typically a file path.
 */
public static String getDataColumn(Context context, Uri uri, String selection,
        String[] selectionArgs) {

    Cursor cursor = null;
    final String column = "_data";
    final String[] projection = {
            column
    };

    try {
        cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
                null);
        if (cursor != null && cursor.moveToFirst()) {
            final int column_index = cursor.getColumnIndexOrThrow(column);
            return cursor.getString(column_index);
        }
    } finally {
        if (cursor != null)
            cursor.close();
    }
    return null;
}


/**
 * @param uri The Uri to check.
 * @return Whether the Uri authority is ExternalStorageProvider.
 */
public static boolean isExternalStorageDocument(Uri uri) {
    return "com.android.externalstorage.documents".equals(uri.getAuthority());
}

/**
 * @param uri The Uri to check.
 * @return Whether the Uri authority is DownloadsProvider.
 */
public static boolean isDownloadsDocument(Uri uri) {
    return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}

/**
 * @param uri The Uri to check.
 * @return Whether the Uri authority is MediaProvider.
 */
public static boolean isMediaDocument(Uri uri) {
    return "com.android.providers.media.documents".equals(uri.getAuthority());
}
 

Sqlite tutorial with customlistview

http://tausiq.wordpress.com/2012/08/22/android-list-view-from-database-with-cursor-adapter/

http://tausiq.wordpress.com/2012/08/22/android-list-view-from-database-with-cursor-adapter/

Thursday, April 3, 2014

Imortant Link

 

Custom ListView with Image and Text Using BaseAdapter  

http://www.tutorialsbuzz.com/2014/03/watsapp-custom-listview-imageview-textview-baseadapter.html

Android Button State Change Example 

http://www.tutorialsbuzz.com/2014/04/android-button-state-change-example.html

 

OnActivityResult Demo



Android Fundamentals: IntentService Basics
IntentService (android.app.IntentService) is a simple type of service that can be used to handle asynchronous work off the main thread by way of Intent requests. Each intent is added to the IntentService’s queue and handled sequentially.



Custom checkbox and rediobutton


http://icetea09.com/blog/2014/03/18/android-android-action-bar/




http://www.grokkingandroid.com/adding-actionbarsherlock-to-your-project/

creating-frame-animations-in-android
http://javatechig.com/android/creating-frame-animations-in-android


http://brainflush.wordpress.com/2009/03/15/understanding-android-themes-and-styles/





Paypal Intigratioin


https://github.com/paypal/PayPal-Android-SDK

android-reverse-geocoding-yahoo-api.html



http://www.londatiga.net/it/how-to-send-image-to-twitpic-from-android/


/**
       * Take screenshot of the activity including the action bar
       *
       * @param activity
       * @return The screenshot of the activity including the action bar
       */
     
public static Bitmap takeScreenshot(Activity activity)
      {
            ViewGroup decor = (ViewGroup)activity.getWindow().getDecorView();
            ViewGroup decorChild = (ViewGroup)decor.getChildAt(0);
            decorChild.setDrawingCacheEnabled(true);
            decorChild.buildDrawingCache();
            Bitmap drawingCache = decorChild.getDrawingCache(true);
            Bitmap bitmap = Bitmap.createBitmap(drawingCache);
            decorChild.setDrawingCacheEnabled(false);
            return bitmap;
      }

/**
       * Print hash key
       */

      public static void printHashKey(Context context)
      {
            try
            {
                  String TAG = "com.sromku.simple.fb.example";
PackageInfo info = ontext.getPackageManager().getPackageInfo(TAG,
                        PackageManager.GET_SIGNATURES);
                  for (Signature signature: info.signatures)
                  {
                        MessageDigest md = MessageDigest.getInstance("SHA");
                        md.update(signature.toByteArray());
                        String keyHash = Base64.encodeToString(md.digest(),Base64.DEFAULT);
                        Log.d(TAG, "keyHash: " + keyHash);
                  }
            }
            catch (NameNotFoundException e)
            {

            }
            catch (NoSuchAlgorithmException e)
            {

            }
      }

Android Sliding Menu using Navigation Drawer


http://manishkpr.webheavens.com/android-navigation-drawer-example-using-fragments/

Working Code with Fragment

tutorial-activity-slide-animation

Monday, March 31, 2014

Create Json string Format to POST Json data to the Service-- With Array

 http://www.javacodegeeks.com/2013/10/android-json-tutorial-create-and-parse-json-data.html


public class JsonUtil {

public static String toJSon(Person person) {
      try {
        // Here we convert Java Object to JSON 
        JSONObject jsonObj = new JSONObject();
        jsonObj.put("name", person.getName()); // Set the first name/pair 
        jsonObj.put("surname", person.getSurname());

        JSONObject jsonAdd = new JSONObject(); // we need another object to store the address
        jsonAdd.put("address", person.getAddress().getAddress());
        jsonAdd.put("city", person.getAddress().getCity());
        jsonAdd.put("state", person.getAddress().getState());

        // We add the object to the main object
        jsonObj.put("address", jsonAdd);

        // and finally we add the phone number
        // In this case we need a json array to hold the java list
        JSONArray jsonArr = new JSONArray();

        for (PhoneNumber pn : person.getPhoneList() ) {
            JSONObject pnObj = new JSONObject();
            pnObj.put("num", pn.getNumber());
            pnObj.put("type", pn.getType());
            jsonArr.put(pnObj);
        }

        jsonObj.put("phoneNumber", jsonArr);

        return jsonObj.toString();

    }
    catch(JSONException ex) {
        ex.printStackTrace();
    }

    return null;

}
 
 
{
   "phoneNumber": [
      {
         "type": "work",
         "num": "11111"
      },
      {
         "type": "home",
         "num": "2222"
      }
   ],
   "address": {
      "state": "World",
      "address": "infinite space, 000",
      "city": "Android city"
   },
   "surname": "Swa",
   "name": "Android"
}
========================================================
 
 

Create Json string Format to POST Json data to the Service


Task:Register
{
    "Device":
    {
        "DeviceId":"test-iSWzc6l8hEtvxSaaYEPVWlajSgClaPG/ug1xV5dftfQ=",
        "Operator":"Operator",
        "DeviceName":"XDeviceEmulator",
        "DeviceTotalMemory":1023,
        "ScreenWidth":480.0,
        "ScreenHeight":800.0,
        "OperatingSystem":"Android"
    },
    "Receiver":
    {
        "CountryCode":91,"Mobile":"9725910991"
    }
}
JSONObject json1 = new JSONObject();
JSONObject jsonDevice = new JSONObject();
    jsonObj.put("DeviceId", value);
    jsonObj.put("Operator", value);
    jsonObj.put("DeviceName", value);
    jsonObj.put("DeviceTotalMemory", value);
    jsonObj.put("ScreenWidth", value);
    jsonObj.put("ScreenHeight", value);
    jsonObj.put("OperatingSystem", value);
json1.put("Device", jsonDevice);
JSONObject jsonReceiver = new JSONObject();
    jsonObj.put("CountryCode", value);
    jsonObj.put("Mobile", value);
json1.put("Receiver", jsonReceiver);

Strint s1="Task:Register"+json1.toString()+"<EOF>";
Toast.makeText(getBaseContext(), "Json Strint => "+ s1 ,Toast.LENGTH_SHORT).show();

Tuesday, March 25, 2014

Android | Send “POST” JSON Data to Server


Wednesday, February 12, 2014

Animation tuotial

https://code.google.com/p/apidemos/source/browse/#svn%2Ftrunk%2FApiDemos%2Fres%2Fanim

playing .swf on application startup into Android



import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.webkit.WebView;
import android.webkit.WebSettings.PluginState;

public class Splash_Screen extends Activity {

     private static int SPLASH_TIME_OUT = 3000;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.startup);

        String localUrl ="file:///android_asset/Kiss-o-meter.swf";

        WebView wv=(WebView) findViewById(R.id.webview);
        wv.getSettings().setPluginState(PluginState.ON);
        wv.loadUrl(localUrl); 

        new Handler().postDelayed(new Runnable() {

            /*
             * Showing splash screen with a timer. This will be useful when you
             * want to show case your app logo / company
             */

            @Override
            public void run() {
                // This method will be executed once the timer is over
                // Start your app main activity      
                Intent yes_krao = new Intent(Splash_Screen.this, KissingMeter.class);
                startActivity(yes_krao);
                finish();
            }
        }, SPLASH_TIME_OUT);
    }   
}