CategoryAndroid

Change color of image to transparent

C

CGImageRef rawImageRef = image.CGImage; const double colorMasking[6] = { 0, 0, 0, 0, 0, 0 }; UIGraphicsBeginImageContext(image.size);   CGImageRef maskedImageRef =  CGImageCreateWithMaskingColors(rawImageRef, colorMasking); { CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0.0, image.size.height); CGContextScaleCTM(UIGraphicsGetCurrentContext(), 1.0, -1.0); }  ...

Merge two images by retaining opacity of Image

M

UIGraphicsBeginImageContext(topImage.size);   CGContextRef context = UIGraphicsGetCurrentContext(); CGContextTranslateCTM(context, 0, topImage.size.height); CGContextScaleCTM(context, 1.0, -1.0); CGRect rect = CGRectMake(0, 0, topImage.size.width, topImage.size.height); // draw black background to preserve color of transparent pixels CGContextSetBlendMode(context, kCGBlendModeNormal);...

Write signature on device screen

W

To write signature in app ….use this gesture code.   Write this gesture in xml: <android.gesture.GestureOverlayView android:id=”@+id/signaturePad”           android:layout_width=”match_parent”           android:layout_height=”0dp”           android:layout_weight=”5″           android:background=”#FFFFFF”         ...

How to Login via Facebook,get facebook friendlist and their details, post on friends wall and get newsfeeds details

H

How to Login with Facebook: follow the below steps to add login via facebook: step1: register app on developers.facebook.com step 2: get the app_id , add it to strings file and add following code to manifest file: <meta-data android:name=”com.facebook.sdk.ApplicationId” android:value=”@string/app_id” /> //add meta-data inside appication tag. <activity...

Loading image from url using AQuery

L

Download android-query.jar from below link:   Add following code where you want to load image : public ImageLoader imageLoader; imageLoader = new ImageLoader(this); AQuery androidAQuery=new AQuery(getApplicationContext()); androidAQuery.id(ImageView).image(url, true, true, 100,default_pic);   Note: if you dont want to store image in cache memory set true parameters to false.  ...

How to write data into NFC tags in Android?

H

NFC stands for “Near Field Communication” and, as the name implies, it enables short range communication between compatible devices. This requires at least one transmitting device, and another to receive the signal.  NFC allows you to share small payloads of data between an NFC tag and an Android-powered device, or between two Android-powered devices. I was developing an application in which I...

Share With Intents in Android

S

MainActivity : package com.example.shareintent; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.widget.Button; import android.widget.ImageButton; public class MainActivity extends Activity { @Override protected void...

Capture Active Screen in Android

C

AndroidManifest.xml : <?xml version=”1.0″ encoding=”utf-8″?> <manifest xmlns:android=”; package=”com.example.capturescreen” android:versionCode=”1″ android:versionName=”1.0″ > <uses-sdk android:minSdkVersion=”8″ android:targetSdkVersion=”17″ /> <application...

How to ObjectSerializer in to java to store in shared preference in Android

H

public class ObjectSerializer { // private static final Log log = LogFactory.getLog(ObjectSerializer.class); public static String serialize(Serializable obj) throws IOException { if (obj == null) return ""; try { ByteArrayOutputStream serialObj = new ByteArrayOutputStream(); ObjectOutputStream objStream = new ObjectOutputStream(serialObj); objStream.writeObject(obj); objStream.close(); return...

How to store the object in to database(Java Serializable Object to Byte Array)

H

The best way to do it is to use ApacheUtils: To Serialize: byte[] data = SerializationUtils.serialize(yourObject); deserialize: YourObject yourObject = (YourObject) SerializationUtils.deserialize(byte[] data) SerializationUtils Class: package com.example; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import...

Category