Wednesday, November 16, 2011

Android :connot see the image/file/video that has been saved by application on SD card

Well this thing may cause a head-storm

Scenario :
Your application has saved/write a file/picture/video that is not being reflected in the gallery.
The reason behind this is that media Scanner is not aware of the new files ..

So the Simple solution to this problem is

try Running this piece of code after u have closed your output stream after writing the file:


MediaScannerConnection.scanFile(context, new String[] { filePath+fileName }, null, null);

Tuesday, November 15, 2011

Android Loading Dialog Box

By this you can show a loading dialog box to the user while performing a background task


First declare the ProgressBar and its Handler:


    ProgressDialog progressBarDialog;
     Handler handler=new Handler() {
             @Override
             public void handleMessage(Message msg)
             {
                
                 if(progressBarDialog != null)
                 {
                     progressBarDialog.dismiss();
                
                        ///Write the code u want to perform after the previous task was completed
                 }
                
             }
         };
   

Place the task/function/code u want to perform inside run()

progressBarDialog = ProgressDialog.show(PhoneLog.this, "Cyber Sports", "Saving...", true);
                        new Thread()
                        {
                            public void run()
                            {
                                GenerateResponse();///example of the task u want to perform
                                handler.sendMessage(handler.obtainMessage());
                            }
                        }.start();

And its done!!

Android Check intertnet connection is available or not

  //////Check Internet Connection return True or False  ///////

        public static boolean isInternetAvailable(Context context)
        {
             boolean isInetrnetAvailable = false;
             try
             { 
                  ConnectivityManager connectivityManager = (ConnectivityManager)   
                   context.getSystemService(Context.CONNECTIVITY_SERVICE);
                  NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
               
                  if(networkInfo != null)
                  {  
                       if( networkInfo.isConnected())
                       {
                           isInetrnetAvailable  = true;
                       }
                       else
                       {
                           isInetrnetAvailable  = false;
                       }
                  }
                  else
                  {
                      isInetrnetAvailable = false;
                  }
             }
             catch(Exception exception)
             {
                 isInetrnetAvailable = false;
             }
             
             return isInetrnetAvailable;
        }


------------------------------------------
in addition  you can navigate the user to Wireless and Network settings through calling ....

 startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));

Wednesday, October 19, 2011

Icecream Sandwhich for HTC Desire

Hey Guys... after watching several videos online .. i updated Android Sdk and tried ICS on emulator..
Its full of lots of feature .... its mouthwatering

So cant wait it to taste it...


just waiting for any Aosp ROM to get released what u think!!!

I will post any links if  i got the one as I am keeping eye on this every second


P.S.

here is the link this ICS ROM is a SDK Port .... u can give it a try ...


http://forum.xda-developers.com/showthread.php?t=1313577

and here is the video



enjoY!


UPDATE 15 NOV 2011

As the Google  has released the source code ...so the serious development will begin ..we can see some alpha - beta  within a week

++ CyanogenMod has declared that it will try to support all 60 devices with ICS(within 2 months)
that includes HTC Desire too
So we will definitely get the taste of  Ice Cream Sandwhich

Mean While the rooted users can get ICS theme  a system theme + you can also have same in Go launcher 
combining both themes u get a real feel of ICS a bit..


UPDATE 21 NOV 2011

There goes the development.....

[DEV-WIP] ICS for Desire [ITL41D-SOURCE] [DOWNLOAD AVAILABLE]

Thursday, October 13, 2011

Disable Android Market Updater

Hate the new market........

So well if you are rooted than you can achieve by typing following command in emulator on your phone

Emulator Market link

Command

su -
pm disable com.android.vending.updater

Friday, September 30, 2011

Create Alert Dialog in Android

To create Alert Dialog just call the following code where you want to like on button click on back button press or where ever you wish


Like this is an example where I asked user to exit the application on back button pressed :

@Override
    public void onBackPressed() {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setMessage("Are you sure you want to EXIT?")
            .setCancelable(false)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) 
                  {
                     moveTaskToBack(true) ;
                     System.exit(0);
                }
            })
            .setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
            AlertDialog alert = builder.create();
            alert.show();
     }


Wednesday, September 28, 2011

Vertical and Horizontal Scroll on a Layout in Android

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/cybersportsbg">

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scrollbars="vertical">

        <HorizontalScrollView
            android:id="@+id/horizontalScrollView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <LinearLayout
                android:id="@+id/linearLayout1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal">
.....
  ----Your Layout------
........


            </LinearLayout>
            </HorizontalScrollView>
            </ScrollView>


</LinearLayout>

Launch CALL Activity on TextView or button Click in Android

First set the on click listener for your Button :

               btnMail.setOnClickListener(new View.OnClickListener() {
                       @Override
                       public void onClick(View arg0)
                                  {
                                     // TODO Auto-generated method stub
                                      call(txtPhone.getText().toString());
                                  }
                           });


Then Call this function !!!!

               private void call(String phone) {
                       try {
                              Intent callIntent = new Intent(Intent.ACTION_CALL);
                               callIntent.setData(Uri.parse("tel:"+phone));
                              startActivity(callIntent);
                             } catch (ActivityNotFoundException e) 

                       }
                   

And  Bingo thats IT!!!

Tuesday, September 27, 2011

Launch Mail Activity on TextView or button Click in Android

First set the on click listener for your Button :

               btnMail.setOnClickListener(new View.OnClickListener() {
                       @Override
                       public void onClick(View arg0)
                                  {
                                     // TODO Auto-generated method stub
                                       mail(txtEmail.getText().toString());
                                  }
                           });


Then Call this function !!!!

             private void mail(String email)
                       {
                             Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                             emailIntent.setType("text/plain");
                             emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,email);
                             startActivity(emailIntent);
                       }

And  Bingo thats IT!!!

Sunday, May 15, 2011

My first post to this blog

well welcome and warm regards to anyone who is reading this.. Just to begin with i am junior Android Developer ..and have HTC  Desire ,my first Android...
From the very first day i have got this device i find new things everyday.. each day i get surprised  that whoa! i can do this with it!!
well that's the real power of ANDROID....if u have came so far reading this than ,you must be  an android Fanboy...so don,t wait start following start exploring!!!...enjy