Tuesday, 23 October 2012

Android Design

http://speckyboy.com/2012/06/10/android-gui-stencils-kits-and-templates/

Friday, 19 October 2012

Android call browser by click even


write the code under the click event


Intent browserIntent1 = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
        startActivity(browserIntent1);

Tuesday, 16 October 2012

Android Video Player from youtube

package com.example.vidoplayer;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
        Toast.makeText(MainActivity.this, "Hello world", Toast.LENGTH_LONG).show();
        VideoView videoView = (VideoView) findViewById(R.id.vv);
        MediaController mediaController = new MediaController(this);
        mediaController.setAnchorView(videoView);
     // Set video link (mp4 format )
        Uri video = Uri.parse("http://www.youtube.com/watch?v=lEbxLDuecHU&playnext=1&list=PL040F3034C69B1674");
        videoView.setMediaController(mediaController);
        videoView.setVideoURI(video);
        videoView.start();

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}

Saturday, 13 October 2012

How to show error in an EditText using setError() in Android?

package com.coderzheaven.seterror;
 
 import android.app.Activity;
 import android.os.Bundle;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.Button;
 import android.widget.EditText;
 
 public class MainActivity extends Activity {
 
 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 Button btn =(Button)findViewById(R.id.button1);
 btn.setOnClickListener(new OnClickListener() {
 
 @Override
 public void onClick(View v) {
 EditText edittext =(EditText)findViewById(R.id.editText1);
 if(edittext.getText().length()==0){
 edittext.setError("Field cannot be left blank.");
 }
 }
 });
 }
 }
 
 
 
 
SetError Android

 
 

Thursday, 11 October 2012

Hello ALL Android Lovers.

You Know How to Restrict your App work for a Specific period ?

Yes: Excelent/Good/Perfect.
No: Then Check This.


 private void expiryDate() {
        try{

        //not work after 12/11/2012(DD/MM/YYYYY).
        if (new Date().after(new GregorianCalendar(2012,10,12).getTime())) { 
            AlertDialog.Builder ad = new AlertDialog.Builder(MainActivity.this);
            ad.setTitle("App Expired");
            ad.setMessage("Please Contact this ABC");
            ad.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                  finish();
               }
             }).show();
           }
        } catch (Exception e) { /* handle any exceptions */ return; }
       
    }

Enjoy .