Skip to main content


Showing posts from February, 2014

Warning - No DNS Server found : Android

Mostly new android users face this problem when they install Android eclipse and run any created project than the below error comes on console of android eclipse and project does not run :
Warning: No DNS servers found
There is a simple solution to this issue.See below..

Go to -> Window -> Preferences -> Android -> Launch -> Default Emulator Option ->
paste this: -dns-server,

then Apply -> OK

Now create any project you will never face this issue again.

Read File Names From Assets To A ListView

Here in this blog we are explaing how to load files names from asset and load it in a listview.
Here we have saved certain html files inside assets/datas/..
Copy and Download the code...
public class MainActivity extends Activity { ListView list; String path; ArrayList<String> data = new ArrayList<String>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); list = (ListView) findViewById(; path = getResources().getString(; showlist(); } private void showlist() { String[] data1 = null; // *****got all resource in "am" from asset********* AssetManager am = getResources().getAssets(); try { // ***** got all one by one in arraylist "data1" ********* data1 = am.list(path); } catch (Exception e) { } for (String name : data1) { // ***** removing all .htm from extension******…

Alert, Confirm, and Prompt boxes in Javascript

The three "commands" involved in creating alert, confirm, and prompt boxes are:
window.alert()window.confirm()window.prompt()window.alert() : This command pops up a message box displaying whatever you put in it. <body> <script type="text/javascript"> window.alert("Iam an alert box!!!") </script> </body> window.confirm(): Confirm is used to confirm a user about certain action, and decide between two choices depending on what the user chooses. <body> <script type="text/javascript"> var x=window.confirm("Are you sure?") if (x) window.alert("Yes!") else window.alert("No") </script> </body> window.prompt(): Prompt is used to allow a user to enter something, and do something with that info: <body> <script type="text/javascript"> var y=window.prompt("Enter your name here...") window.alert(y) </script> </body>

Simple Gallery Application In Android

Here is simple gallery application.Copy and download the code and try it out.....
public class mygalleryactivity extends Activity { Integer[] imageIDs = { R.drawable.pic1, R.drawable.pic2, R.drawable.pic3, R.drawable.pic4, R.drawable.pic5, R.drawable.pic6, R.drawable.pic7 }; Gallery gallery; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); gallery=(Gallery) findViewById(; gallery.setAdapter(new ImageAdapter(this)); gallery.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position ,long id) { // TODO Auto-generated method stub Toast.makeText(getBaseContext(), "pic" + (position + 1) + "selected", Toast.LENGTH_SHORT).show(); ImageView imageView =(ImageView) findViewById(; image…

Android Get Current Time and Date

For getting current (today) date and time in android application, we used calendar class get the current instance of android phone clock.
After getting calendar class object, we required a formatted object for date and time.
Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("dd:MMMM:yyyy HH:mm:ss a"); String strDate = sdf.format(c.getTime()); System.out.println("================>>>"+strDate);
Android Time formats table

d single digit date e.g. 5 dd double digit date e.g. 05 M single digit month e.g. 1 MM double digit month e.g. 01 MMM three-letter abbreviation for month e.g. Jan MMMM month spelled out in full e.g. January yy double digit year e.g. 13 yyyy four digit year e.g. 2013
Android Time format table

h single digit hours in 12 hour format e.g. 9 hh double digit hours in 12 hour formate e.g. 09 H single digit hours in 24 hour format e.g. 9PM as 21 HH double digit hours in 24 hour format e.g. 9PM as 21 m single d…

How to sign an android APK, a simplest way

After completing your Android Project, you have to sign it before you upload it.And here in this post we explain an easy way to sign an apk via eclipse. Double click the Android Manifest file and and clearly provide the package and version code and version name.
Below that there is link called “use the export wizard”. Click on that.

then another window will open, there select your desired project.

click Next, then you will be asked for a keystore, if you have a keystore file then browse and locate the file.
Create a new one.
If you have a keystore file the after locating the file you have to give the password.

Click on Finish and your APK file will be created in the destination directory.
If you are creating a new one then…
Go through these steps by filling in the details that appear in the dialog.

Clicking on Finish will create your signed APK.
Now Give a location for you signed apk file.- Click finish -> Your signed APK is ready for upload to the market.