Wednesday, January 5, 2011

Sending a video file via Bluetooth by directly opening the Bluetooth default page

try
{
Intent int_bluetooth= new Intent();
int_bluetooth.setAction(Intent.ACTION_SEND);
int_bluetooth.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
int_bluetooth.setType("video/*");
int_bluetooth.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://mnt/sdcard/poi.3gp"));
int_bluetooth.setClassName("com.android.bluetooth", "com.android.bluetooth.opp.BluetoothOppLauncherActivity");

startActivity(int_bluetooth);
}
catch(ActivityNotFoundException e)
{
Log.e("Bluetooth", e.toString());
}

Monday, December 6, 2010

Inserting an image in to Gallery

Bitmap bmpImg = BitmapFactory.decodeFile("/sdcard/hi.png");
MediaStore.Images.Media.insertImage(getContentResolver(), bmpImg, null, null);

Dispatching touch event of one view to aother view

Button btnFirst = new Button(this);
btnFirst.setOnTouchListener(new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
Log.i("First Button","This is first button's onTouch()");
return false;
}
}));

Button btnSecond = new Button(this);
btnSecond.setOnTouchListener(new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
btnFirst.dispatchTouchEvent(event);
return false;
}
}));