Showing posts with label ANDROID DEVELOPMENT. Show all posts
Showing posts with label ANDROID DEVELOPMENT. Show all posts

Crop Image in Android

Intent intent = new Intent(Intent.ACTION_PICK, null);
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", int_Width_crop);
intent.putExtra("outputY", int_Height_crop);
intent.putExtra("scale", false);
intent.putExtra("return-data", true);
intent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUri());
//  Uri imagePath = getImageUri();
startActivityForResult(intent, CHOOSE_PICTURE);
------------------------------------------------------------------------------------------

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_REQUEST)
{
Uri imagePath = getImageUri();
// System.out.println("Activity result"+imagePath);
}
if (requestCode == CROP_FROM_CAMERA)
{
final Bundle extras = data.getExtras();
if (extras != null) {
Bitmap photo = extras.getParcelable("data");
// mPhoto = photo;
// mPhotoChanged = true;
myImage.setImageBitmap(photo);
// setPhotoPresent(true);
}
}
if (requestCode == CHOOSE_PICTURE)
{
final Bundle extras = data.getExtras();
if (extras != null) {
Log.d("photo", "extras is not null");
Uri selectedImage = getImageUri();
getContentResolver().notifyChange(selectedImage, null);
ContentResolver cr = getContentResolver();
Bitmap bitmap;
try {
bitmap = android.provider.MediaStore.Images.Media
.getBitmap(cr, selectedImage);
Log.d("photo",
"data.getAction() is not null. setting image.");
this.myImage.setImageBitmap(bitmap);
} catch (Exception e) {
Toast.makeText(this, "Failed to load",
Toast.LENGTH_SHORT).show();
Log.e("photo", e.toString());
}
}
}

Android Training in Kerala

How To start audio using Service in android

public class MyServices extends Service{
private static final String TAG = “MyService”;
MediaPlayer player;
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
//Toast.makeText(this, “Back”, Toast.LENGTH_LONG).show();
Log.d(TAG, “onCreate”);
player = MediaPlayer.create(MyServices.this, R.raw.natural);
player.setLooping(true); // Set looping
}
@Override
public void onDestroy() {
Toast.makeText(this, “Background Sound Stopped”, Toast.LENGTH_LONG).show();
Log.d(TAG, “onDestroy”);
player.stop();
player.release();
}
@Override
public void onStart(Intent intent, int startid) {
Toast.makeText(this, “Background Sound Enabled”, Toast.LENGTH_LONG).show();
Log.d(TAG, “onStart”);
player.start();
}
}



// in manifest file
<service android:enabled=”true” android:name=”.class name” />


TO start audio
startService(new Intent(Settings.this, MyServices.class));

TO stop service
stopService(new Intent(Settings.this, MyServices.class));


Android Training in Kerala

Creating Your First Android Application

Requirements

1:Eclipse IDE
2:Android Sdk(Download from http://developer.android.com/sdk/index.html)
3:JDK 1.6

By using Eclipse IDE,you can create a project (select File > New >Project then choose Android >Android Project











Next step  is to give meaningful project name.
After giving a name,locate your workspace(*Workspace is the location where you actually save your project).
                        In order to develop an android application ,we requires Google API.That is  inside the Build Target block.So select an API.


After selecting all these,we should specify our package name.package name is used for distinguishing our current project from other projects(eg:"com.study.tutorial1").Then Select a version and after doing all these ,click "Finish".


NOW YOUR PROJECT IS READY..................
 

Popular Posts

About Me

Only For Sharing Android Related Things...

Facebook Fan Page