Home Blog Page 1921

Intel’s New Fourth-Gen ‘Haswell’ Processors: What You Need to Know (FAQ)

New Intel processors are about to come to desktops, laptops, and tablets near you. Here’s the full rundown on what it all means. [Read more]

 

Read more at CNET News

Cortex-A9 SoC Targets Linux NAS Devices and 802.11ac Routers

Broadcom announced a system-on-chip aimed at network attached storage (NAS) devices and 802.11ac routers, supported by a Linux SDK. The StrataGX BCM5862x Series combines a single- or dual-core 1.2GHz ARM Cortex-A9 processor with a Cortex-R5 based “FlexSPARX” ARM core designed to accelerate storage performance, and features a cryptographic accelerator and dual 6Gbps SATA interfaces. The […]

Read more at LinuxGizmos

IBM Adds DevOps Tools to its Cloud, Mobile Lines

Big Blue is adding tools for log analysis, monitoring, application services and virtualized mobile app testing to its SmartCloud and MobileFirst lineups.

Research: IT Leaders Slow to Embrace Software-Defined Networking

Software-defined networking (SDN) is a new concept for many, as confirmed by a recent TechRepublic survey. In this report, find out who is using SDN, why they plan to implement it, and the results they’ve experienced.

Executive’s Guide to Software-Defined Networking (Free Ebook)

SDN holds great promise for our increasingly overtaxed networks. Learn how SDN works, how it’s being used, and what lies ahead for this transformative technology.

Attack of the Intel-powered Androids!

Several Android tablets running on Intel Clover Trail+ Atom processors broke cover at Computex Taiwan. Intel’s dual-core, 1.6GHz Atom Z5260 is fueling a Samsung Galaxy Tab 3 10.1 tablet, as well as Asus’s 6-inch Fonepad Note and 10-inch MemoPad FHD10 tablets, while Asus also unveiled a hybrid 11.6-inch Transformer Book Trio, combining an Android slate […]

Read more at LinuxGizmos

ARM Aims Speedy, Power-Stingy Cortex-A12 at Mid-Range Mobiles

ARM announced a 28nm-fabricated Cortex-A12 processor design claimed to offer 40 percent higher performance than the Cortex-A9, while drawing the same power. The Cortex-A12 is paired with a power-efficient Mali-T622 GPU and Mali-V500 video coprocessor, and supports hybrid Big.Little SoC configurations in partnership with the Cortex-A7. Billed as a successor to the popular Cortex-A9 processor, […]

Read more at LinuxGizmos

30 Linux Kernel Developer Workspaces in 30 Weeks: Steve Rostedt

We’re back this Monday with our second profile (see the first one with Greg KH here) in the latest edition of 30 Linux Kernel Developers in 30 Weeks. This series focuses on the workspaces used by Linux kernel developers and aims to take us a little closer into the ways that some of the world’s best software developers do their work.

This week we talked to Steve Rostedt, who works for Red Hat and maintains the stable Linux kernel releases of the real-time patch. A huge thanks to Steve for taking us deep inside his office with this video and giving us a sense of how he approaches the magic and the madness of Linux kernel development.

https://www.youtube.com/watch?v=04VpdhLccqk?rel=0″ allowfullscreen=”true” frameborder=”0″ width=”375″ height=”309

What do you like most about your work space?

My chair. Well, I’ve had lots of chairs over the years, and I loved every one of them. They require arm rests, because I like to do arm chair push ups where I lift my legs straight out and then use the arm rests to push my body upward. This probably explains why I need to constantly replace my chairs, as they don’t last very long.

As I also spend too much time in my office, a comfortable chair is very important. I don’t like the fluffy lazy boy type. I like a firm back rest but also a switch that lets the chair rock.

What do you like least?

The mess.  I’m horrible at keeping a clean office. I work on different things all the time and take things out and never put them back. I eventually get overwhelmed and break down and straighten everything up. But that just lasts a couple of days before things are all over the floor again.

My wife is a neat freak and told me that as long as my mess does not extend out into the rest of the house (I have a home office, if that wasn’t obvious), she doesn’t care how my office looks.

What’s the oddest workspace you’ve ever used?

When I worked for TimeSys, I had to go down to its Pittsburgh office and had to work on one of its machines that was kept in a small room. As it did not have a remote terminal, I had to be at the machine. Since there were no chairs in the room, we had to make use of the machines around us for chairs and tables. I sat on one machine with my laptop on another (taller) machine as a desk.

Is there a particular item in your workspace that we should know about?

Hmm, I guess the strangest thing in my office is the remains of my beloved dog Angel (a bull terrier). When we had to put her down (she had cancer) I had her cremated. I was given her remains and never buried her. She’s sat on top of my cabinet for as long as I’ve worked in my current office.

 

 

How to Call the Camera in Android App Development

Calling the camera on Android

One of the great things about modern mobile phones is the increasingly good onboard camera. The Android API gives you seamless access to the camera from any other app, giving you plenty of scope to enhance existing apps or create new ones.

There are two basic approaches to camera access: you can use an Intent to call the default camera app, or you can use the API to build your own camera Activity. The second is more flexible, but also requires more work to code. Often it’s fine just to use the default app, and that’s what we’ll cover in this tutorial.

Our example app will be pretty basic, just to illustrate the idea. We’ll have a button, which we click to launch a camera intent, then we’ll show the returned picture. As explained in a previous tutorial, Intents are used by Android to pass messages within and between Activities and modules. Here, our Intent will pass a message to and from the onboard Camera.

Setting up

Once you’ve created your project, and before you start coding, you’ll need to edit your manifest (AndroidManifest.xml) to add permission to use the camera and external storage, and to add a note that this app uses the Camera feature:

<manifest .... >
  <uses-permission android:name="android.permission.CAMERA" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-feature android:name="android.hardware.camera" />

Next, set up the XML display (in activity_call_camera.xml) to show a button and an image:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" >
    <Button
        android:id="@+id/button_callcamera"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="18dp"
        android:text="@string/get_photo" />
    <ImageView
        android:id="@+id/photo_image"
        android:contentDescription="will vary; image taken from camera"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/button1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="80dp"
        android:src="/@drawable/ic_launcher" />
</RelativeLayout>

Calling the Camera with Intent

Now, set up your single Activity:

public class CallCamera extends Activity {
	
  private static final String TAG = "CallCamera";
  private static final int CAPTURE_IMAGE_ACTIVITY_REQ = 0;
	
  Uri fileUri = null;
  ImageView photoImage = null;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_call_camera);
    photoImage = (ImageView) findViewById(R.id.photo_image);
        
    Button callCameraButton = (Button) findViewById(R.id.button_callcamera);
    callCameraButton.setOnClickListener(new View.OnClickListener() {
      public void onClick(View view) {
        Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        File file = getOutputPhotoFile();
        fileUri = Uri.fromFile(getOutputPhotoFile());
        i.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
        startActivityForResult(i, CAPTURE_IMAGE_ACTIVITY_REQ );
      }
    });
  }
}

We’re using startActivityForResult(), because we want a result (the photo file) returned to our Activity when the camera is done. This means that we need to hand in a URI to give the Camera somewhere to save the photo. (See a little further down for why fileUri, annoyingly, needs to be a class variable.)

The getOutputPhotoFile() method looks like this:

private File getOutputPhotoFile() {
  File directory = new File(Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_PICTURES), getPackageName());
  if (!directory.exists()) {
    if (!directory.mkdirs()) {
      Log.e(TAG, "Failed to create storage directory.");
      return null;
    }
  }
  String timeStamp = new SimpleDateFormat("yyyMMdd_HHmmss", locale.UK).format(new Date());
  return new File(directory.getPath() + File.separator + "IMG_"  
                    + timeStamp + ".jpg");
}

This gives your photo a sensible and standard (time-linked) name, and uses the system-preferred picture storage directory for your device.

Finally, we need to deal with the result when it returns to the activity. This is our onActivityResult():

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQ) {
    if (resultCode == RESULT_OK) {
      Uri photoUri = null;
      if (data == null) {
        // A known bug here! The image should have saved in fileUri
        Toast.makeText(this, "Image saved successfully", 
                       Toast.LENGTH_LONG).show();
        photoUri = fileUri;
      } else {
        photoUri = data.getData();
        Toast.makeText(this, "Image saved successfully in: " + data.getData(), 
                       Toast.LENGTH_LONG).show();
      }
      // showPhoto(photoUri);
    } else if (resultCode == RESULT_CANCELED) {
      Toast.makeText(this, "Cancelled", Toast.LENGTH_SHORT).show();
    } else {
      Toast.makeText(this, "Callout for image capture failed!", 
                     Toast.LENGTH_LONG).show();
    }
  }
}

 

You’ll notice that comment about a known bug. What should happen is that the image URI should be returned by the Intent. However, some older devices (including mine) do save the file in the requested location, but send back a null Intent. The workaround is to save the location (fileUri) and use that if we get an “OK” result code but no image location data. If you run this code as-is, it should work, but you’ll only get Toast messages on return.

 

Showing the Image

Now, let’s show the returned image. Uncomment the showPhoto() line in the method above, and add a showPhoto() method:

private void showPhoto(Uri photoUri) {
  File imageFile = new File(photoUri);
  if (imageFile.exists()){
     Bitmap bitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath());
     BitmapDrawable drawable = new BitmapDrawable(this.getResources(), bitmap);
     photoImage.setScaleType(ImageView.ScaleType.FIT_CENTER);
     photoImage.setImageDrawable(drawable);
  }       
}

Run the code, and you should see the photo shown beneath the ‘get photo’ button when you return from the Camera.

Improvements and bug fixes

If you click the button a second time and take a second photo, the old photo should be replaced by your new one… but in fact, if you try it, depending on your device you may be faced with an OutOfMemoryError. To fix this, add this line in showPhoto(): private void showPhoto(Uri photoUri) { if (imageFile.exists()){ ((BitmapDrawable)photoImage.getDrawable()).getBitmap().recycle(); //… as before } }

Finally, you might have noticed that initially when you fire up the code, you get a little Android robot where the image should be. To fix this and just show nothing, add a line in onCreate():

photoImage = (ImageView) findViewById(R.id.photo_image);
photoImage.setImageDrawable(null);

You’ll also need to make some changes in showPhoto() to avoid a NullPointerException:

private void showPhoto(Uri photoUri) {
  if (imageFile.exists()){
    Drawable oldDrawable = photoImage.getDrawable();
    if (oldDrawable != null) { ((BitmapDrawable)oldDrawable).getBitmap().recycle(); }
    // rest as before
  }       
}

One last issue: depending on your device, the image may also be rotated on your screen. Unfortunately this is a little complicated to fix, largely because of the memory cost of rotating bitmaps, and is outside the scope of this tutorial. If you want to explore this further, you can use the EXIF information to find the rotation, and BitmapFactory to reduce the overhead of handling bitmaps. A little later in this tutorial series, I’ll look at manipulating bitmaps and images; the next tutorial in the series, though, will take a closer look at the Camera API and at building your own camera app.

Backup, Recovery, Migrations in a Virtual Environment

A conversation with Vision Solutions’ Tim Laplante started with a briefing on Double Take 7 and ended up with discussion of platforms, approaches to disaster recovery and more.