0 comments

Android set difference color for textView

Android textView you can set the text Italic or Bold or set The text Color for everywhere you want.

this is you string.xml
<string name="description">Your description where you want to set the red color <i>here you want to set italic</i> <b> here is your Bold text here</b></string>

your main.xml


    



and this is your java file
package monstercodz.blogspot.com;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.widget.TextView;

public class AndroidSetTextViewDifferenceColorActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        SpannableStringBuilder text  = new SpannableStringBuilder(getResources().getText(R.string.description));
        int start = 32;
        int end = 52;
        TextView display = (TextView)findViewById(R.id.display);
        text.setSpan(new ForegroundColorSpan(Color.RED),start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        display.setText(text);
        //display.setTextColor(Color.BLUE);
        
    }
}

you can download the example project by Click here
2 comments

Android vertical seekbar example

In Android there is no vertical seekbar . so we can use rotate the horizontal seekbar by 90 degrees. so this tutorial will teach you how to use it.



you need to create a class call VerticalSeekBar.java and extends from Seekbar like this.
package monstercodz.blogspot.com;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.SeekBar;

public class VerticalSeekBar extends SeekBar {

    public VerticalSeekBar(Context context) {
        super(context);
    }

    public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public VerticalSeekBar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(h, w, oldh, oldw);
    }

    @Override
    protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(heightMeasureSpec, widthMeasureSpec);
        setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
    }

    protected void onDraw(Canvas c) {
     c.rotate(90);
     c.translate(0, - getWidth());
     
        super.onDraw(c);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (!isEnabled()) {
            return false;
        }

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_MOVE:
            case MotionEvent.ACTION_UP:
             setProgress((int) (getMax() * event.getY() / getHeight()) - 0);
                onSizeChanged(getWidth(), getHeight(), 0, 0);
                break;

            case MotionEvent.ACTION_CANCEL:
                break;
        }
        return true;
    }
}

in your main.xml






and finally your
AndroidVerticalSeekbarExampleActivity.java
package monstercodz.blogspot.com;

import android.app.Activity;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

public class AndroidVerticalSeekbarExampleActivity extends Activity implements OnSeekBarChangeListener {
 private TextView tv;
 private VerticalSeekBar seekbar;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        tv = (TextView)findViewById(R.id.tv_value);
        seekbar = (VerticalSeekBar)findViewById(R.id.seekbar);
        tv.setText(String.valueOf(seekbar.getProgress()) + "/" + String.valueOf(seekbar.getMax()));
        seekbar.setMax(100);
        seekbar.setOnSeekBarChangeListener(this);
    }
 @Override
 public void onProgressChanged(SeekBar seekBar, int progress,
   boolean fromUser) {
  // TODO Auto-generated method stub
  tv.setText(String.valueOf(seekbar.getProgress()) + "/" + String.valueOf(seekbar.getMax()));
 }
 @Override
 public void onStartTrackingTouch(SeekBar seekBar) {
  // TODO Auto-generated method stub
  
 }
 @Override
 public void onStopTrackingTouch(SeekBar seekBar) {
  // TODO Auto-generated method stub
  
 }
}

you can download the sample code by Click here
0 comments

Flipper view with Animation Example


This Example will show you how to use flipper view that contain a few image and allow user to navigate the image by clicking on the button next or previous or user can touch and fling on the image to change the content of the flipper with animation.

for the first you should have 4 xml file for the animation. so you need to create directory name anim under res folder. see the image bellow.

push_left_in.xml

      
     


push_left_out.xml

      
     


push_right_in.xml

      
      


push_right_out.xml
  
      
      



This is your main.xml file

  
      
      
          

finally your java file.
FliperViewExampleActivity.java
package monstercodz.blogspot.com;

import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.View;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ViewFlipper;

public class FliperViewExampleActivity extends Activity implements OnGestureListener {
    /** Called when the activity is first created. */
 private int imageID[] = {R.drawable.pic2,R.drawable.pic3,R.drawable.pic4};
 private ViewFlipper viewFlipper = null;  
    private GestureDetector gestureDetector = null;
    private Button btn_next,btn_pre;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btn_next = (Button)findViewById(R.id.btn_next);
        btn_pre = (Button)findViewById(R.id.btn_pre);
        
        btn_next.setOnClickListener(new View.OnClickListener() {
   
   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
    nextImage();
   }
  });
        
        btn_pre.setOnClickListener(new View.OnClickListener() {
   
   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
    previousImage();
   }
  });
        
        viewFlipper = (ViewFlipper) findViewById(R.id.viewflipper); 
        // gestureDetector Object is used to detect gesture events
        gestureDetector = new GestureDetector(this); 
        for (int i = 0; i < imageID.length; i++)  
        { 
            ImageView image = new ImageView(this);  
            image.setImageResource(imageID[i]);  
            image.setScaleType(ImageView.ScaleType.FIT_XY);
            viewFlipper.addView(image, new LayoutParams(  
                    LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        }
    }
    
    private void nextImage(){
     this.viewFlipper.setInAnimation(AnimationUtils.loadAnimation(this,  
                R.anim.push_left_in));  
        this.viewFlipper.setOutAnimation(AnimationUtils.loadAnimation(this,  
                R.anim.push_left_out));  
        this.viewFlipper.showNext(); 
    }
    
    private void previousImage(){
     this.viewFlipper.setInAnimation(AnimationUtils.loadAnimation(this,  
                R.anim.push_right_in));  
        this.viewFlipper.setOutAnimation(AnimationUtils.loadAnimation(this,  
                R.anim.push_right_out));  
        this.viewFlipper.showPrevious();  
    }
    
 @Override
 public boolean onDown(MotionEvent arg0) {
  // TODO Auto-generated method stub
  return false;
 }
 @Override
 public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
   float velocityY) {
  // TODO Auto-generated method stub
  if (e1.getX() - e2.getX() > 120)  
        {  
             nextImage();
            return true;  
        }
        else if (e1.getX() - e2.getX() < -120)  
        {  
          previousImage();
          return true;
        }  
        return true;
 }
 @Override
 public void onLongPress(MotionEvent e) {
  // TODO Auto-generated method stub
  
 }
 @Override
 public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
   float distanceY) {
  // TODO Auto-generated method stub
  return false;
 }
 @Override
 public void onShowPress(MotionEvent e) {
  // TODO Auto-generated method stub
  
 }
 @Override
 public boolean onSingleTapUp(MotionEvent e) {
  // TODO Auto-generated method stub
  return false;
 }
 
 @Override 
    public boolean onTouchEvent(MotionEvent event)  
    {  
        return gestureDetector.onTouchEvent(event);  
    }
}




You can download the sample project by clicking here
3 comments

Media player with progress bar Example

This example will show you how to use the media player to play the mp3 and progress bar will load with the media duration.



This is your main.xml file


    

this is your MP3PlayerActitivy.java
package monstercodz.blogspot.com;

import java.io.IOException;

import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnPreparedListener;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class Mp3PlayerActivity extends Activity implements OnPreparedListener {
    /** Called when the activity is first created. */
 private Button btnPlay;
 private Button btnPouse;
 private int current = 0;
 private boolean   running = true;
 private int duration = 0;
 private MediaPlayer mPlayer;
 private SeekBar mSeekBarPlayer;
 private TextView mMediaTime;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mPlayer = MediaPlayer.create(getApplicationContext(), R.raw.music);
        btnPlay = (Button) findViewById(R.id.button1);
        btnPouse = (Button) findViewById(R.id.button2);
        mMediaTime = (TextView)findViewById(R.id.mediaTime);
        mSeekBarPlayer = (SeekBar)findViewById(R.id.progress_bar);
        mPlayer.setOnPreparedListener(this);
        
        mSeekBarPlayer.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
         @Override
         public void onStopTrackingTouch(SeekBar seekBar) {}
         @Override
         public void onStartTrackingTouch(SeekBar seekBar) {}
         @Override
         public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
             if(fromUser){
                 mPlayer.seekTo(progress);
                 updateTime();
             }
         }
     });
        
        btnPlay.setOnClickListener(new View.OnClickListener() {
   
   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
    try {
     mPlayer.prepare();
    } catch (IllegalStateException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
    mPlayer.start();
    mSeekBarPlayer.postDelayed(onEverySecond, 1000);
   }
  });
        
        
        btnPouse.setOnClickListener(new View.OnClickListener() {
   
   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
    mPlayer.pause();
   }
  });
    }
    
    private Runnable onEverySecond = new Runnable() {
        @Override
        public void run(){
         if(true == running){
             if(mSeekBarPlayer != null) {
              mSeekBarPlayer.setProgress(mPlayer.getCurrentPosition());
             }
             
             if(mPlayer.isPlaying()) {
              mSeekBarPlayer.postDelayed(onEverySecond, 1000);
              updateTime();
             }
         }
        }
    };
    
    private void updateTime(){
      do {
            current = mPlayer.getCurrentPosition();
            System.out.println("duration - " + duration + " current- "
                    + current);
            int dSeconds = (int) (duration / 1000) % 60 ;
            int dMinutes = (int) ((duration / (1000*60)) % 60);
            int dHours   = (int) ((duration / (1000*60*60)) % 24);
            
            int cSeconds = (int) (current / 1000) % 60 ;
            int cMinutes = (int) ((current / (1000*60)) % 60);
            int cHours   = (int) ((current / (1000*60*60)) % 24);
            
            if(dHours == 0){
             mMediaTime.setText(String.format("%02d:%02d / %02d:%02d", cMinutes, cSeconds, dMinutes, dSeconds));
            }else{
             mMediaTime.setText(String.format("%02d:%02d:%02d / %02d:%02d:%02d", cHours, cMinutes, cSeconds, dHours, dMinutes, dSeconds));
            }
            
            try{
                Log.d("Value: ", String.valueOf((int) (current * 100 / duration)));
                if(mSeekBarPlayer.getProgress() >= 100){
                    break;
                }
            }catch (Exception e) {}
        }while (mSeekBarPlayer.getProgress() <= 100);
    }
    
 @Override
 public void onPrepared(MediaPlayer arg0) {
  // TODO Auto-generated method stub
  duration = mPlayer.getDuration();
  mSeekBarPlayer.setMax(duration);
  mSeekBarPlayer.postDelayed(onEverySecond, 1000);
 }
}
you should have the directory name raw/music.mp3 under res folder. you can also download the sample project by click Here
0 comments

Xcode how to sort array Object

NSMutableArray *array = [[NSMutableArray alloc] init];
        [array addObject:[[Student alloc] initWithID:1 withName:@"Chi kheang"]];
        [array addObject:[[Student alloc] initWithID:3 withName:@"Rabee"]];
        [array addObject:[[Student alloc] initWithID:2 withName:@"Sothearoth"]];
        [array addObject:[[Student alloc] initWithID:4 withName:@"Bebe"]];
        [array addObject:[[Student alloc] initWithID:5 withName:@"Lyhour"]];
        
        //sort the object
        NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES];
        [array sortUsingDescriptors:[NSArray arrayWithObject:sort]];
        
        //print log
        for (Student *s in array) {
            NSLog(@"Student ID = %i and Name = %@\n",s.studentID,s.name);
        }


This is the out put log
0 comments

Xcode how to set tapGuesture on UIImage

in your viewDidLoad method
CGRect frame = CGRectMake(0, 50, 320, 200);
    
    //create the object for the imageview
    imageView = [[UIImageView alloc] initWithFrame:frame];
    imageView.image = [UIImage imageNamed:@"p5.png"];
    imageView.contentMode = UIViewContentModeScaleAspectFit;
    
    imageView.userInteractionEnabled = YES;
    imageView.multipleTouchEnabled = YES;
    
    [self.view addSubview:imageView];
    self.view.backgroundColor = [UIColor lightGrayColor];
    
    //tap gesture
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] 
                                          initWithTarget:self 
                                          action:@selector(handleTapGesture:)];
    tapGesture.numberOfTapsRequired = 2;
    [imageView addGestureRecognizer:tapGesture];
    [tapGesture release];

implement handleTapGesture method when you tap on image.
-(IBAction)handleTapGesture:(UIGestureRecognizer *)sender {
    if (sender.view.contentMode == UIViewContentModeScaleAspectFit)
        sender.view.contentMode = UIViewContentModeCenter;
    else
        sender.view.contentMode = UIViewContentModeScaleAspectFit;
}

this is your p5.png image

You can download the Example here
2 comments

Map view bubble example


main.xml

        


map_tag_bubble.xml

    
    
        
        
    
    

manifest.xml

    
 
    
        
            
                
                
            
        
  
    


map_bubble_background.xml

    
    
    
    


MapBubbleActivity.java
package monstercodz.blogspot.com;

import java.util.ArrayList;
import java.util.List;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.OverlayItem;

public class MapBubbleActivity extends MapActivity {
 private MapView map = null;
 private MyLocationOverlay me = null;
 private View viewBubble;
 private ViewGroup parentBubble;
 private OverlayItem item;
 private GeoPoint geo;

 @Override
 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        map = (MapView) findViewById(R.id.map);

        map.getController().setCenter(
                        getPoint(40.76793169992044, -73.98180484771729));
        map.getController().setZoom(17);
        map.setBuiltInZoomControls(true);

        Drawable marker = getResources().getDrawable(R.drawable.marker);

        marker.setBounds(0, 0, marker.getIntrinsicWidth(),
                        marker.getIntrinsicHeight());

        map.getOverlays().add(new SitesOverlay(marker));

        me = new MyLocationOverlay(this, map);
        map.getOverlays().add(me);
 }

 @Override
 public void onResume() {
        super.onResume();

        me.enableCompass();
 }

 @Override
 public void onPause() {
        super.onPause();

        me.disableCompass();
 }

 @Override
 protected boolean isRouteDisplayed() {
        return (false);
 }

 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_S) {
                map.setSatellite(!map.isSatellite());
                return (true);
        } else if (keyCode == KeyEvent.KEYCODE_Z) {
                map.displayZoomControls(true);
                return (true);
        }

        return (super.onKeyDown(keyCode, event));
 }

 private GeoPoint getPoint(double lat, double lon) {
        return (new GeoPoint((int) (lat * 1000000.0), (int) (lon * 1000000.0)));
 }

 private class SitesOverlay extends ItemizedOverlay {
        private List items = new ArrayList();

        public SitesOverlay(Drawable marker) {
                super(marker);
                boundCenterBottom(marker);

                items.add(new OverlayItem(getPoint(40.748963847316034,
                                -73.96807193756104), "UN", "United Nations"));
                items.add(new OverlayItem(getPoint(40.76866299974387,
                                -73.98268461227417), "Lincoln Center",
                                "Home of Jazz at Lincoln Center"));
                items.add(new OverlayItem(getPoint(40.765136435316755,
                                -73.97989511489868), "Carnegie Hall",
                                "Where you go with practice, practice, practice"));
                items.add(new OverlayItem(getPoint(40.70686417491799,
                                -74.01572942733765), "The Downtown Club",
                                "Original home of the Heisman Trophy"));

                populate();
        }

        @Override
        protected OverlayItem createItem(int i) {
                return (items.get(i));
        }
        
        @Override
        public boolean onTap(GeoPoint p, MapView mapView) {
         dimissbubble();
         return super.onTap(p, mapView);
        }

        @Override
        protected boolean onTap(int i) {

                item = getItem(i);
                geo = item.getPoint();
                addBubble(geo);  //We call the functtion addbubble passing the position of the item tapped
                return (true);
        }

        @Override
        public int size() {
                return (items.size());
        }
 }

 private void dimissbubble(){
  if (viewBubble != null) {
   map.removeView(viewBubble);
   viewBubble = null;
  }
 }

 //the main function about bubble
 private void addBubble(GeoPoint point) {
  dimissbubble();
 //if there isn't any bubble on the screen enter
        if (viewBubble == null) {

                parentBubble = (ViewGroup) map.getParent();
               //We inflate the view with the bubble
                viewBubble = getLayoutInflater().inflate(R.layout.map_tag_bubble,
                                parentBubble, false);

                //to position the bubble over the map. The -128 and -150 are the offset.
                MapView.LayoutParams mvlp = new MapView.LayoutParams(
                                MapView.LayoutParams.WRAP_CONTENT,
                                MapView.LayoutParams.WRAP_CONTENT, geo, -128, -150,
                                MapView.LayoutParams.LEFT);
                
                /*LayoutParams mvlp = new MapView.LayoutParams(
            MapView.LayoutParams.WRAP_CONTENT, 
            MapView.LayoutParams.WRAP_CONTENT, geo, 
            MapView.LayoutParams.TOP | MapView.LayoutParams.CENTER_HORIZONTAL);*/
                
                LinearLayout f = (LinearLayout) viewBubble;
 //Fill the text
                ((TextView) f.findViewById(R.id.tag_title_textview))
                .setText(item.getTitle());
                ((TextView) f.findViewById(R.id.tag_last_seen_textview))
                .setText(item.getSnippet());

                // ((TextView)((FrameLayout)viewBubble))).findViewById(R.id.bubbleText))))
 //And the event.
                viewBubble.setOnClickListener(new OnClickListener() {

                        //When we touch the bubble it is removed. And make null viewBubble to reuse it.
                        @Override
                        public void onClick(View v) {
                                map.removeView(viewBubble);
                                viewBubble = null;

                        }
                });
                //As you see, add in the map.
                map.addView(viewBubble, mvlp);
        }
 }
 }

you file structure should look like this

you drawable image

Download the source code clickHere
0 comments

Android map view example

main.xml


to generate your map keyClick here

Manifest.xml

    

    
        
            
                
                
            
        
  
    
    


HelloItemizedOverlay.java
package monstercodz.blogspot.com;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class HelloItemizedOverlay extends ItemizedOverlay{
 
 private ArrayList mOverlays = new ArrayList();
 private Context mContext;
 public HelloItemizedOverlay(Drawable defaultMarker,Context context) {
  super(boundCenterBottom(defaultMarker));
  // TODO Auto-generated constructor stub
  mContext = context;
 }
 
  public void addOverlay(OverlayItem overlay){
  mOverlays.add(overlay);
  populate();
  }

 @Override
 protected OverlayItem createItem(int i) {
  // TODO Auto-generated method stub
  return mOverlays.get(i);
 }

 @Override
 public int size() {
  // TODO Auto-generated method stub
  return mOverlays.size();
 }
 
 @Override
 protected boolean onTap(int index) {
  // TODO Auto-generated method stub
   OverlayItem item = mOverlays.get(index);
   AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
   dialog.setTitle(item.getTitle());
   dialog.setMessage(item.getSnippet());
   dialog.show();
   return true;
 }

}

MapViewExample.java
package monstercodz.blogspot.com;

import java.util.List;

import android.graphics.drawable.Drawable;
import android.os.Bundle;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class MapViewExample extends MapActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);
        List mapOverlays = mapView.getOverlays();
        Drawable drawable = this.getResources().getDrawable(R.drawable.marker);
        HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable,this);
        GeoPoint point = new GeoPoint(30443769,-91158458);
        OverlayItem overlayitem = new OverlayItem(point, "Laissez les bon temps rouler!", "I'm in Louisiana!");

        GeoPoint point2 = new GeoPoint(17385812,78480667);
        OverlayItem overlayitem2 = new OverlayItem(point2, "Namashkaar!", "I'm in Hyderabad, India!");

        itemizedoverlay.addOverlay(overlayitem);
        itemizedoverlay.addOverlay(overlayitem2);

        mapOverlays.add(itemizedoverlay);
    }

 @Override
 protected boolean isRouteDisplayed() {
  // TODO Auto-generated method stub
  return false;
 }
}

marker.png

Download source code example here
0 comments

Android how to generate google api key

google api key is use to build an android application witch is use with google map.
to generate it you need to open the open the keytool.exe by comment prompt in your window witch is contain in the java/jdk/bin directory they type keytool -list -keystore your debug.keystore where your debug.keystore is always store in the C:\Users\your user\.android\debug.keystore. please have a look with the image below.
after you do it correct it will ask you for the password. so your password should be "android" after that copy the Certificate fingerprint to past in http://code.google.com/android/maps-api-signup.html on the Certificate finger print fill and check on the I have read and agree with the terms and conditions then click on generate api key button fill with your google mail account. after that you will get the google key to use for build your android project that use with google map.
0 comments

Android using Bundle for sharing variables

Sharing variables between Activities is quite important point during development time of your Application. This Example suppose Activity1 from where you run up other Activity2 based on your selection from submenu. You gonna share variable myValue

From Activity1
Intent intent = new Intent(this,myActivity2.class);
Bundle bundle = new Bundle();
bundle.putString(“myValue“, myValue);
intent.putExtras(bundle);
navigation.this.startActivity(intent);
In Activity2
Bundle bundle = getIntent().getExtras();
act2MyValue= bundle.getString(“myValue“);
//Now is your application powered to share variables between two different activities.
0 comments

Android Button State change Example

This tutorial you will learn how to change the button state xml.
First you need to have 3 image to switch for their state
def.png
disable.png
press.png

Now you need to have button_selector.xml


 
     
     


main.xml


    
    
    

ButtonStateExample.java
package monstercodz.blogspot.com;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class ButtonstateExample extends Activity implements OnClickListener {
 private Button btn1;
 private Button btn2;
 private boolean checkClick = false;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btn1 = (Button)findViewById(R.id.btn);
        btn2 = (Button)findViewById(R.id.btn1);
        btn1.setOnClickListener(this);
        btn2.setOnClickListener(this);
    }
 @Override
 public void onClick(View v) {
  // TODO Auto-generated method stub
  if(v == btn1){
   Toast.makeText(getApplicationContext(), "Button Enable You can click", Toast.LENGTH_LONG).show();
  }else{
   if(!checkClick){
    checkClick = true;
    btn1.setEnabled(false);
   }else{
    checkClick = false;
    btn1.setEnabled(true);
   }
  }
 }
}

you can also download Source codeClick here