Sunday, 4 December 2011

Android Saved Instance State Bundle

Hi,
Normally when the device is tilted(i.e. screen orientation is changed) the activity is restarted.Whole activity is destroyed and recreated.So when activity is destroyed ,we need to save the state of activity.This can be done using the onSaveInstanceState and onRestoreInstanceState.


public class SavedInstanceActivity extends Activity {
TextView main_text;
Button update_button;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        main_text=(TextView)findViewById(R.id.main_text);
        update_button=(Button)findViewById(R.id.press_saved);
        update_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
main_text.setText("SAVED INSTANCE STATE");
}
});
    }
    
    @Override
    protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putString("SAVED", main_text.getText().toString());
    }
    
    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    main_text.setText(savedInstanceState.getString("SAVED"));
    }
}

Like as you see in the above example if we had not used the onSavedInstanceState() then whole activty would have been recreated and textview would have been blank again.

Click to download the full source code: SOURCE CODE

Thursday, 24 November 2011

Steve Wozniak(Apple Co-Founder) with his Galaxy Nexus and a ice cream sandwich T-shirt to go with it.

Heck of a Strange thing happened in Google's campus in Mount View when Steve Wozniak the co founder of apple became the first person in US to get the Samsung Galaxy Nexus.

This all happened when "Woz" tweeted that he was looking for the Samsung galaxy nexus ,but unfortunately it was not available in US.So "Woz" was invited by the Google's campus in mount view  where he was presented the Brand new Samsung galaxy Nexus and a ice cream sandwich T-shirt.

gsmarena 001 Steve Wozniak gets a Galaxy Nexus from Google, and an Ice Cream Sandwich T Shirt to go with it




;-)....

SOURCE

Wednesday, 2 November 2011

Android Views Animation Tutorial




In this section i will try to explain the 4 types of animation on views which can overall change the impression of the views.

The attached program demonstrates the available types of animations which are:
Alpha - Causes a fading in or fading out effect.
Scale - The view's size smoothly changes.
Rotate - The view rotates.
Translate - The view moves to a different position.


You can individually use these animations or you can also combine these animations into one. Combining of animations is done with help of animation set.First i will explain how to use these animations individually.

ALPHA ANIMATION: Alpha animation is used in fading in and fading out of views. 

<alpha 
android:fromAlpha="0.0" 
android:toAlpha="0.9"
android:duration="3000" />

SCALE ANIMATION: Scale animation is used for changing the size of view.


<scale 
android:fromXScale="1.0" 
android:fromYScale="1.0"
android:toXScale="2.0" 
android:toYScale="2.0" 
android:duration="3000" />

ROTATE ANIMATION: Rotate animation is used for rotating a view around a particular axis.


<rotate 
android:fromDegrees="359" 
android:toDegrees="0"
android:duration="3000" 
android:pivotX="50%" 
android:pivotY="50%" />

TRANSLATE ANIMATION: Translate animation is used to change the position of a particular view.

<translate 
android:fromXDelta="300%" 
android:toXDelta="0%" 
android:fromYDelta="0%"
android:toYDelta="0%" 
android:duration="3000" 
android:zAdjustment="bottom" />

You need to keep these XML files in anim folder in res folder.
And finally to use this application in your Activity you need to use the following piece of code:




final Animation anim=AnimationUtils.loadAnimation(getApplicationContext(), R.anim.animation);// where animation is the name of the anim file which contains any of the above mentioned animation.




Download free source code here.

Tuesday, 1 November 2011

(Nokia choosing WP7 over Android)

                 As my title says i am going to talk about the thing which is in every one's mind i.e. why Nokia chose WP7 over Android although knowing the success of Android in the mobile market.So i m going to compare some of the features of Android and WP7.

                 During the Q&A during Nokia's Capital Market Day, Elop said that Android did not allow them to differentiate enough. This seems weird, since Android is considerably more open and free than Windows Phone 7. However, I think what he meant is that Nokia would not have a say in the actual development direction of Android. And this is where Microsoft comes in.

Nokia knew that it was too late to join the Android party—Android had become a crowded space. Creating a standout Android phone would not only be difficult given the experience of other companies but because it could get lost in the maul of Android phones available. Even Android phone makers would admit that it's hard to stay at the top of the Android power rankings—hell, doesn't it seem like the "best Android phone" only has a lifespan of a month before it gets dethroned? Nokia saw Google eventually getting all the profits as hardware gets commoditized.

And maybe Windows Phone 7 will have those same hardware "issues" as Android but Nokia felt it could differentiate its handsets by dropping in Nokia specific features like their Navteq location-based services. That, they felt, would give them a leg up.

But none of those arguments seem to matter as much as this one: Nokia didn't want to lose the smartphone wars without giving Google and Apple an honest fight. Choosing Android would mean that they'd become a bit player in a two-horse race (Apple vs Google). Choosing Windows Phone means they're hoping and fighting to add another horse. It might be too late and maybe Nokia had to sell their soul, who knows, but I respect any one who goes down swinging.

Monday, 31 October 2011

Lego robot beats human world record for solving the Rubik’s Cube with Android





cubestormer

Solving the Rubik’s Cube puzzle popularized in the 1980s is an exercise in futility for many of us, but to a world class “speedcuber” it’s a challenge of mere moments. The currentofficial human record for the Rubik’s cube 3×3 puzzle is just 5.66 seconds. I know a robot that did it in 5.35 seconds. Take, that humanity! (Wait a second…) The puzzle solving bot is called CubeStomer II and you can watch its record breaking run in the video below. Made from Lego, powered by an Android smart phone, and created by two mad geniuses, CubeStormer II has a pedigree that sounds like it came from a children’s cartoon. That’s fitting, because I think the Lego NXT robot is a sure sign that humanity has gone meta. Why waste time on solving trivial puzzles when you can build a robot to waste time solving trivial puzzles for you instead?
CubeStormer II is controlled by four Lego NXT ‘bricks’ that communicate via Bluetooth with a Samsung Galaxy SII smart phone. A special app on the phone takes a picture of the cube, solves the puzzle virtually, and then relays the solution to the Lego robot. From click to finish the whole process takes just seconds. You have to see it to believe it:

New Rejoice for Mob.Application Developer.

Hi friends yet another IDE is out for mobile application developers(I-Phone, Blackberry,Android)
Adobe Flash Builder 4.5
Now it seems as if  the java developers have some competition.
Language used to write the application  markup language that Flash Builder uses to design application interfaces.
When you create a Flex mobile project, Flash Builder generates the following files for the project (where ProjectName is the name you give your project in the first step of the wizard):
  • ProjectName.mxml: This is the application file for the project. Typically, you do not add content to the default application file directly.
  • ProjectNameHomeView.mxml: This file represents the initial screen (or view) of the project. Flash Builder places the file in a package called "views."
Now lets see if it brings the boom for the Flex developers...or bane for the Android java developers.

For complete and full documentation for Adobe flash builder check out this link.
http://www.adobe.com/devnet/flash-builder/articles/hello-world.html



Thursday, 20 October 2011

Apple's Siri vs. Android's Voice Actions: Feature Showdown




Look out, Google: Siri could take Apple into search
Apple's new voice input-based digital assistant, Siri for the iPhone 4S pits the iPhone against Android's Voice Actions, a popular feature for Android phones running Android 2.2 (Froyo) or higher. Both Siri and Voice Actions promise to make your life easier by letting you speak--rather than type--your messages, web searches, notes, and navigation.
In November, Google also plans to update Android's voice input engine with Android 4.0, or Ice Cream Sandwich on the new Samsung Galaxy Nexus. ICS will include a new hands free voice-activation feature, as well as an overhauled voice input engine.
Read More: http://www.pcworld.com/article/242198/apples_siri_vs_androids_voice_actions_feature_showdown.html#tk.hp_fv

Tuesday, 18 October 2011

Innovation in Android 4.0


Innovation

Android is continously driving innovation forward, pushing the boundaries of communication and sharing with new capabilities and interactions.
Android Beam for NFC-based sharing
Android Beam is an innovative, convenient feature for sharing across two NFC-enabled devices, It lets people instantly exchange favorite apps, contacts, music, videos — almost anything. It’s incredibly simple and convenient to use — there’s no menu to open, application to launch, or pairing needed. Just touch one Android-powered phone to another, then tap to send.
For sharing apps, Android Beam pushes a link to the app's details page in Android Market. On the other device, the Market app launches and loads the details page, for easy downloading of the app. Individual apps can build on Android Beam to add other types of interactions, such as passing game scores, initiating a multiplayer game or chat, and more.
Face recognition lets you unlock your phone with your face.
Face Unlock
Android 4.0 introduces a completely new approach to securing a device, making it even more personal — Face Unlock is a new screen-lock option that lets users unlock their devices with their faces. It takes advantage of state-of-the-art facial recognition technology to register a face and to recognize it later when unlocking the device. Users just hold their devices in front of their faces to unlock, or use a backup PIN or pattern.
Wi-Fi Direct and Bluetooth HDP
Support for Wi-Fi Direct lets users connect directly to nearby peer devices over Wi-Fi, for more reliable, higher-speed communication. No internet connection or tethering is needed. Through third-party apps, users can connect to compatible devices to take advantage of new features such as instant sharing of files, photos, or other media; streaming video or audio from another device; or connecting to compatible printers or other devices.
Android 4.0 also introduces built-in support for connecting to Bluetooth Health Device Profile (HDP) devices. With support from third-party apps, users can connect to wireless medical devices and sensors in hospitals, fitness centers, homes, and elsewhere. In addition, for connecting to higher quality Bluetooth audio devices, Android 4.0 adds support for Bluetooth Hands Free Profile (HFP) 1.6.

ReadMore: http://developer.android.com/sdk/android-4.0-highlights.html

Samsung's Galaxy Nexus gets official: Android 4.0, 4.65-inch HD Super AMOLED display (video)

Wait no more. Google and Samsung have just made the long-awaited Galaxy Nexus (not longer the Nexus Prime, as we'd once heard) official here in Hong Kong, and the specifications are downright drool-worthy. Those with bantam hands need not apply, as this 4.65-inch behemoth is bound to bring back talk of Sidetalkin'. Naturally, Ice Cream Sandwich is onboard, with Google finally revealing the version number as 4.0. Other specs include an HD Super AMOLED display (1,280 x 720), a 1.2GHz dual-core processor, 5 megapixel rear camera (with LED flash), a 1.3 megapixel front-facing cam, 1080p video recording and playback, a newfangled panorama mode, a 3.5mm headphone jack and Bluetooth 3.0. You'll also find USB 2.0, 802.11a/b/g/n WiFi, an embedded NFC module, accelerometer, compass, gyro, proximity sensor and even a barometer -- yeah, a barometer. Finishing things out, there's 1GB of RAM, 16 or 32GB of internal storage space and a 1,750mAh battery. As for radios? There's an HSPA+ model on tap, while an LTE version will "be available depending on region." There's nary a mention of carrier in the press release we're holding, but based on earlier leaks, a 4G build for Verizon Wireless seems a lock.



Read More:http://www.engadget.com/2011/10/18/samsungs-galaxy-nexus-gets-official-android-4-0-4-65-inch-hd/

RIM announces BBX - the new platform for phones and tablets

Quite expectedly RIM has just announced its new platform called BBX. BBX combines "the best of BlackBerry and the best of QNX", as RIM puts it. The new BBX-OS based on this BBX platform will be for both smartphones and tablets, and will offer support for apps developed for the previous BlackBerry OS 6 and OS 7, but also Adobe Air and Flash apps, HTML 5 or even for Android apps thanks to the BlackBerry Runtime for Android software module.
For more Information check the link below:


Source: http://www.gsmarena.com/rim_announces_bbx__the_new_blackberry_os_for_phones_and_tablets-news-3281.php

Sunday, 16 October 2011

Tech World Mourns Loss of Dennis Ritchie, Father of C and Unix


Dennis Ritchie, the computer scientist responsible for C and Unix, has passed away at age 70. His career leaves behind an operating system and programming language that form the basis of some of the world's most widely used technologies. "You've got all these operating systems, languages and programs all building on Dennis' work," Pike concluded. "It's hard to think of a bigger legacy."

Source: http://www.technewsworld.com/story/Tech-World-Mourns-Loss-of-Dennis-Ritchie-Father-of-C-and-Unix-73496.html

Monday, 10 October 2011

funniest deprecation in the Java API

Hi,
All the Java guys might be aware the term Depricated in java or android programming.
From the definition of deprecated:
A program element annotated @Deprecated is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists.
The funniest deprecation in the Java API, is imo, the FontMetrics.getMaxDecent.
Reason for deprecation: Spelling error.
Deprecated. As of JDK version 1.1.1, replaced by getMaxDescent().


Selecting ImageFrom Gallery

Hi ,
  In this post i am going to tell you about on how to pick a image from gallery and use that image in your application.

Step1:
Intent photo_pick=new Intent(Intent.ACTION_PICK);
                photo_pick.setType("image/*");
                photo_pick.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(Intent.createChooser(photo_pick,
                        "Select Picture"), 1);


Step2:
As you have used the startActivityForResult so now you should check for the result using the onActivtyResult method as follows:

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode==1){
            /*** To get the path and image ***/           
            if(resultCode == RESULT_OK){ 
                Uri selectedImage = data.getData();
                String[] filePathColumn = {MediaStore.Images.Media.DATA};
                Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
                cursor.moveToFirst();
                int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                String filePath = cursor.getString(columnIndex);
                Log.e("","filepath"+filePath);// file path of selected image
                cursor.close();
                Bitmap yourSelectedImage = BitmapFactory.decodeFile(filePath);
                _show_image.setImageBitmap(yourSelectedImage); //set your bitmap in your imageView
            }

}


Source Code: https://sites.google.com/site/quickandroidblog/download-stuff

Thursday, 15 September 2011

Animation in Android

In this Post i will tell you about the simple blinking animation using apha property of android.
First create a class as follows by extending the Animation class:

BlinkAnimation,java

public class BlinkAnimation extends Animation {
    private int totalBlinks;
    private boolean finishOff;
   
    public BlinkAnimation(int totalBlinks, boolean finishOff) {
        this.totalBlinks = totalBlinks;
        this.finishOff = finishOff;
    }

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        float period = interpolatedTime * totalBlinks * 3.14f + (finishOff ? 3.14f / 2 : 0);
        t.setAlpha(Math.abs(FloatMath.cos(period)));
    }

    @Override
    public boolean willChangeBounds() {
        return false;
    }

    @Override
    public boolean willChangeTransformationMatrix() {
        return false;
    }
}


Next step is to create a avtivity to instaniate the animation as follows:

TestActivity.java


public class TestActivity extends Activity implements OnClickListener, AnimationListener {
    private ImageView image;
   
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        image = (ImageView) findViewById(R.id.image);
        ((Button) findViewById(R.id.button)).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.button) {
            Animation animation;
            if (image.getVisibility() == View.VISIBLE) {
                animation = new BlinkAnimation(3, true);
                animation.setInterpolator(new DecelerateInterpolator());
            } else {
                animation = new BlinkAnimation(3, false);
                animation.setInterpolator(new AccelerateInterpolator());
            }
            animation.setDuration(1000L);
            animation.setAnimationListener(this);
           
            image.startAnimation(animation);
        }
    }

    @Override
    public void onAnimationEnd(Animation animation) {
        image.setVisibility(image.getVisibility() == View.VISIBLE ?
                View.INVISIBLE : View.VISIBLE);
    }

    @Override
    public void onAnimationRepeat(Animation animation) {}

    @Override
    public void onAnimationStart(Animation animation) {}
}



and your XML file would look like this a follows:

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <ImageView
    android:id="@+id/image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="30dip"
    android:src="@drawable/icon" />
  <Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="30dip"
    android:text="Please click me" />
</LinearLayout>

Monday, 12 September 2011

Netflix Now Works on Android 2.2 and 2.3 Devices

Netflix customers who want to watch the latest shows on the go using their smartphones have gotten some good news, but not everyone will be able to share in the party.


Source: http://www.pcworld.com/article/239830/netflix_now_works_on_android_22_and_23_devices.html

Saturday, 10 September 2011

Android Ice cream sandwich

Android users waiting for the Ice Cream Sandwich version of the mobile operating system will see the latest flavor pop up sometime in October or November.
Google's own executive chairman, Eric Schmidt, tipped off the time frame for the new version of Android in an interview yesterday with Salesforce CEO Marc Benioff.

Thursday, 8 September 2011

XMPP or Jabber for Chatting in Android

This Tutorial will tell you how to create a XMPP Client  for Android.
You can connect to any Server  like Gmail or Facebook or create your own Server using Open Fire.

  • For Information regarding how to setup Jabber Messaging Server and Use Miranda IM Client refer to:
             http://www.wowtutorial.org/tutorial/52.html


  • And download Miranda IM Client 
  • Next thing is to Connect to this Server Using your own Android Application: 
          You need to use the Smack Api for this purpose, which can be downloaded from the follwing link:
OR
 
After You have downlaoded the Smack Library Now you need to add it in your project's Refrenced Libraries. 
 
       1.Connection With The Server:
 
private XMPPClient xmppClient;
    private XMPPConnection connection;
    private ArrayList<String> messages = new ArrayList(); 
    public void login(String userName, String password) throws XMPPException
    {
    ConnectionConfiguration config = new ConnectionConfiguration("HOST",PORT, "SERVICE");
    connection = new XMPPConnection(config);
    connection.connect();
 
    //LOGIN USING THE FOLLWING login() 
 
    connection.login(userName, password);
    xmppClient.setConnection(connection); 
    }
 
  2.Send Message to a Person:
 
   Message msg = new Message("Recepiont", Message.Type.chat);
 msg.setBody(text);
 connection.sendPacket(msg); 

  3.For incoming messages from other users:
 
  public void setConnection
 (XMPPConnection connection) {
 this.connection = connection;
 if (connection != null) {
   // Add a packet listener to get messages sent to us
  PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
  connection.addPacketListener(new PacketListener() {
   public void processPacket(Packet packet) {
    Message message = (Message) packet;
     if (message.getBody() != null) {
    String fromName = StringUtils.parseBareAddress(message.getFrom());
    Log.i("XMPPClient", "Got text [" + message.getBody() + "] from [" + fromName + "]");
    messages.add(fromName + ":");
    messages.add(message.getBody());
    // Add the incoming message to the list view
    mHandler.post(new Runnable() {
    public void run() {
    setListAdapter();
     }
    });
     }
    }
   }, filter);
  }
 }
 
  4.To Sign Out or Disconnect from the Server: 

 public void signOut()
 {
  connection.disconnect();
 }
 
 
 
  There are a lot of other things which you can do using smack API.
  You can find the detailed documentation of each class in the following link:
http://www.igniterealtime.org/builds/smack/docs/latest/documentation/index.html






SOURCE: http://davanum.wordpress.com/2007/12/31/android-just-use-smack-api-for-xmpp/