what is E4X Simply?

By | October 5, 2010

E4X = JavaScript for XML E4X means “ECMAScript For XML”. It is a standard extension to ECMAScript. So in real life E4X means “JavaScript for XML”.

admin

Custom Toasts in ANDROID.

By | October 5, 2010

First, just show an image inside a toast: [java] package com.Ch.Example.pack; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.Gravity; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.Toast; public class Example extends Activity { /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); showToast(); } private void showToast() { Toast toast =… Read More »

admin

How to make sure the network is available in android?

By | October 5, 2010

Get all the available network connections [java] public boolean isNetworkAvailable() { Context context = getApplicationContext(); ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity == null) { Toast.makeText(this, "No conectivity", Toast.LENGTH_LONG).show(); } else { NetworkInfo[] info = connectivity.getAllNetworkInfo(); if (info != null) { for (int i = 0; i < info.length; i++) { if (info[i].getState() == NetworkInfo.State.CONNECTED) { Toast.makeText(this, ""+info[i].getTypeName(),… Read More »

admin

Get my Telephone number in ANDROID

By | October 5, 2010

Gets the phone number the app is running on. It needs a permission so add the line uses-permission android:name=”android.permission.READ_PHONE_STATE” to the manifest.xml [java] private String getMyPhoneNumber(){ TelephonyManager mTelephonyMgr; mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); return mTelephonyMgr.getLine1Number(); } private String getMy10DigitPhoneNumber(){ String s = getMyPhoneNumber(); return s.substring(2); } [/java]

admin

How to start an application at bootup in ANDROID?

By | October 4, 2010

This snippet starts an Application automatically after the android-os booted up. [java] String url = "url"; Intent intent1 = new Intent(Intent.ACTION_VIEW); intent1.setData(Uri.parse(url)); startActivity(intent1); [/java] in AndroidManifest.xml (application-part): [xml] <receiver android:enabled="true" android:name=".BootUpReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </receiver> [..] <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> [..] [/xml] [java] public class BootUpReceiver extends BroadcastReceiver{ @Override public void onReceive(Context context,… Read More »

admin

How to send an SMS from an android application?

By | October 4, 2010

It’s easy to send Messages using the SmsManager in android. Check some of the examples relating to working with SMS’s in android. 1. How to simulate an incoming call to an emulator OR Send an SMS to an emulator in ANDROID ? 2. Listening incoming sms message in Android. 3. How to get notified during an incoming call… Read More »

admin

How to convert Bitmap image to drawable in Android?

By | October 4, 2010

Converting a bitmap to drawable is really easy in ANDORID. It has a class called BitmapDrawable which takes a bitmap as the parameter and convert it into a drawable object. [java] BitmapDrawable bd = new BitmapDrawable(targetBitmap); [/java]

admin

Play Video using VideoView in ANDROID.

By | September 19, 2010

Playing a video file is simple in android. This post will help you. Put your video in res/raw folder. If no raw folder present then create a new folder inside res. [java] package com.coderzheaven.pack; import android.app.Activity; import android.net.Uri; import android.os.Bundle; import android.widget.MediaController; import android.widget.VideoView; public class Example extends Activity { /** Called when the activity is first created.… Read More »

admin

How to drag and drop in ANDROID?

By | September 18, 2010

The following code helps you to do a drag and drop in ANDROID. [java] package com.pack; import android.app.Activity; import android.content.Context; import android.graphics.Canvas; import android.os.Bundle; import android.view.MotionEvent; import android.widget.AbsoluteLayout; import android.widget.Button; import android.widget.ImageView; public class Touch extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MyView tx = new… Read More »

admin

How to uninstall an application in ANDROID phone through Code?

By | September 17, 2010

By using the below code snippet you can uninstall an installed application on your ANDROID phone. Create an intent object with an action and data as the package name and start with the ACTION_DELETE. [java] Intent intent = new Intent(Intent.ACTION_DELETE); intent.setData(Uri.parse("package:com.pack.Applicationname")); startActivity(intent); [/java]

admin

To restart your application in Adobe AIR

By | September 15, 2010

Call this function to restart your application [xml] var app:WindowedApplication = WindowedApplication(Application.application); var mgr:ProductManager = new ProductManager("airappinstaller"); mgr.launch("-launch " + app.nativeApplication.applicationID + " " + app.nativeApplication.publisherID); app.close(); [/xml] Note : PLease add this to your app.XML file inorder for the above code to work.

admin

Load html string into WebView in android

By | September 13, 2010

This sample code helps you to load html from a string and from a file into webview in ANDROID. [java] String str = Your HTML String; /* use src=’file:///android_asset/images/photo_3.jpg’ for loading images from the assets /images folder */ /* To load from a string use loadDataWithBaseURL */ webview.loadDataWithBaseURL("",str , "text/html", "utf-8", ""); /* To load from a file… Read More »

admin