How I Got Rid Of Moto Camera’s “Camera Error: Please Restart Camera” Problem

Several months ago, the camera app on my Moto G5 Plus phone began to intermittently malfunction when I opened it. Instead of letting me take a picture, I’d get an error message of “Camera Error: Please Restart Camera.” I would close and restart the app four or five times before finally being able to take a picture– by which time I’d have missed the opportunity to capture the picture I’d wanted.

Incredibly frustrating! I tried the suggestions on the support website, but none of them helped and the problem persisted.

Here’s how I finally chose to deal with the problematic Moto Camera app:

  1. Installed Mark Harman’s Open Camera App.
  2. Tested the Open Camera app to make sure it worked properly on my phone (i.e. it takes pictures, uploads them to Google Photos, etc.)
  3. Remove Moto Camera from the Home Screen’s Dock.
  4. Add Open Camera to the Home Screen Dock.
  5. Open the App Drawer, then press & hold on the Moto Camera app until the “App Info” menu item appears.
  6. Click on “App Info” and then click on the “Disable” button.
  7. Confirm you want to disable and uninstall the Moto Camera app.

Your mileage may vary, of course, but my phone camera opens reliably now.

Jack Has Problems With His Dates

A long time ago, Jack needed a function to return a JavaScript date object which represented New Year’s Day for any year which he specified, or for the current year if none was provided.

This is what he came up with:

function getNewYearsDate(yr){

	var nyDate = new Date("");

	if ( typeof yr === "undefined"){
		var tmpDate = new Date();
		yr = tmpDate.getFullYear();
	}

	nyDate.setMonth(0);
	nyDate.setDate(1);
	nyDate.setYear(yr);

	return nyDate;
}

Of course, Jack tested his function carefully . . .

getNewYearsDate(2020);
// returns Wed Jan 01 2020 00:00:00 GMT-0500 (Eastern Standard Time)
getNewYearsDate();
// returns Tue Jan 01 2019 00:00:00 GMT-0500 (Eastern Standard Time)

and seeing the results he expected to see, Jack pushed this change to production where it worked wonderfully for many months.

This morning, Jack identified a need for a similar function which represents July 4th/Independence Day. Because Jack is in a rush, he decides to copy and alter his getNewYearsDate function to handle returning the date for Independence Day in the United States (July 4th).

Here’s what he did:

function getIndependenceDate(yr){
	
	var idDate = new Date("");

	if ( typeof yr === "undefined"){
		var tmpDate = new Date();
		yr = tmpDate.getFullYear();
	}

	idDate.setMonth(6);
	idDate.setDate(4);
	idDate.setYear(yr);

	return idDate;
}

But this time, when he tests his new function, he gets surprising results!

getIndependenceDate()
Tue Jan 01 2019 00:00:00 GMT-0500 (Eastern Standard Time)
getIndependenceDate(2020)
Wed Jan 01 2020 00:00:00 GMT-0500 (Eastern Standard Time)

Can you see why the getNewYearsDate() function works, while the getIndependenceDate() function fails?

If so, how would you alter the getIndependenceDate() function so it returns the correct value?

A Few Quick Thoughts On SiteImprove’s API

I had a chance to work with SiteImprove’s API recently, and wanted to capture my thoughts and impressions while they were still fresh in mind.

First, the documentation was above average. Once you’ve received your API key, you can literally “test drive” particular methods within the documentation, right below the area where that particular method is explained. You see everything, the response, the headers, etc. which comes in handy when you’re troubleshooting an issue.

Second, the “next page link” being included in the results when the amount of matching items exceeds the amount per page (defaults at 10, can be maxed out at 1000). Makes recursive requests dead simple– if the “next link” exists, drop it in as your url variable’s next value, and let your for loop continue. If the “next link” doesn’t exist, break out of your loop. And the “next link” already has the correct url attributes appended to it, so you don’t need to worry about updating it or dealing with page number and items per page in your code.

Ok, so what did I *not* like? SiteImprove uses header responses to convey information about your current rate limit (e.g. 50), how many requests you have remaining (e.g. 25) and the rate reset (e.g. 5 seconds). That’s right: integer, integer, string? Why they didn’t keep the last one an integer and opt for milliseconds (e.g. 5000) is beyond me. But if slicing off the text and converting the result to milliseconds for a sleep() interval is the worst thing I have to complain about, that’s pretty good overall.