Saturday 29 June 2013

Share image and text to the facebook android

           Share image and text to the facebook in android.PLease follow the below source code



               String fbMsg="hi facebook";
               byte[] image=getImageData();//Get the byte array of image data
Bundle b=new Bundle();

b.putByteArray("picture", image);
b.putString("message", fbMsg);

String facebookMessage = getIntent().getStringExtra("facebookPrayer");
if (facebookMessage == null)
               {
//Post text and image through bundle parameter "b"
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request("me/photos", b, "POST", new SampleUploadListener(), null);


}

         public static byte[] getImageData()
{

Bitmap                       bitmap=BitmapFactory.decodeResource(ctx.getResources(),R.drawable.ic_launcher);
ByteArrayOutputStream bao=new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bao);
byte[] bitMapData = bao.toByteArray();
return bitMapData;
}

SampleUploadListener.class

public class SampleUploadListener implements AsyncFacebookRunner.RequestListener {

@Override
public void onComplete(String response, Object state) {
// TODO Auto-generated method stub

}

@Override
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub

}

@Override
public void onFileNotFoundException(FileNotFoundException e, Object state) {
// TODO Auto-generated method stub

}

@Override
public void onMalformedURLException(MalformedURLException e, Object state) {
// TODO Auto-generated method stub

}

@Override
public void onFacebookError(FacebookError e, Object state) {
// TODO Auto-generated method stub

}

}

Friday 28 June 2013

Convert the text into word document

 Convert the text into word document and that document send to Mail in Android:


 File myFile;
Button share=(Button) findViewById(R.id.butshare);

                share.setOnClickListener(new OnClickListener() {
                 @Override
public void onClick(View v) {
0.String text =et.getText().toString();
try {
            myFile = new File("/sdcard/FresherResume.doc");
               myFile.createNewFile();
               FileOutputStream fOut = new FileOutputStream(myFile);
               OutputStreamWriter myOutWriter =new OutputStreamWriter(fOut);
               myOutWriter.append(text);
               myOutWriter.close();
               fOut.close();
            
                   Intent email = new Intent(Intent.ACTION_SEND); 
     email.setType("plain/text");
     email.putExtra(Intent.EXTRA_EMAIL, new String[] { "please enter To Address" });
       email.putExtra(Intent.EXTRA_SUBJECT, "Resume");
        email.putExtra(Intent.EXTRA_TEXT, "Please find attachment");
        
     email.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(myFile));
     startActivity(email);
     
           } 
           catch (Exception e) 
           {
               Toast.makeText(TemplateActivity.this, e.getMessage(),Toast.LENGTH_SHORT).show();
           }
             
}
});








Tuesday 25 June 2013

Zooming for Layout in Android

                                       Layout Zooming in Android


Follow this link http://stackoverflow.com/questions/4772565/how-to-make-a-scrollable-layout-and-zoomable-layout-in-an-android-app

1.First Add Android_ZoomViiew.jar(download jar file from this link https://code.google.com/p/android-zoom-view/downloads/list) in libs folder and follow the below source code


import pl.polidea.view.ZoomView;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;

public class Zoom extends Activity {
private ZoomView zoomView;
LinearLayout main_container;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.main);

View v = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE))
.inflate(R.layout.activity_main, null, false);
v.setLayoutParams(new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

zoomView = new ZoomView(this);
zoomView.addView(v);

main_container = (LinearLayout) findViewById(R.id.linearLayout2);
main_container.addView(zoomView);
}

}



Monday 24 June 2013

Upload image into ftp server in Android

                            Example for Upload image into the ftp server in Android

HI all,please find the below  code for image uploading in ftp server and also refer this link http://www.jibble.org/simpleftp/



package com.eminosoft.upload;

import java.io.File;

import org.apache.commons.net.ftp.FTPClient;
import org.jibble.simpleftp.SimpleFTP;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.Toast;

public class MainActivity extends Activity {

FTPClient ftpClient;

public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_main);

UploadVideo async = new UploadVideo();
async.execute();

}

class UploadVideo extends AsyncTask<String, Integer, String> {

@Override
protected String doInBackground(String... params) {
// ftpClient=uploadingFilestoFtp();
try {
SimpleFTP ftp = new SimpleFTP();

ftp.connect("ftp.somewhere.net", 21, "username", "password");

ftp.bin();

// Change to a new working directory on the FTP server.
ftp.cwd("web");

// Upload some files.
ftp.stor(new File("/mnt/sdcard/A.png"));
// ftp.stor(new File("comicbot-latest.png"));

// You can also upload from an InputStream, e.g.
// ftp.stor(new FileInputStream(new File("test.png")),
// "test.png");
// ftp.stor(someSocket.getInputStream(), "blah.dat");

// Quit from the FTP server.
ftp.disconnect();

} catch (Exception e) {
e.printStackTrace();
}

return null;
}

@Override
protected void onPreExecute() {
super.onPreExecute();
// dialog.show();
}

@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
Toast.makeText(MainActivity.this, "sent", Toast.LENGTH_LONG).show();
}
}




}





How can we add the customButton to CustomAnnotationView in iOS?

Hi ,


In iOS5 I am trying to create a custom callout for an annotation that will contain detail like, title, description,driving directions etc. In my app, when user is  selecting an annotation, then  have a choice of get the directions by tap on driving directions button. Now I am trying to create the driving directions button on custom annotation, the button is adding as subview to the custom annotation but when user click on that it's not responding(not calling the button method).
I tried by adding the detail disclosure button instead of custom button ,but it is also not working.
If I use AnnotationView instead of customAnnotationView, detailDisclosure button is working fine.


If any one have the solution for this please help me ..

Friday 21 June 2013

How to rename the file in document directory(Sand box)without losing of data in file?


 NString *newDirectoryName = @"<new folder name>";    
    NSString *oldPath = @"<path to the old folder>";
    NSString *newPath = [[oldPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:newDirectoryName];
    NSError *error = nil;
    [[NSFileManager defaultManager] moveItemAtPath:oldPath toPath:newPath error:&error];
    if (error) {
        NSLog(@"%@",error.localizedDescription);
        // handle error
    }

Wednesday 19 June 2013

xib compatible with both iphone 5 and iphone 4 devices

Hi Team,



 NSString *viewName;
        if ([[UIScreen mainScreen] bounds].size.height == 568)
        {
            viewName = [[NSString alloc] initWithString:@"ViewControllerIphone5"];
            
            //this is iphone 5 xib
        }
        else
        {
            viewName=[[NSString alloc] initWithString:@"ViewController"];
           
            // this is iphone 4 xib
        }

  
enter image description here enter image description here enter image description here

Thanks & Regards,
R.Anusha

Sunday 16 June 2013

How to determine Whether the frame Contains Object or not?


Hi Team,

I have Started a simple puzzle application.

Reference Link: http://www.dailyfreegames.com/flash/puzzle-games/priests-n-devils-game.html
Totally we have  6 members (3 persons, 3 devils);

Initially am selecting one person and one devil,  and moving in to other side i'll drop one devil and come back to the person with previous positions.

This process has been repeated until to reach all the members into Other Side

One issue raises here,

When Am implementing the winning case,

If the person is in boat at some particular position, let us consider CGRectMake(10,10,50,50) in this position object has been added.

now am selecting the another person or devil, the object has been added in to the same positon .


Now I want to restrict here, If the object exists in particular position then other object has been added in to another frame but not the first frame.

In this way am implementing all the cases..

If any one have an idea, please help me out


    raft1 = CGRectMake(65, 40, 26, 50);
    raft2 = CGRectMake(116, 40, 26, 50);



   if (sourceBtn.tag==0)
        {
            if (click == firstClick)
            {
                if(boatIsLeft == YES)
                {
                    tag = king1.tag+1;
                    [king1 setTag:tag];
                    [king1 setFrame:raft1];
                    [boatView addSubview:king1];
                    [boatView bringSubviewToFront:king1];
                }
                else if (boatIsLeft == NO)
                {
                    [king1 setFrame:dest1];
                    [kingDestView addSu

bview:king1];
                }
                NSLog(@"tag value is %d", sender.tag);
                click ++;
            }
            else if (click == secondClick)
            {
                if(boatIsLeft == YES)
                {
                    tag = king1.tag+1;
                    [king1 setTag:tag];
                    [king1 setFrame:raft2];
                    [boatView addSubview:king1];
                    [boatView bringSubviewToFront:king1];
                }
                else if (boatIsLeft == NO)
                {
                    [king1 setFrame:dest1];
                    [kingDestView addSubview:king1];
                }
                click = one;
                NSLog(@"tag value is %d", sender.tag);
            }
        }



Monday 10 June 2013


Set the title of Navigation Bar created in Interface Builder


UINavigationBars manage a stack of UINavigationItems much like a UINavigationController manager a stack of UIViewControllers.  
To set what is visible directly, you should use either pushNavigationItem:animated: or setItems:animated: using the navigationItem of the view controller you want the bar to reflect.

eg:

self.navigationItem.title = @"A custom title";
[self.navigationBar pushNavigationItem:self.navigationItem animated:NO];

The above code that you have a property navigationBar which references the stand-alone navigation bar.

If you don't want to manage it yourself, you can do as mplappert suggested and nest your view controller (witout a stand-alone UINavigationBar) in a UINavigationController and present the navigation controller modally instead of your view controller.

or

self.navigationBar.topItem.title = title;
where navigation bar is your outlet.


Regards
Tejaswini.S

Wednesday 5 June 2013



Hii

For testing the InApp Purchases,

Please refer

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/AddingaStoretoYourApplication/AddingaStoretoYourApplication.html#//apple_ref/doc/uid/TP40008267-CH101-SW1

Testing a Store

During development, you should test your application to ensure that purchases are working correctly. However, you do not want to charge users while testing your application. Apple provides a sandbox environment to allow you to test your application without creating financial transactions.




The Sandbox Environment

When you launch your application from Xcode, Store Kit does not connect to the App Store. Instead, it connects to a special sandbox store environment. The sandbox environment uses the infrastructure of the App Store, but it does not process actual payments. It returns transactions as if payments were processed successfully. The sandbox environment uses special iTunes Connect accounts that are limited to In-App Purchase testing. You cannot use your normal iTunes Connect account to test your store in the sandbox.
To test your application, create one or more special test accounts in iTunes Connect. You should make at least one test account for each region that your application is localized for. Detailed information about creating test accounts can be found in iTunes Connect Developer Guide.

Testing in the Sandbox

Follow these steps to test your application in the sandbox.
  1. Log out from your iTunes account on the test device.
    Before you can test your application, you must first log out of your regular iTunes account. iOS 3.0 includes a Store category in the Settings application. To log out of your iTunes account, exit your application, launch the Settings application and click the Store icon. Sign out from the currently active account.


  2. Launch your application.
    Once you have signed out of your account, exit Settings and launch your application. As you make purchases from your application’s store, Store Kit prompts you to authenticate the transaction. Log in using your test account to approve the payment. No financial transaction takes place, but transactions complete as if a payment was made.


    Thanks & regards
    Tejaswini.S
Hi all,

I have an issue with sqlite database.
I have set up a SQLite DB that currently reads and writes NSStrings perfectly. I also want to store an image in the database and recall it later.
My current process goes like this: UIImagePickerController -> User Chooses Image from Photos -> chosenImage is set to instance of UIImageView -> Now I want to take this image and store it in the DB.
 I've read up a bit on using NSData and encoding the image,Now I am able to insert my Image to  Database.
But while retrieving from database I am writing like this.
NSData *dataForCachedImage = [[NSData alloc] initWithBytes:sqlite3_column_blob(statement, 5) length: sqlite3_column_bytes(statement, 5)];   
if(dataForCachedImage == nil)
{
   NSLog(@"No image found.");
}
else
{
self.image = [UIImage imageWithData:dataForCachedImage];
NSLog( @"SaveBody: Failed from sqlite3_prepare_v2. Error is:  %s", sqlite3_errmsg(database) );

}
[dataForCachedImage release];

Here I am  getting the data in dataForCachedImage,but 

self.image = [UIImage imageWithData:dataForCachedImage];

after this it is showing nil object in image.

Can anyone help me out.

Thanks
Tejaswini.S

Saturday 1 June 2013

how to handle, when two users sending voice messages at a time in bluetooth developed by game-kit framework.