Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Wednesday, May 22, 2013

Android - Creating a Navigation Drawer

Following Link explains in detail how a drawer navigation can be added to an android application using the new guidelines & pattern explained in Google I/O 2013.

http://gmariotti.blogspot.com/2013/05/creating-navigation-drawer.html

PS;
For Devices having OS Honeycomb or greater.

Monday, January 7, 2013

Android - Get Device's Unique Identifier(UID)

String deviceId = Secure.getString(this.getContentResolver(),
                Secure.ANDROID_ID);
returns the Android ID as an unique 64-bit hex string.

Saturday, December 15, 2012

Android - Place Tab at the bottom


Here's the simplest, most robust, and scalable solution to get tabs on the bottom of the screen.
  1. In your vertical LinearLayout, put the FrameLayout above the TabWidget
  2. Set layout_height to wrap_content on both FrameLayout and TabWidget
  3. Set FrameLayout's android:layout_weight="1"
  4. Set TabWidget's android:layout_weight="0" (0 is default, but for emphasis, readability, etc)
  5. Set TabWidget's android:layout_marginBottom="-4dp" (to remove the bottom divider)

Sunday, August 19, 2012

Android - Sending GPS Location to Emulator



Assuming you've got a mapview set up and running:
MapView mapView = (MapView) findViewById(R.id.mapview);
final MyLocationOverlay myLocation = new MyLocationOverlay(this, mapView);

mapView.getOverlays().add(myLocation);
myLocation.enableMyLocation();

myLocation.runOnFirstFix(new Runnable() {
    public void run() {
        GeoPoint pt = myLocation.getMyLocation();
    }
});
You'll need the following permission in your manifest:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
And to send mock coordinates to the emulator from Eclipse, Go to the "Window" menu, select "Show View" > "Other" > "Emulator control", and you can send coordinates from the emulator control pane that appears.

Thursday, August 9, 2012

Android - Placing Image Above Text in Button


Place the following in your layout XML file, replacing [image] with your image:
1
2
3
4
5
6
<Button
     android:id="@+id/groups_button_bg"
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:text="Groups"
     android:drawableTop="@drawable/[image]" />
Using android:drawableTop="@drawable/...", we’re able to place an image abovethe button text. The following options are available for placing the image in different positions relative to the button text:
1
2
3
4
android:drawableLeft
android:drawableRight
android:drawableBottom
android:drawableTop
In addition, android:drawablePadding can be used to specify the amount of padding between the image and button text.

Sunday, May 13, 2012

Android - Send Email From Your App


/* Create the Intent */
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
/* Fill it with Data */
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"to@email.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Text");
/* Send it off to the Activity-Chooser */
context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));

Emails only works if you are using the application in a real phone, so if you are using the emulator, try it on a real phone.