Tuesday, 27 August 2013

Hidden Tricks On Your Android Device:Speed Dial,Offline map,Capture Your Screen,Auto response texts,Quick Pic Review,Stolen mobile


The New Speed Dial(more useful):




Android lets you create icons for your most-dialed contacts and place them on your home screen for easy access. To do this, press and hold an empty space on your home screen until a menu pops up. Go to Shortcuts > Contact, and scroll through your contacts until you find the person you want to add.


To create an offline map





To create an offline map, enter Google Maps for Android and display your desired map on the screen. You will find a button that says "Make this map area available offline" to simplify the process. The estimated size of the area in your map will appear on the screen. If it is too large, you will be asked to choose a smaller area. You can store up to six maps on your device.


Capture Your Screen:




If you want to take the screen shot of something interesting that you came across while browsing, or of confirmation of the bill you paid online, just hold power button and lower volume key at same time. The screenshot should automatically be stored to your gallery.


Quick Pic Review:



Checking the photo you just clicked is made easy on Android. When you click a pic, just tap the lower right-hand corner of your camera app to view your most-recent photograph, then swipe left and right to view pictures. For faster review, pinch inward to view pictures lined up in order, similar to a film strip. Swipe up to delete any unwanted photos.


Auto response texts:



If you are busy and could not be able to receive a call and you also don’t want to cut the call as it might be taken for being rude, you can simply set a default message that can help you in such tricky situation. With Android 4.0 (Ice Cream Sandwich) or any newer version, you can decline a phone call while sending the caller a custom text message.


To customize auto-response texts, go to Phone > Settings > Quick Responses. Tap one of the pre-written responses to change it. When your phone rings, slide the circle upward to the message icon and let go.

Expand Your Vocabulary


There are occasions where you need to type the full word since it did not turn up in auto complete of suggestions. It often happens when you are trying to type the complex words or a word from some vernacular language.  All you need to do is, long-press on text field, and the word automatically gets added to the dictionary.



In case of stolen mobile:




Google is coming up with its own version of iOS’ “find my mobile” app. And then there are number of apps like TrustGo that can help you find your mobile if lost. But before that, you can place a setting on your device that displays your name, email, telephone number or other information from the locked screen itself. So if the finder of your mobile turns out to be a good Samaritan, the person can be able to get your details from the locked screen itself. From Settings, go to Security > Screen security > Owner info. You can enter your name, email address, phone number or other information to appear on the lock screen.

Saturday, 24 August 2013

ONE App Developer Responsible for 47,000+ Apps in BlackBerry World?

A developer firm known as S4BB has single handedly created over 47,000 apps for the BlackBerry World app market. That amounts to almost one-third of BlackBerry World's total app count. The app store race is not even close, but this revelation illustrates another stumbling block in BlackBerry's attempt at platform and app store relevancy - the huge discrepancy between quantity and quality of apps in BlackBerry World.


Some of you may have noticed that a few developers have been exploiting the free submission of apps to BlackBerry World and using it as a promotional tool. Pointed out to me that the worst offender by far is S4BB.he first 20-30 actually seem like good to decent quality legitimate apps and then it rapidly goes downhill. 



Either way having 47,000 apps definitely skews any BlackBerry World statistics. I am sure other App Stores have tons of spam and fart apps but I was not aware that BlackBerry World was similarly afflicted by a single developer. This just goes to show that BlackBerry should be focusing on the quality apps instead of the quantity of apps.
What do you think? How should BlackBerry handle this sort of BlackBerry World app flooding? Are they doing the right thing by letting them in and letting users decide if they should buy or ignore them?
PS: Is anyone else curious how long it took BlackBerry World’s crack squad of reviewers to review these 47,000 apps from one vendor? Could that be why it takes so long for an app to be approved?
 

Friday, 23 August 2013

Develop app once in html and run in Apple,Andriod,Windows,Blackberry,bada,Symbian,webOS

Phonegap:PhoneGap is a free and open source framework that allows you to create mobile apps using standardized web APIs
  
It supports Apple,Andriod,Windows,Backberry,Symbains,bada,webOS.
Step 1: Download Phonegap plugins 
Click on install.

Step 2: Develop a HTML page
Here we have taken a sample Application which shows the details of Mobile. 

 index.html:

<!DOCTYPE html>
<html>
  <head>
    <title>Device Properties Example</title>

    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
    <script type="text/javascript" charset="utf-8">

    // Wait for Cordova to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);

    // Cordova is ready
    //
   function onDeviceReady() {
     var element = document.getElementById('deviceProperties');

     element.innerHTML = 'Device Name: '     + device.name     + '<br />' + 
                         'Device Cordova: '  + device.cordova + '<br />' + 
                         'Device Platform: ' + device.platform + '<br />' + 
                         'Device UUID: '     + device.uuid     + '<br />' + 
                         'Device Version: '  + device.version  + '<br />';
   }

    </script>
  </head>
  <body style="background-color:#99ccff;text-align:center;font-weight:bold;">
  <label>**----PhoneGapp Sample-----** </label>
    <p id="deviceProperties" ><br/>
 <br/>Loading device properties...</p>
  </body>
</html>
 Step3:Place index.html and cordova.js in folder make it zip.
https://build.phonegap.com/apps 
 click on update code browse the rar fileclick on upload

Step4:If u want to c app in andriod mobile click on apk save file.
Connect the mobile to system place the apk file in mobile ur app is ready. 








Encrypt and decrypt a password in Java using Advanced Encryption Standard (AES).

One of the best and secured way to Encrypt and Decrypt Advanced Encryption Standard (AES).

 The standard comprises three block ciphers, AES-128, AES-192 and AES-256, Each of these ciphers has a 128-bit block size, with key sizes of 128, 192 and 256 bits, respectively. The AES ciphers have been analyzed extensively and are now used worldwide.

AES algorithm can use a key of 128 bits (16 bytes * 8); so we selected that key.

Simple Data Encryption/Decryption Example with AES:

package com.pswd;
import java.security.Key;
import java.security.spec.InvalidKeySpecException;

import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

import sun.misc.*;

/**
 * This class is used for encrypt and decrypt the  password field.
 *
 */
public class PswdEnc {

    private static final String ALGO = "AES";
    private static final byte[] keyValue =  
    new byte[]
  {'T','h','e','B','e','s','t','S','e','c','r','e','t','K','e','y' };

    /*--Used to encrypt the string and returns 24 bit
 and based on string length--*/
    public static String encrypt(String Data) throws Exception {
        Key key = generateKey();
        Cipher c = Cipher.getInstance(ALGO);
        c.init(Cipher.ENCRYPT_MODE, key);
        byte[] encVal = c.doFinal(Data.getBytes());
        String encryptedValue = new BASE64Encoder().encode(encVal);
        return encryptedValue;
    }
    /*--Used to decrypt the encrypted string and returns 
actual plain string--*/
    public static String decrypt(String encryptedData) throws Exception {
        Key key = generateKey(); 
        Cipher c = Cipher.getInstance(ALGO);
        c.init(Cipher.DECRYPT_MODE, key);
        byte[] decordedValue =  
           new BASE64Decoder().decodeBuffer(encryptedData);
        byte[] decValue = c.doFinal(decordedValue);
        String decryptedValue = new String(decValue);
        return decryptedValue;
    }
       public static void main(String[] args) throws Exception {
  
    String enc= encrypt("Alekhya");
    System.out.println("Encrption: "+enc);
 }
    
    private static Key generateKey() throws Exception {
        Key key = new SecretKeySpec(keyValue, ALGO);
        return key;
    }
     
}

OUTPUT:

Encrption: TKpzxJDDXob7UKWlkYG4Vw==

 

Thursday, 22 August 2013

Sample Application of Spring ,Hibernate,MySql with CRUD operations

In this sample we have used Hibernate annotations and POM to configure.

SPRING: Spring is the most popular application development framework for enterprise Java™. Millions of developers use Spring to create high performing, easily testable, reusable code without any lock-in.

Structure of the project will be:












MainController.java: 
package org.alekhya.tutorial.controller;
import java.util.List;
import javax.annotation.Resource;
import org.alekhya.tutorial.domain.Person;
import org.alekhya.tutorial.service.PersonService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;


/**
 * Handles and retrieves person request
 */
@Controller
@RequestMapping("/main")
public class MainController {

 protected static Logger logger = Logger.getLogger("controller");
 
 @Resource(name="personService")
 private PersonService personService;
 
 /**
  * Handles and retrieves all persons and show it in a JSP page
  * 
  * @return the name of the JSP page
  */
    @RequestMapping(value = "/persons", method = RequestMethod.GET)
    public String getPersons(Model model) {
     
     logger.debug("Received request to show all persons");
     
     // Retrieve all persons by delegating the call to PersonService
     List<Person> persons = personService.getAll();
     
     // Attach persons to the Model
     model.addAttribute("persons", persons);
     
     // This will resolve to /WEB-INF/jsp/personspage.jsp
     return "personspage";
 }
    
    /**
     * Retrieves the add page
     * 
     * @return the name of the JSP page
     */
    @RequestMapping(value = "/persons/add", method = RequestMethod.GET)
    public String getAdd(Model model) {
     logger.debug("Received request to show add page");
    
     // Create new Person and add to model
     // This is the formBackingOBject
     model.addAttribute("personAttribute", new Person());

     // This will resolve to /WEB-INF/jsp/addpage.jsp
     return "addpage";
 }
 
    /**
     * Adds a new person by delegating the processing to PersonService.
     * Displays a confirmation JSP page
     * 
     * @return  the name of the JSP page
     */
    @RequestMapping(value = "/persons/add", method = RequestMethod.POST)
    public String add(@ModelAttribute("personAttribute") Person person) {
  logger.debug("Received request to add new person");
  
     // The "personAttribute" model has been passed
 to the controller from the JSP
     // We use the name "personAttribute" because the JSP uses that name
  
  // Call PersonService to do the actual adding
  personService.add(person);

     // This will resolve to /WEB-INF/jsp/addedpage.jsp
  return "addedpage";
 }
    
    /**
     * Deletes an existing person by delegating the
 processing to PersonService.
     * Displays a confirmation JSP page
     * 
     * @return  the name of the JSP page
     */
    @RequestMapping(value = "/persons/delete", method = RequestMethod.GET)
    public String delete(@RequestParam(value="id", required=true) Integer id, 
              Model model) {
   
  logger.debug("Received request to delete existing person");
  
  // Call PersonService to do the actual deleting
  personService.delete(id);
  
  // Add id reference to Model
  model.addAttribute("id", id);
     
     // This will resolve to /WEB-INF/jsp/deletedpage.jsp
  return "deletedpage";
 }
    
    /**
     * Retrieves the edit page
     * 
     * @return the name of the JSP page
     */
    @RequestMapping(value = "/persons/edit", method = RequestMethod.GET)
    public String getEdit(@RequestParam(value="id", required=true) Integer id,  
              Model model) {
     logger.debug("Received request to show edit page");
    
     // Retrieve existing Person and add to model
     // This is the formBackingOBject
     model.addAttribute("personAttribute", personService.get(id));
     
     // This will resolve to /WEB-INF/jsp/editpage.jsp
     return "editpage";
    }
    
    /**
     * Edits an existing person by delegating 
       the processing to PersonService.
     * Displays a confirmation JSP page
     * 
     * @return  the name of the JSP page
     */
    @RequestMapping(value = "/persons/edit", method = RequestMethod.POST)
   public String saveEdit(@ModelAttribute("personAttribute") Person person, 
                 @RequestParam(value="id", required=true) Integer id, 
                Model model) {
     logger.debug("Received request to update person");
    
     // The "personAttribute" model has been passed to
        the controller from the JSP
     // We use the name "personAttribute" because the JSP uses that name
     
     // We manually assign the id because we disabled it in the JSP page
     // When a field is disabled it will not be 
     included in the ModelAttribute
     person.setId(id);
     
     // Delegate to PersonService for editing
     personService.edit(person);
     
     // Add id reference to Model
  model.addAttribute("id", id);
  
     // This will resolve to /WEB-INF/jsp/editedpage.jsp
  return "editedpage";
 }
    
}
 Person.java:
package org.alekhya.tutorial.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "PERSON")
public class Person implements Serializable {

 private static final long serialVersionUID = -5527566248002296042L;
 
 @Id
 @Column(name = "ID")
 @GeneratedValue
 private Integer id;
 
 @Column(name = "FIRST_NAME")
 private String firstName;
 
 @Column(name = "LAST_NAME")
 private String lastName;
 
 @Column(name = "MONEY")
 private Double money;

 public Integer getId() {
  return id;
 }

 public void setId(Integer id) {
  this.id = id;
 }

 public String getFirstName() {
  return firstName;
 }

 public void setFirstName(String firstName) {
  this.firstName = firstName;
 }

 public String getLastName() {
  return lastName;
 }

 public void setLastName(String lastName) {
  this.lastName = lastName;
 }

 public Double getMoney() {
  return money;
 }

 public void setMoney(Double money) {
  this.money = money;
 }
}
PersonService.java
package org.alekhya.tutorial.service; import java.util.List; import javax.annotation.Resource; import org.alekhya.tutorial.domain.Person; import org.apache.log4j.Logger; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; /**  * Service for processing Persons  *  */ @Service("personService") @Transactional public class PersonService { protected static Logger logger = Logger.getLogger("service"); @Resource(name="sessionFactory") private SessionFactory sessionFactory; /** * Retrieves all persons * * @return a list of persons */ public List<Person> getAll() { logger.debug("Retrieving all persons"); // Retrieve session from Hibernate Session session = sessionFactory.getCurrentSession(); // Create a Hibernate query (HQL) Query query = session.createQuery("FROM Person"); // Retrieve all return query.list(); } /** * Retrieves a single person */ public Person get( Integer id ) { // Retrieve session from Hibernate Session session = sessionFactory.getCurrentSession(); // Retrieve existing person first Person person = (Person) session.get(Person.class, id); return person; } /** * Adds a new person */ public void add(Person person) { logger.debug("Adding new person"); // Retrieve session from Hibernate Session session = sessionFactory.getCurrentSession(); // Save session.save(person); } /** * Deletes an existing person * @param id the id of the existing person */ public void delete(Integer id) { logger.debug("Deleting existing person"); // Retrieve session from Hibernate Session session = sessionFactory.getCurrentSession(); // Retrieve existing person first Person person = (Person) session.get(Person.class, id); // Delete session.delete(person); } /** * Edits an existing person */ public void edit(Person person) { logger.debug("Editing existing person"); // Retrieve session from Hibernate Session session = sessionFactory.getCurrentSession(); // Retrieve existing person via id Person existingPerson = 
  (Person) session.get(Person.class, person.getId());
  
  // Assign updated values to this person
  existingPerson.setFirstName(person.getFirstName());
  existingPerson.setLastName(person.getLastName());
  existingPerson.setMoney(person.getMoney());

  // Save updates
  session.save(existingPerson);
 }
}
applicationContext.xml 
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <!-- Activates various annotations to be detected in bean classes --> <context:annotation-config /> <context:component-scan base-package="org.alekhya.tutorial" /> <mvc:annotation-driven /> <!-- Load Hibernate related configuration --> <import resource="hibernate-context.xml" /> </beans>
hibernate-context.xml 
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd "> <context:property-placeholder location="/WEB-INF/spring.properties" /> <!-- Enable annotation style of managing transactions --> <tx:annotation-driven transaction-manager="transactionManager" /> <bean id="sessionFactory" class=
  "org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
   p:dataSource-ref="dataSource"
   p:configLocation="${hibernate.config}"
   p:packagesToScan="org.alekhya.tutorial"/>
 
 <!-- Declare a datasource that has pooling capabilities-->  
 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
    destroy-method="close"
    p:driverClass="${app.jdbc.driverClassName}"
    p:jdbcUrl="${app.jdbc.url}"
    p:user="${app.jdbc.username}"
    p:password="${app.jdbc.password}"
    p:acquireIncrement="5"
    p:idleConnectionTestPeriod="60"
    p:maxPoolSize="100"
    p:maxStatements="50"
    p:minPoolSize="10" />

 <!-- Declare a transaction manager-->
 <bean id="transactionManager" class= 
    "org.springframework.orm.hibernate3.HibernateTransactionManager" 
          p:sessionFactory-ref="sessionFactory" />
  
</beans> 
 hibernate.cfg.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
  
<hibernate-configuration>
<session-factory>
 <!-- We're using MySQL database so the dialect needs to MySQL as well-->
 <property name="hibernate.dialect">
  org.hibernate.dialect.MySQL5InnoDBDialect
 </property>
 <!-- Enable this to see the SQL statements in the logs-->
 <property name="show_sql">false</property>
 <!-- This will drop our existing database and re-create a new one.
  Existing data will be deleted! -->
 <property name="hbm2ddl.auto">create</property>
 <property name="hbm2ddl.auto">update</property>
</session-factory>
</hibernate-configuration>
spring-servlet.xml: 
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <!-- Declare a view resolver --> <bean id="viewResolver" class="
org.springframework.web.servlet.view.InternalResourceViewResolver" 
      p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />

</beans>  
spring.properties:
# database properties app.jdbc.driverClassName=com.mysql.jdbc.Driver app.jdbc.url=jdbc:mysql://localhost/SpringPerson app.jdbc.username=root app.jdbc.password=root #hibernate properties hibernate.config=/WEB-INF/hibernate.cfg.xml
web.xml:
<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4" xmlns="
http://java.sun.com/xml/ns/j2ee" xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
 <servlet>
  <servlet-name>spring</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>
 
 <servlet-mapping>
  <servlet-name>spring</servlet-name>
  <url-pattern>/alekhya/*</url-pattern>
 </servlet-mapping>

 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
 </listener>
 
</web-app>

OUTPUT:
 

Monday, 19 August 2013

▶ Motivational video Change your mind in just 2 50 mins Make ur mind peace,fills courage and desire to achieve.

Sample Spring Example with Maven(POM)

Example uses Maven to generate a simple Java project structure, and demonstrates how to retrieve Spring bean and prints a “hello ! ” string.

Goto Eclipse IDE  File->New->Others->MavenProject


Click on next



 Group Id and Artifact Id must be project name

Project Structure: Make sure the folder structure as follows:


 pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>Sample-Maven</groupId>
  <artifactId>Sample-Maven</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  <dependencies>
 
  <!-- Spring framework -->
  <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring</artifactId>
   <version>2.5.6</version>
  </dependency>
 
 </dependencies>
 
</project> 
 
HelloWorld.java
package com.alekhya.common; public class HelloWorld { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public void printHello() { System.out.println("Hello ! " + name); } }
 
Spring-Module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
 
 <bean id="helloBean" class="com.alekhya.common.HelloWorld">
  <property name="name" value="Alekhya" />
 </bean>
 
</beans>
 App.java:
package com.alekhya.common; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class App { public static void main(String[] args) { ApplicationContext context=new ClassPathXmlApplicationContext("Spring-Module.xml"); HelloWorld obj=(HelloWorld)context.getBean("helloBean"); obj.printHello(); } }
 
Run it:Output
 
Hello ! Alekhya