Thursday, April 7, 2011

INTERCEPTING ONE APP FROM ANOTHER IN ANDROID

hi, if u want to open one application from another using intent the following code is usuful.

Intent intent = new Intent(Intent.ACTION_MAIN);

intent.setComponent(new ComponentName("com.example.android.apis","com.example.android.apis.ApiDemos")); //Here we have to specify package name and corresponding activity in that package are parameters.

startActivity(intent);

      In this example i am opening api demos from my application. So "com.example.android.apis" is the main package and "com.example.android.apis.ApiDemos" is the main activity.

DOWNLOADING IMAGE FROM INTERNET IN ANDROID

public Bitmap downloadImageFromWeb(String url)
{
        Bitmap bitmap = null;
        InputStream in;
        try       
        {
            //Creation of url
            URL url_img = new URL(url);
          
            //Establishing Connection
            in = url_img.openStream();
          
            //Converting input stream to bitmap
            bitmap = BitmapFactory.decodeStream(in);
          
            //Closing the input stream
            in.close();
        }
        catch (MalformedURLException e)
        {
            e.printStackTrace();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return bitmap;
}

DEVICE MODEL OR VISIBLE NAME IN ANDROID


Using Build  Class we will get the details of the mobile like device name, device info...

Build . MODEL ---- The visible device name.

Build . PRODUCT --- The name of the overall product.

Build . MANUFACTURER -- The manufacturer of the product.


For More Details about this class go through the link.
http://developer.android.com/reference/android/os/Build.html