Skip to main content

Posts

ProgressDialog example using handler android

final ProgressDialog dialog = ProgressDialog . show ( this , "Title" , "Message" , true ); final Handler handler = new Handler () { public void handleMessage ( Message msg ) { dialog . dismiss (); } } ; Thread t = new Thread () { public void run () { // write process code here. handler . sendEmptyMessage ( 0 ); } } ; t . start ();

local image & text load in webview

public void onCreate ( Bundle savedInstanceState ) {         super . onCreate ( savedInstanceState );         setContentView ( R . layout . main );         WebView view = ( WebView ) findViewById ( R . id . webView1 );         try {         InputStream input = getResources (). openRawResource ( R . raw . lights );         Reader is = new BufferedReader (                 new InputStreamReader ( input , "windows-1252" ));             //InputStream input = getAssets().open("ws.TXT");             int size ;             size = input . available ();             byte [] buffer = new byte [ size ];             input . read ( buffer );     ...

Convert GeoPoint to Address

public String ConvertPointToLocation (GeoPoint gp) {             String address = "" ;             Geocoder geoCoder = new Geocoder( this , Locale. getDefault ());             try {                   List<Address> addresses = geoCoder.getFromLocation(                               (gp.getLatitudeE6()/1E6),(gp.getLongitudeE6()/1E6), 1);                   if (addresses.size() != 0) {                         for ( int index = 0; index < addresses.get(0)                         .getMaxAddressLineIndex(); index++)                               address += addresses.get(0).getAddressLine(index) + " " ;                   }             } catch (IOException e) {             }             return address;       }

Share data android

 Intent msg = new Intent(Intent.ACTION_SEND);  String[] recipients = { "" }; // this.is@recipient.com   String[] carbonCopies = { "" }; // hey.another@recipient.   msg.putExtra(Intent.EXTRA_EMAIL, recipients);   msg.putExtra(Intent.EXTRA_CC, carbonCopies);  msg      .putExtra(        Intent.EXTRA_TEXT,        "your text");   // Change from ApplicationStep class subject line     // Html.   msg.putExtra(Intent.EXTRA_SUBJECT, ApplicationStep.EMAIL_SUBJECT);     msg.putExtra(Intent.EXTRA_STREAM, Uri.parse(sUri)); // attachment    msg.setType("image/png");   startActivity(Intent.createChooser(msg,      "Please choose an email client"));

Get ImageFile form server and Store onto Device's memory and display it

public class DataStoreActivity extends Activity {     /** Called when the activity is first created. */     @Override     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         //setContentView(R.layout.main);         DownloadFile(" i mage file path www.");         byte b[] = readInternalStoragePrivate("download.jpg");                 Bitmap bmp = BitmapFactory.decodeByteArray(b, 0, b.length);                 ImageView imageView = new ImageView(this);         imageView.setImageBitmap(bmp);         setContentView(imageView);   ...