Friday, November 2, 2012

Mount Google Galaxy Nexus on Ubuntu 12.04(Precise)

1. Open Terminal
2. Run command "sudo apt-get install mtp-tools mtpfs gmtp"
3. Connect device to computer via USB
4. Select USB option to Media Device(MTP)
5. Enjoy, device mounted successfully.

Thursday, September 13, 2012

Facebook "Like" Button for iOS , Android and Blackberry



Before using this below code, please add facebook library to your project and use token of facebook Api to like facebook page.

public String likeFacebookButton( String urlWantToLike ) {

String url = null;

if(facebook.isSessionValid())
{
url = "http://www.facebook.com/plugins/like.php?" +
"href=" + URLEncoder.encode( urlWantToLike ) + "&" +
"send=false&"+
"layout=button_count&" +
"show_faces=false&" +
"width=100&" +
"height=21&"+
"action=like&" +
"font=arial&"+
"colorscheme=light&" +
"access_token=" + URLEncoder.encode( facebook.getAccessToken() );

}
return url;
}

Eclipse: "Run As","Debug As","Profile As" doesn't display the elements of list

Above problem have just wasted my whole day so i gone through all eclipse docs and community forums and finally i got the solution.

The solution to above problem is to execute this command in terminal

"sudo apt-get --reinstall install tzdata-java"

Wednesday, July 25, 2012

Use of variables in strings.xml in Android

e.g X company have Y employees
where X is a string variable and Y is an integer variable.

We can use this type of case in R.string also , as discussed below:

Write in strings.xml file
<string name="abc">%1$s company have %2$d employees.</string>
where $s stands for string
$d for integers

In java file
String mystring = getResources().getString(R.string.abc);
String finalstring = mystring.format(mystring, "Google",10000);

OUTPUT:
Google company have 10000 employees.

Sunday, July 22, 2012

Facebook and Twitter Sharing in Blackberry

With lot of research from last many months, finally i concluded a code for sharing status on facebook and twitter in Blackberry. So, make changes in attached code according to your need.
Please change application secret keys before executing it.


If any doubt and queries can comment below.


Download SharingKit

Tuesday, March 20, 2012

JSON Parsing in Android

try
        {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost postMethod = new HttpPost("Insert JSON Url");
            BufferedReader in = null;
            BasicHttpResponse httpResponse = (BasicHttpResponse) httpclient.execute(postMethod);
            in = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
            StringBuffer sb = new StringBuffer("");
            String line = "";
            while ((line = in.readLine()) != null)
            {
                sb.append(line);
            }
            in.close();
            String result = sb.toString();

            JSONObject resObject=new JSONObject(result);
            String _key =resObject.getString("Insert Json Key");
            Vector _adBeanVector = new Vector();
            JSONArray newsArray = resObject.getJSONArray("Insert Json Array Key");
            if(newsArray.length() > 0)
           {
           for (int i=0;
            i < newsArray.length()
           ; i++)
           {
           Vector _adElementsVector=new Vector();
           JSONObject newsObj = newsArray.getJSONObject(i);
           _adElementsVector.addElement(newsObj.getString("Insert Json Array Element Key1"));
          _adElementsVector.addElement(newsObj.getString("Insert Json Array Element Key2"));
          _adBeanVector.addElement(_adElementsVector);
           }
           }
     }
 catch (Exception e)
{
}

Tuesday, January 24, 2012

JSON parsing in Blackberry

HttpConnection conn = null;
InputStream in = null;
String _response = null;
Vector _adBeanVector=null;
int code;
try
{
StringBuffer url=new StringBuffer().append(" Insert Json Url");
conn = (HttpConnection) Connector.open(url.toString(), Connector.READ);
conn.setRequestMethod(HttpConnection.GET);

code = conn.getResponseCode();
if (code == HttpConnection.HTTP_OK) {
in = conn.openInputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buffer = new byte[in.available()];
int len = 0;
while (-1 != (len = in.read(buffer))) {
out.write(buffer);
}
out.flush();
_response = new String(out.toByteArray());
JSONObject resObject=new JSONObject(_response);
String _key =resObject.getString("Insert Json Key");

_adBeanVector = new Vector();
JSONArray newsArray = resObject.getJSONArray("Insert Json Array Key");
if(newsArray.length() > 0)
{
for (int i=0 ;
i <  news Array.length()
 ; i++)
{
Vector _adElementsVector=new Vector();
JSONObject newsObj = newsArray.getJSONObject(i);
_adElementsVector.addElement(newsObj.getString("Insert Json Array Element Key1"));
_adElementsVector.addElement(newsObj.getString("Insert Json Array Element Key2"));
_adBeanVector.addElement(_adElementsVector);
}
}
if (out != null){
out.close();
}
if (in != null){
in.close();
}
if (conn != null){
conn.close();
}
}

} catch (Exception e)
{
Dialog.alert(e.getMessage());
}