Skip to main content

Posts

Showing posts from 2011

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);   ...

Simple Android Audio record Example Android

public class AudioRecorder { final MediaRecorder recorder = new MediaRecorder(); public void start() throws IOException { recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(sdCardPath+ "/xyz.3gp "); recorder.prepare(); recorder.start(); } public void stop() throws IOException { recorder.stop(); recorder.release(); } }

ProgressDialog in android

ProgressDialog progressDialog = null ;     // ...     progressDialog = ProgressDialog . show ( this , "Please wait..." , true );     new Thread () {         public void run () {             try {                   // Grab your data                                                             } catch ( Exception e ) { }             // When grabbing data is finish: Dismiss your Dialog             progressDialog . dismiss ();         }     }. start ();

ProgressDialog using Handler Use

Step 1: Create Global Handler Class. private EventHandler mEventHandler = new EventHandler(); class EventHandler extends Handler { int tempMsg = 0; @Override public void handleMessage(Message msg) { try { switch (msg.what) { case 1: // call method whatever you want. break; dialog.dismiss(); } catch (Exception e) { Log.d("XReader", "Error in " + e.getMessage()); } } }; step2: call Hender using Msg ProgressDialog dialog = ProgressDialog.show(XReaderActivity.this, "", "Please wait",true); Message message = new Message(); message.what = 1; mEventHandler.sendMessage(message);

ESRI using Eclipse setup guide

Please follow these steps to install the ArcGIS for Android 1.0 Beta Eclipse plug-ins: 1. Start Eclipse, then select Help > Install New Software.... 2. In the top-right corner, Click Add. 3. In the Add Repository dialog that appears, enter “ArcGIS Android” for the Name and the following URL for the Location: http://downloads.esri.com/software/arcgis/android 4. In the Available Software dialog, select the checkbox next to ArcGIS for Android and click Next. 5. In the next window, you'll see two plug-ins to be installed. Click Next. 6. Display the License text by clicking on "IMPORTANT-READ CAREFULLY". Read the license text, then click the radio button to accept the license agreements, then click Finish. 7. When the installation completes, restart Eclipse. * Notes for users of ArcGIS for Android Early Adopter release only If you had installed the plug-ins for the ArcGIS for Android Early Adopter release, please refer to the Help for ArcGIS API for Android ...

Hw to use android:layout_weight

Use android : layout_weight < LinearLayout         android : orientation = "vertical" android : layout_width = "fill_parent"         android : layout_height = "fill_parent" android : weightSum = "100"         xmlns : android = "http://schemas.android.com/apk/res/android" >         < LinearLayout             android : layout_width = "fill_parent" android : layout_height = "wrap_content"             android : layout_weight = "70" >         < /LinearLayout>         <LinearLayout android:id="@+id/ widget32 " android:orientation=" horizontal "             android:layout_weight=" 30 " android:layout_width=" fill_parent "             android:layout_height=" wrap_content ">         </LinearLay...

Email validation for android Edittext

public boolean eMailValidation(String emailstring) { emailPattern = Pattern.compile("[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}" + "\\@" + "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" + "(" + "\\." + "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" + ")+"); emailMatcher = emailPattern.matcher(emailstring); return emailMatcher.matches(); }

GET TEXT FROM ASSERT ANDROID

private String getAssertText(String path) { String javascrips= "" ; try { InputStream input = getAssets().open(path); int size; size = input.available(); byte [] buffer = new byte [size]; input.read(buffer); input.close(); // byte buffer into a string javascrips = new String(buffer); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return javascrips; }

Call webservice using restclient android

package com.util; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URLEncoder; import java.util.ArrayList; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicNameValuePair; import org.apache.http.protocol.HTTP; public class RestClient {     private static final int GET = 0; private static final int POST = 1; private ArrayList <NameValuePair> params;     private ArrayList <NameValuePair> header...

Parsing JSON using GSON in Android

Parsing JSON using GSON in Android Download GSON lib : http://code.google.com/p/google-gson/downloads/list As part of the college mini project,  I along with my group, developed a micro-blogging platform for Android. One of the biggest hurdles I had to face was of choosing the proper data format for receiving responses from the web service. I needed something that was fast as well as easy to understand and parse.  I first chose XML as it was easy to read and mostly because I knew no other alternatives. But parsing XML certainly wasn’t easy. With the variety of tags in the responses from the server and the heaviness of XML format, it just became impossible to use it. That’s when  JSON (JavaScript Object Notation) came up as an alternative to XML. I was circumspect about using JSON at first as I had doubts about its readability and ease of deserialization. But those doubts were not much more than just superstitions. JSON is smaller and easier to parse, than...