Browse Month: June 2012

How to store the data in to the SD-card and to delete this stored data when the application is uninstalled in Android

For Guidance follow this link
http://developer.android.com/guide/topics/data/data-storage.html

store file in to the sdcard use this code


private File cacheDir;

if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
cacheDir=new File(android.os.Environment.getExternalStorageDirectory(),"/Android/data/YOUR PACKAGE_NAME/files/");
else
cacheDir=context.getCacheDir();
if(!cacheDir.exists())
cacheDir.mkdirs();
}

If you’re using API Level 8 or greater, use getExternalCacheDir() to open a File that represents the external storage directory where you should save cache files. If the user uninstalls your application, these files will be automatically deleted. However, during the life of your application, you should manage these cache files and remove those that aren’t needed in order to preserve file space.

If you’re using API Level 7 or lower, use getExternalStorageDirectory() to open a File that represents the root of the external storage, then write your cache data in the following directory:

/Android/data/package_name/cache/

The package_name is your Java-style package name, such as “com.example.android.app”.

Sort NSMutableArray and Make NSMutableDictionary in iphone

//*******************Code*****************
.h
NSMutableArray *arrayForLetter;

//———————————-
.m
NSMutableArray *myArray = [[NSMutableArray alloc] init];
[myArray addObject:@”Z”];
[myArray addObject:@”y”];
[myArray addObject:@”X”];
[myArray addObject:@”Z”];
[myArray addObject:@”&A”];
[myArray addObject:@”C”];
[myArray addObject:@”#A”];
[myArray addObject:@”DA”];
[myArray addObject:@”^A”];
[myArray addObject:@”!E”];

NSLog(@”My Array : %@”,myArray);

NSArray *sortedArray = [myArray sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
NSLog(@”Sorted Array : %@”,sortedArray);

NSMutableDictionary *arraysByLetter = [NSMutableDictionary dictionary];

for (NSString *value in sortedArray)
{
NSString *firstLetter = [value substringWithRange:NSMakeRange(0, 1)];

NSCharacterSet * set = [[NSCharacterSet characterSetWithCharactersInString:@”abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ”] invertedSet];

if ([firstLetter rangeOfCharacterFromSet:set].location != NSNotFound)
{
arrayForLetter = [arraysByLetter objectForKey:@”#”];
if (arrayForLetter == nil)
{
arrayForLetter = [NSMutableArray array];
[arraysByLetter setObject:arrayForLetter forKey:@”#”];
}
[arrayForLetter addObject:value];
}
else
{
[firstLetter uppercaseString];
arrayForLetter = [arraysByLetter objectForKey:firstLetter];
if (arrayForLetter == nil)
{
arrayForLetter = [NSMutableArray array];
[arraysByLetter setObject:arrayForLetter forKey:firstLetter];
}
[arrayForLetter addObject:value];
}
}

NSArray *array = [[arraysByLetter allKeys] sortedArrayUsingSelector:@selector(compare:)];

NSLog(@”Dictionary of Array : %@”,arraysByLetter);
NSLog(@”Keys of array : %@”,array);

//*************Out Put ********************

2012-06-06 13:15:42.196 DemoAppliction[4215:207] My Array : (
Z,
y,
X,
Z,
“&A”,
C,
“#A”,
DA,
“^A”,
“!E”
)
2012-06-06 13:15:44.250 DemoAppliction[4215:207] Sorted Array : (
“!E”,
“&A”,
“#A”,
“^A”,
C,
DA,
X,
y,
Z,
Z
)
2012-06-06 13:15:45.442 DemoAppliction[4215:207] Dictionary of Array : {
“#” = (
“!E”,
“&A”,
“#A”,
“^A”
);
C = (
C
);
D = (
DA
);
X = (
X
);
Z = (
Z,
Z
);
y = (
y
);
}
2012-06-06 13:15:45.443 DemoAppliction[4215:207] Keys of array : (
“#”,
C,
D,
X,
Z,
y
)

How to Integrate the Paypal in Android Application

Hi,

Everybody know about paypal in real time . and this post may be helpful for you in you want to integrate paypal in your android application for any payment processes.
Paypal REleased an API and Library for MObile Integration.

You can integrate by using PAYPAL Mobile Libaraies.
PayPal Mobile Library =>http://www.mediafire.com/?87sdrw49oo82xn0
PayPal MerchantSetupAdministrationGuide
PayPal sandBOX Document =>http://www.mediafire.com/?el5fqbcc61e8o11

PayPal MOBILE library API document=>https://docs.google.com/file/d/1hLlPVThyBitCi_Lj5HicxXnmxnxmINzRxZp6jKbqtT-ekGB6KnNogbtfFSBE/edit?hl=en_US&authkey=COns1MoE

First to Create the Account to the paypal
By this link https://developer.paypal.com/

Then Add this code in your Project
Add this method
invokeSimplePayment(); in which

PayPalPayment newPayment = new PayPalPayment();
newPayment.setSubtotal(BigDecimal.valueOf(Totalprice));
newPayment.setCurrencyType("USD");
//.setCurrency("USD");
newPayment.setRecipient("my@email.com");
newPayment.setMerchantName("Nutri-ForeFronT");
PayPal pp = PayPal.getInstance();
if(pp==null)
pp = PayPal.initWithAppID(this, "APP-80W284485P519543T", PayPal.ENV_SANDBOX);
Intent paypalIntent = pp.checkout(newPayment,this);
this.startActivityForResult(paypalIntent, 1);

Override the OnActivityResult method and get response


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(resultCode) {

case Activity.RESULT_OK:
Toast.makeText(this,"ok" , 1).show();
}
break;

case Activity.RESULT_CANCELED:
Toast.makeText(this,"Cancel" , 1).show();
break;

case PayPalActivity.RESULT_FAILURE:
Toast.makeText(this,"faluare", 1).show();
}
}

How to resize image programmatically in iPhone

Hello friends, many times we need to resize the UIImage runtime according to the need of application.  Here is the function which changes the size of the image and returns a new resized image

– (UIImage *)reSizeTheImage:(UIImage *)image convertToSize:(CGSize)size {

UIGraphicsBeginImageContext(size);

[image drawInRect:CGRectMake(0, 0, size.width, size.height)];

UIImage *destImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return destImage;

}

 

You need to provide the size in which you want to resize the image.

That’s it. Just 5 lines makes the job easy…Isn’t it?

 

  • 1
  • 2

Need more help?

Hi there, was your problem or query resolved? If not & need more assistance, please do reach out to us at info@nanostuffs.com, we'll be more than delighted to help. Nanostuffs has 7+ years of extensive Salesforce & iOS/Android experience.
Holler Box