Saturday, July 22, 2017

DEAL: Best Buy Hosting Black Friday in July Promo, Save $290 on Pixel Phones and Much More

pixel xl reviewBest Buy is hosting a Black Friday in July event, with deals taking place all over its site. For us, the Android nerds, you’ll find savings on a Pixel or Pixel XL through Verizon, with the max savings listed at $290. As detailed on Best Buy, you can grab a Pixel on Verizon with unlimited data for just $358 or $478 without unlimited.
Here’s the lineup of Pixel deals currently at Best Buy.

Google Pixel with Verizon unlimited plan: $358 sale price, $14.92/month for 24 months
Google Pixel without Verizon unlimited plan: $478 sale price, $19.92/month for 24 months
Google Pixel XL with Verizon unlimited plan: $454 sale price, $18.92/month for 24 months
Google Pixel XL without Verizon unlimited plan: $574 sale price, $23.92/month for 24 months

If you are in the mood for something other than a Pixel, you can find a Huawei Watch 2 for $220 ($80 off), Bose SoundSport in-ear headphones for $50 ($50 off) or Bose QuietComfort headphones for $180 ($70 off).
That’s just the start, though, with savings available on TVs, security systems, sound systems, PlayStation VR, and so much more.
Follow the link below to see all of the deals!
Black Friday in July Link
DEAL: Best Buy Hosting Black Friday in July Promo, Save $290 on Pixel Phones and Much More is a post from: Droid Life
DEAL: Best Buy Hosting Black Friday in July Promo, Save $290 on Pixel Phones and Much More

5 best apps like Snapchat

best apps like snapchat featured image
Snapchat is quickly becoming one of the most popular social media platforms. It does really well with the younger generation. In terms of sheer numbers, that’s the generation that most companies want to be a part of. Thus, we’ve seen a lot of companies try to emulate Snapchat to try and cash in on its success. Sometimes it works and sometimes it doesn’t. You’re likely here because you like the idea of Snapchat. However, for whatever reason, you may not like Snapchat itself. There are some options in this space. We focused on two main featuers. The augmented reality and the expiring messages (in both Story form and individual messages). Here are the best apps like Snapchat.
Here are some more social media apps you might like! related_article10 best Facebook apps for Android2 weeks ago related_article10 best Twitter apps for AndroidMarch 6, 2017

FacebookFacebookPrice: FreeDOWNLOAD ON GOOGLE PLAYFacebook does a lot of things. It being a little like Snapchat is one of them. It has a Stories feature. Facebook Stories works a lot like Snapchat Stories. You post a short video or image. Your friends can then see it for the next 24 hours. You can also share with individuals. It's a little clunky to use. It does have to share space with the rest of Facebook. However, if you like the idea but don't want a new social network, Facebook has you covered. It's one of the easier apps like Snapchat. DOWNLOAD ON GOOGLE PLAYFacebookFace SwapFace SwapPrice: FreeDOWNLOAD ON GOOGLE PLAYFace Swap is closer to the augmented reality part of Snapchat. It allows you to take a selfie and then transplant your face onto something else. You can do something goofy like make yourself a statue. The app will even match the texture of the statue. It won't show you any weird hot dogs or sling a dog tongue out when you open your mouth. However, it's a fun way to put your face somewhere else. It's not quite as fun, we admit. However, it's still one of the better apps like Snapchat.DOWNLOAD ON GOOGLE PLAYGoogle AlloGoogle AlloPrice: FreeDOWNLOAD ON GOOGLE PLAYGoogle Allo is Google's latest messaging service. It's actually good for those looking for apps like Snapchat. It has an incognito mode that keeps chats private. It also features self-destructing messages similar to Snapchat. The text messaging part of the app is far more polished. Overall, it works more like WhatsApp but with a couple of Snapchat features. It doesn't have any of the camera or augmented reality features, though. DOWNLOAD ON GOOGLE PLAYInstagramInstagramPrice: FreeDOWNLOAD ON GOOGLE PLAYInstagram is about as close to Snapchat that you can get without it actually being Snapchat. It's a camera-first social network. It lets you send images to individuals that expire. You can even upload video and photo to your Instagram Story that will auto-delete after 24 hours. It has the added bonus of live video support. It works a lot like Facebook's Stories. However, it feels better integrated into Instagram than it does into Facebook. This is one of the better apps like Snapchat and the one we'd recommend you try first.DOWNLOAD ON GOOGLE PLAYInstagramSkypeSkypePrice: FreeDOWNLOAD ON GOOGLE PLAYSkype is quickly joining the ranks of apps like Snapchat. A recent feature (as of 2017) called Highlights is essentially just like Snapchat Stories. You upload whatever you're doing and it disappears after seven days. Behind that is the same Skype that everyone knows about. You can do video calls, text chats, voice chats, and pretty much whatever else you want to do. Microsoft has hit a few snags with the latest round of Skype updates. However, they are working on improving these new features and new UI.DOWNLOAD ON GOOGLE PLAYSkype

Thank you for reading! Here are some final app lists to check out! related_article10 best news apps for AndroidJune 8, 2017 related_article10 best Reddit apps for AndroidDecember 5, 2016
If we missed any great apps like Snapchat, tell us about them in the comments! You can also click here to check out our latest Android app and game lists!

5 best apps like Snapchat

Verizon Admits to Throttling Netflix, Says It Was Just Testing Optimizations

A story that took place earlier this week just blew right open, with Verizon admitting that it has been tampering with video streaming performance of select applications, with the majority of worry being voiced by users of Netflix.
As it has played out, users of Netflix were testing their data on Verizon LTE, using Netflix’s own speed test app and Ookla’s. From what the data showed, Ookla’s speeds came back normal at over 80Mbps, while Netflix’s data, on the same exact phone at the same exact location, appeared to be capped at 10Mbps. Coincidence? It didn’t seem likely, and with this new statement from Verizon, the carrier has essentially admitted to potentially violating Title II.
Here’s the statement provided to Arstechnica from Verizon.
We’ve been doing network testing over the past few days to optimize the performance of video applications on our network. The testing should be completed shortly. The customer video experience was not affected.
While Verizon states that video experience was not affected for customers, that’s not exactly the point. With Title II still in affect, ISPs are required to treat all data equally, regardless of its origin. If Verizon is purposefully throttling (or placing caps on select applications), that’s a no-no.
We’ll update this post as the story unfolds.
// Arstechnica | The Verge
Verizon Admits to Throttling Netflix, Says It Was Just Testing Optimizations is a post from: Droid Life
Verizon Admits to Throttling Netflix, Says It Was Just Testing Optimizations

The Edge Sense Plus app will help you unlock the full potential of your HTC U11


The HTC U11 is probably the most unusual flagship unveiled this year. Not only does its “liquid surface” design look absolutely stunning, but it also comes with a rather unique feature on board – Edge Sense.
You’d be forgiven if you thought the squeezable sides of the HTC U11 are merely a gimmick that no one will use. Quite the opposite, a lot of users have found it to actually be convenient, so you might be glad to know that one developer decided to take the technology a step further.


See also:A closer look at Amazon Alexa on the HTC U11related imageA closer look at Amazon Alexa on the HTC U115 days ago


Allow us to introduce you to Edge Sense Plus – an Android app that takes the squeeze to a whole new level. While the original Edge Sense is quite versatile and can be set to perform a variety of tasks with a short or a long squeeze, Edge Sense Plus adds a number of improvements over the default version.
The most notable addition the app introduces is the double squeeze gesture. This means that users can have a total of three different ways to apply pressure on that gorgeous-looking frame. The squeezes can also be set to result in multiple different actions, depending on whether the handset is lying flat on a surface, or is upright in the user’s hand.


#gallery-1
margin: auto;

#gallery-1 .gallery-item
float: left;
margin-top: 10px;
text-align: center;
width: 33%;

#gallery-1 img
border: 2px solid #cfcfcf;

#gallery-1 .gallery-caption
margin-left: 0;

/* see gallery_shortcode() in wp-includes/media.php */







In case you want to have a custom sound accompanying your squeeze, you can do that too. Any cartoon squeezing noise would be a great fit.
The app can remap Edge Sense to perform a huge number of tasks, such as toggling automatic screen rotation, turning Bluetooth on and off, launching split screen mode and whatnot.
Of course, being a third-party app, Edge Sense Plus does have its issues. Some functions require your device to be rooted, such as toggling NFC or GPS. Others are completely missing – you can’t take a screenshot with the app, for example. The developer promised that the screenshot feature will be added in a future update, but it will only work on rooted handsets. And in order to use all possible features of Edge Sense Plus, you will have to pay a small “premium” fee.



One thing that needs to be clarified here is that Edge Sense Plus will work slightly slower than its default counterpart. The developer made sure to point out that this cannot be fixed, as the app waits for the default Edge Sense input, then processes it, and only then does it carry out its required function.
Just like every third-party app, Edge Sense Plus has both pros and cons. But if you’re looking to expand the possible use cases of Edge Sense and don’t mind a slight delay, make sure to check the app out on Google Play.
GET IT FROM GOOGLE PLAY
The Edge Sense Plus app will help you unlock the full potential of your HTC U11

Are we ready for a smartphone for hardcore gamers?


The gaming phone has had a turbulent history. Be it with the Nokia N-Gage, the Acer Predator 6, or the Sony Ericsson Xperia PLAY, the experiment has never quite worked out. Meanwhile, many dedicated handheld gaming devices have proved successful since the original Game Boy, with the Nintendo Switch as recently as this year once again proving the potential of the gaming handheld.
We reported yesterday on rumors regarding a potential upcoming Razer handset, likely an Android phone, and one possibly targeted at “hardcore gamers.” This is not based on an official statement by Razer — it may release another Windows gaming tablet, for all we know — but it has nonetheless raised an interesting question: given the past failures and recent successes in dedicated mobile gaming hardware, are we finally ready for a smartphone for hardcore gamers?
Casual vs Hardcore
First, it might be necessary to unpack the notions of the “casual” and the “hardcore” gamer. While in the past one might use the length of time spent playing a game/games, the type of gaming system played on, the amount of money invested in gaming, and skill level, as rickety measuring sticks for discerning the type of gamer category a person fits into, these ideas are ultimately flawed. You can have gamers who want to invest time and money in video games, or want to play them well, and simply can’t.


See also:10 best FPS games for Androidrelated image10 best FPS games for AndroidMay 9, 2017


Then there are gamers who gladly straddle these distinctions: I have both completed Dark Souls and spent most of my time this year playing 5-minute stints of Dig Deep!. In which category do I fit?
The terms are nebulous and frequently debated, but for simplicity, I’ll use them in this article. Just consider that when I write hardcore I mean “relating to a desire for depth” rather than “the time one spends playing games” or “skill level.”
The graphics myth
The market for mobile gaming is significant: Google Play Store game download figures tell us that. But current Android phones are already highly capable when it comes to playing the vast majority of games on offer at the Play Store — it would be harder to find a game that a four or so year old phone couldn’t run than one it could.
In other words, if a gamer-focused phone could only take advantage of games in the Google Play Store, it wouldn’t have much more to offer than any other flagship phone (unless it arrives at a comparatively low price, that is or is built with gaming ergonomics).
Better graphics does not guarantee that a product will appeal to a hardcore gamer. You don’t need to have particularly strong hardware to create so-called hardcore experiences. Look at, say, Dwarf Fortress compared to UNKILLED in the screenshots below (that’s UNKILLED on the bottom, there).

Which would you say has “better” graphics. Which would you say is more likely to provide a “hardcore” experience? That’s an obvious example, but if you look back to the likes of the 8-bit NES era you will find games that offer much deeper gameplay than titles found on far more powerful modern smartphones.
Essentially, you can’t have a hardcore gaming device without hardcore games; what’s an Alienware Area 51 that can only play Kitty Cat Clicker?
Opportunities
If a flagship phone and a Bluetooth speaker can already take advantage of what most current mobile games offer on an audio/visual level, what else could a gamer-focused smartphone offer? Here are some suggestions:

Dedicated games
Internet connectivity optimizations to ensure smooth online play
Upgrade options (like swapping out the GPU/CPU)
Additional buttons (shoulder buttons/D-pad)
Mouse/keyboard/controller support
4K display/surround sound?

(Dedicated gaming laptops, like those Razer already manufactures, also usually target features like better battery life, lower-noise, better cooling systems, less weight, and slimmer profiles in each new iteration. But, with the exception of better battery life, these aren’t likely to be important factors in a gaming smartphone.)
Razer may try to implement one or more of the items listed above into a gaming phone, and, of those, control might be one of the better areas on which to focus. Online seems stable enough, CPU/GPU swapping would be difficult, and audio/visual improvements can, as previously discussed, only be taken so far.


See also:10 best card games for Androidrelated image10 best card games for Android5 days ago


Unlike graphics/sound, control really can be a barrier to getting the full experience of a title, creating the difference between playing it and mastering it, and it’s a fundamental concern when porting games to smartphones. Coming from PC or console input to a touchscreen can all but destroy a game, as it lacks the precision of other types of input. It’s to the Nintendo Switch’s credit that it houses a touchscreen and additional controls.
This — better control — is an area where Razer really does have an opportunity to offer something credible to the hardcore smartphone gaming crowd. But a controller’s usefulness also relies on the game: precise control means nothing on a title like Candy Crush and everything on a game like Downwell — and your Downwells are vastly outnumbered in Google Play. Not to mention the haphazard means of even finding controller-supported titles.
Which leads me to dedicated games. This could be Razer’s other route to success as it could try to bring specific titles to the smartphone with hardcore experiences in mind. Developing its own titles, like Netflix, would be expensive and take forever, but Razer could try to encourage developers to make games for its system. Obtaining games that require its Razer Android device to play isn’t out of the question, though — Nvidia has done it. It’s just that, Nvidia is also bringing in billions of dollars in revenue every year thanks to its semiconductor business.

Wrap up
Cards on the table: I don’t think a dedicated gaming smartphone is a smart idea. There are still great strides to be made in mobile gaming, but unless Razer has some grand plan for mobile titles, the most high-performance hardware in the world still wouldn’t be enough to make a dedicated gaming smartphone worthwhile for the majority of people. Not if it only has the games in the Play Store to work with.
There is hope, though. Nvidia has made fine gaming tablets in the SHIELD and SHIELD Tablet K1, providing a dedicated controller, its own games market, streaming/casting, and offering up more Android updates than the majority of other smartphone manufacturers, all at a reasonable price. They also didn’t have that overblown look like many other devices built for gamers. They are tablets, however, products that you might buy as well as a phone. Owning a normal smartphone and a gaming smartphone might be a stretch.


See also:15 best adventure games for Androidrelated image15 best adventure games for Android2 weeks ago


Here’s the crux of the matter: Is there a market for richer, PC- or console-like gaming experiences on mobile? Absolutely. Will premium smartphone hardware deliver that? Not a chance.
I’m still genuinely excited about the future prospects of mobile gaming. Honestly. I just think that if all a Razer phone does is provide a high-priced way to play the myriad piss-poor titles polluting the Play Store, it’s more than likely going to wind up as just another N-Gage. Prove me wrong Razer, please.
Are we ready for a smartphone for hardcore gamers?

Today in Hip Hop History:LL Cool J released his second album...

Today in Hip Hop History:LL Cool J released his second album Bigger And Deffer July 22, 1987
Today in Hip Hop History:LL Cool J released his second album...

All US carriers will offer the Moto Z2 Force, according to leak


The Moto Z2 Force is expected to make a debut very soon, at the #hellomotoworld event in New York City. And while its US version is rumored to be severely limited in comparison with its international brethren, a new tweet from reliable leaker Evan Blass suggests that it might be the first Moto in a while that will be offered by all four major US carriers. Blass had previously tweeted that it would be available on both Verizon and T-Mobile, but that number has now doubled.
While this is certainly good news for US users, wider availability hardly compensates for the fact that they will get the worst specs when buying the Moto Z2 Force. The US version will come with the Snapdragon 835 chipset, Qualcomm’s flagship silicon at the moment, but it will sport only 4 GB of RAM, as opposed to the 6 GB users around the globe will enjoy.

All four US carriers will indeed offer the Moto Z2 Force.
— Evan Blass (@evleaks) July 22, 2017

Additionally, the Moto Z2 Force will come with a smaller battery than its predecessor. The new model will have a 2,730 mAh power pack, as opposed to the 3,500 mAh battery found in the original Moto Z Force. You can expect its slim profile and “software optimizations” to be the reasoning behind that dubious decision, however, the smaller battery might just be a way to make users purchase more power pack mods. 
For existing Moto Z Force owners, the value of upgrading to the new model in the US might be diminished by the lower specs. Especially considering the actual improvements will only be the newer Qualcomm chip, the dual-camera setup and the thinner profile. However, if you didn’t get the Moto Z Force last year, in particular because your carrier didn’t sell it, the new model might be just the thing for you.

If this new information is true, it might mark the end of the Verizon-exclusive Droid editions. As to why Lenovo decided to move away from the Verizon exclusivity, we can only guess.
However, back in February, during MWC, the company explained that it’s seeing massive growth in sales of its Moto Z line, thanks to its Moto Mods. Such growth is somewhat unusual for a device that was already several months old at the time, but the constant introduction of new Moto Mods helps the Moto Z line stay fresh for much longer than its competitors.
“You’ll see us grow by leaps and bounds in the US market,” said Aymar de Lencquesaing, chairman and president of Motorola. Perhaps, expanding carrier availability is one of those leaps.
All US carriers will offer the Moto Z2 Force, according to leak

T-Mobile LG V10 Nougat update finally lands in the US

lg v10Update: The LG V10 Android Nougat update has just hit the US, courtesy of T-Mobile, after first arriving in South Korea in late May. The update weighs a hefty 1.3 GB so be sure to have plenty of battery and available space for the update, and install it only over Wi-Fi. It bumps the V10 software to version H90130b and includes an E911 timer fix as well as delivering all the benefits of Android Nougat alongside the usual stability and performance fixes.

Welcome to the LG V10 Android update tracker page. This article covers all major U.S. carriers with a quick reference table for each and a log with links to further details. We will continue to update it as new information surfaces, but note that we won’t be covering general security patches in our list.
We recommend you bookmark this page so you can stay up to date with the very latest updates.

Android 7.0 Nougat update tracker

LG V10 Android Marshmallow update
The LG V10 received the Marshmallow update internationally as well as in the US in March 2016 (at least on Verizon). All major US carriers have now rolled out the LG V10 Marshmallow update.
LG V10 Android Nougat update
The LG V10 was released in October, 2015, with Android 5.1.1 Lollipop,  Just before it’s two-year birthday, the Android Nougat update landed first in South Korea on May 24, 2017 and hit the US on July 19, 2017 on T-Mobile.
LG V10 Update US




LG V10 updates - USAndroid 5.1.1 LollipopAndroid 6.0 MarshmallowAndroid 7.0 Nougat




VerizonYesYesTBC


AT&TYesYesTBC


T-MobileYesYesYes




Android 7.0 Nougat first available: August 22, 2016
Android 6.0 Marshmallow first available: October 5, 2015

Verizon LG V10 (VS990) update:

March 24, 2017, Verizon becomes the first carrier to roll out Marshmallow to the LG V10.

Number of days it took Verizon to update to Marshmallow: 172
AT&T LG V10 (H900) update:

April 21, 2016, The LG V10 gets Marshmallow on AT&T.

Number of days it took AT&T to update to Marshmallow: 205
T-Mobile LG V10 (H901) update:

April 11, 2016, T-Mobile LG V10 owners begin to receive Marshmallow in the US.
July 19, 2017, T-Mobile becomes the first US carrier to roll out the LG V10 Nougat update.

Number of days it took T-Mobile to update to Marshmallow: 189
Number of days it took T-Mobile to update to Nougat: 331
First carrier to roll out Android Marshmallow for the LG V10: Verizon (172 days)
First carrier to roll out Android Nougat for the LG V10: T-Mobile (331 days)

International LG V10 (H960A) update:

March 9, 2016, Marshmallow starts rolling out to the LG V10 in Europe, beginning in Turkey.
May 24, 2017, The LG V10 Nougat update starts rolling out in South Korea.

If you’ve received an update we’ve missed, hit the comments below or Tip Us!
T-Mobile LG V10 Nougat update finally lands in the US

The wait will soon be over: Andy Rubin’s Essential Phone coming in a “few weeks”


Andy Rubin’s Essential was supposed to ship out the Essential Phone earlier this month, but that time came and passed. In an email sent to potential customers, however, the Android co-creator confirmed the phone will make its debut “in a few weeks.”
According to Rubin, the Essential Phone is currently going through certification and testing with several U.S. and international carriers. Once that is complete, the phone will presumably ship to potential customers after they receive emails that allow them to put in their credit card information.


See also:Essential Phone coming to UK, followed by Western Europe and Japanrelated imageEssential Phone coming to UK, followed by Western Europe and Japan5 days ago


Rubin also wrote that his team worked “long hours” and has been “hard at work” to make sure the Essential Phone makes its way to people’s doorsteps sometime in August.
This will come as welcome news to those who have anticipated the phone since its unveiling back in May. At the time, Rubin said the Essential Phone would ship to potential customers within 30 days of the announcement, though that came and went without much word from Rubin or Essential.
At the very least, Rubin’s email shows that he and his team are confident enough in the Essential Phone’s development to send out such a message in the first place. We also know plenty about the phone itself, such as its flagship-level specs, modular functionality, and $700 price tag. We also know it is possible that the Essential Phone will make its way to the UK, followed by Western Europe and Japan, though no release window was reported.
For now, US fans looking forward to the Essential Phone have one more thing to be excited about once August arrives.
The wait will soon be over: Andy Rubin’s Essential Phone coming in a “few weeks”

How to write your first Android game in Java



There are plenty of ways to create a game for Android and one important way is to do it from scratch in Android Studio with Java. This gives you the maximum control over how you want your game to look and behave and the process will teach you skills you can use in a range of other scenarios too – whether you’re creating a splash screen for an app or you just want to add some animations. With that in mind, this tutorial is going to show you how to create a simple 2D game using Android Studio and the Java. You can find all the code and resources at Github if you want to follow along.
Setting up
In order to create our game, we’re going to need to deal with a few specific concepts: game loops, threads and canvases. To begin with, start up Android Studio. If you don’t have it installed then check out our full introduction to Android Studio, which goes over the installation process. Now start a new project and make sure you choose the ‘Empty Activity’ template. This is a game, so of course you don’t need elements like the FAB button complicating matters.
The first thing you want to do is to change AppCompatActivity to Activity. This means we won’t be using the action bar features.

Similarly, we also want to make our game full screen. Add the following code to onCreate() before the call to setContentView():
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Note that if you write out some code and it gets underlined in red, that probably means you need to import a class. In other words, you need to tell Android Studio that you wish to use certain statements and make them available. If you just click anywhere on the underlined word and then hit Alt+Enter, then that will be done for you automatically!
Creating your game view
You may be used to apps that use an XML script to define the layout of views like buttons, images and labels. This is what the line setContentView is doing for us.
But again, this is a game meaning it doesn’t need to have browser windows or scrolling recycler views. Instead of that, we want to show a canvas instead. In Android Studio a canvas is just the same as it is in art: it’s a medium that we can draw on.
So change that line to read as so:
setContentView(new GameView(this))
You’ll find that this is once again underlined red. But now if you press Alt+Enter, you don’t have the option to import the class. Instead, you have the option to create a class. In other words, we’re about to make our own class that will define what’s going to go on the canvas. This is what will allow us to draw to the screen, rather than just showing ready-made views.
So right click on the package name in your hierarchy over on the left and choose New > Class. You’ll now be presented with a window to create your class and you’re going to call it GameView. Under SuperClass, write: android.view.SurfaceView which means that the class will inherit methods – its capabilities – from SurfaceView.

In the Interface(s) box, you’ll write android.view.SurfaceHolder.Callback. As with any class, we now need to create our constructor. Use this code:
private MainThread thread;

public GameView(Context context)
super(context);

getHolder().addCallback(this);

Each time our class is called to make a new object (in this case our surface), it will run the constructor and it will create a new surface. The line ‘super’ calls the superclass and in our case, that is the SurfaceView.
By adding Callback, we’re able to intercept events.
Now override some methods:
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)



@Override
public void surfaceCreated(SurfaceHolder holder)



@Override
public void surfaceDestroyed(SurfaceHolder holder)


These basically allow us to override (hence the name) methods in the superclass (SurfaceView). You should now have no more red underlines in your code. Nice.

You just created a new class and each time we refer to that, it will build the canvas for your game to get painted onto. Classes create objects and we need one more.
Creating threads
Our new class is going to be called MainThread. And its job will be to create a thread. A thread is essentially like a parallel fork of code that can run simultaneously alongside the main part of your code. You can have lots of threads running all at once, thereby allowing things to occur simultaneously rather than adhering to a strict sequence. This is important for a game, because we need to make sure that it keeps on running smoothly, even when a lot is going on.
 
Create your new class just as you did before and this time it is going to extend Thread. In the constructor we’re just going to call super(). Remember, that’s the super class, which is Thread, and which can do all the heavy lifting for us. This is like creating a program to wash the dishes that just calls washingMachine().

When this class is called, it’s going to create a separate thread that runs as an offshoot of the main thing. And it’s from here that we want to create our GameView. That means we also need to reference the GameView class and we’re also using SurfaceHolder which is contains the canvas. So if the canvas is the surface, SurfaceHolder is the easel. And GameView is what puts it all together.
The full thing should look like so:
public class MainThread extends Thread
private SurfaceHolder surfaceHolder;
private GameView gameView;

public MainThread(SurfaceHolder surfaceHolder, GameView gameView)

super();
this.surfaceHolder = surfaceHolder;
this.gameView = gameView;



Schweet. We now have a GameView and a thread!
Creating the game loop
We now have the raw materials we need to make our game, but nothing is happening. This is where the game loop comes in. Basically, this is a loop of code that goes round and round and checks inputs and variables before drawing the screen. Our aim is to make this as consistent as possible, so that there are no stutters or hiccups in the framerate, which I’ll explore a little later.

For now, we’re still in the MainThread class and we’re going to override a method from the superclass. This one is run.
And it goes a little something like this:
@Override
public void run()
while (running)
canvas = null;

try
canvas = this.surfaceHolder.lockCanvas();
synchronized(surfaceHolder)
this.gameView.update();
this.gameView.draw(canvas);

catch (Exception e) finally
if (canvas != null)
try
surfaceHolder.unlockCanvasAndPost(canvas);
catch (Exception e)
e.printStackTrace();





You’ll see a lot of underlining, so we need to add some more variables and references. Head back to the top and add:
private SurfaceHolder surfaceHolder;
private GameView gameView;
private boolean running;
public static Canvas canvas;
Remember to import Canvas. Canvas is the thing we will actually be drawing on. As for ‘lockCanvas’, this is important because it is what essentially freezes the canvas to allow us to draw on it. That’s important because otherwise, you could have multiple threads attempting to draw on it at once. Just know that in order to edit the canvas, you must first lock the canvas.
Update is a method that we are going to create and this is where the fun stuff will happen later on.
The try and catch meanwhile are simply requirements of Java that show we’re willing to try and handle exceptions (errors) that might occur if the canvas isn’t ready etc.
Finally, we want to be able to start our thread when we need it. To do this, we’ll need another method here that allows us to set things in motion. That’s what the running variable is for (note that a Boolean is a type of variable that is only ever true or false). Add this method to the MainThread class:
public void setRunning(boolean isRunning)
running = isRunning;

But at this point, one thing should still be highlighted and that’s update. This is because we haven’t created the update method yet. So pop back into GameView and now add  method.
public void update()


We also need to start the thread! We’re going to do this in our surfaceCreated method:
@Override
public void surfaceCreated(SurfaceHolder holder)
thread.setRunning(true);
thread.start();


We also need to stop the thread when the surface is destroyed. As you might have guessed, we handle this in the surfaceDestroyed method. But seeing as it can actually take multiple attempts to stop a thread, we’re going to put this in a loop and use try and catch again. Like so:
@Override
public void surfaceDestroyed(SurfaceHolder holder)    
boolean retry = true;   
while (retry)        
try            
thread.setRunning(false);           
thread.join();    
catch (InterruptedException e)        
e.printStackTrace();   
   
retry = false;


And finally, head up to the constructor and make sure to create the new instance of your thread, otherwise you’ll get the dreaded null pointer exception! And then we’re going to make GameView focusable, meaning it can handle events.
thread = new MainThread(getHolder(), this);
setFocusable(true);
Now you can finally actually test this thing! That’s right, click run and it should actually run without any errors. Prepare to be blown away!

It’s… it’s… a blank screen! All that code. For a blank screen. But, this is a blank screen of opportunity. You’ve got your surface up and running with a game loop to handle events. Now all that’s left is make stuff happen. It doesn’t even matter if you didn’t follow everything in the tutorial up to this point. Point is, you can simply recycle this code to start making glorious games!
Doing a graphics
Right, now we have a blank screen to draw on, all we need to do is draw on it. Fortunately, that’s the simple part. All you need to do is to override the draw method in our GameView class and then add some pretty pictures:
@Override
public void draw(Canvas canvas)         
super.draw(canvas);       
if (canvas != null)            
canvas.drawColor(Color.WHITE);           
Paint paint = new Paint();           
paint.setColor(Color.rgb(250, 0, 0));           
canvas.drawRect(100, 100, 200, 200, paint);       
   

Run this and you should now have a pretty red square in the top left of an otherwise-white screen. This is certainly an improvement.

You could theoretically create pretty much your entire game by sticking it inside this method (and overriding onTouchEvent to handle input) but that wouldn’t be a terribly good way to go about things. Placing new Paint inside our loop will slow things down considerably and even if we put this elsewhere, adding too much code to the draw method would get ugly and difficult to follow.
Instead, it makes a lot more sense to handle game objects with their own classes. We’re going to start with one that shows a character and this class will be called CharacterSprite. Go ahead and make that.
This class is going to draw a sprite onto the canvas and will look like so
public class CharacterSprite
private Bitmap image;

public CharacterSprite(Bitmap bmp)
image = bmp;    


public void draw(Canvas canvas)
canvas.drawBitmap(image, 100, 100, null);


Now to use this, you’ll need to load the bitmap first and then call the class from GameView. Add a reference to private CharacterSprite characterSprite and then in the surfaceCreated method, add the line:
characterSprite = new CharacterSprite(BitmapFactory.decodeResource(getResources(),R.drawable.avdgreen));
As you can see, the bitmap we’re loading is stored in resources and is called avdgreen (it was from a previous game). Now all you need to do is pass that bitmap to the new class in the draw method with:
characterSprite.draw(canvas);
Now click run and you should see your graphic appear on your screen! This is BeeBoo. I used to draw him in my school textbooks.

What if we wanted to make this little guy move? Simple: we just create x and y variables for his positions and then change these values in an update method.
So add the references to your CharacterSprite and then then draw your bitmap at x, y. Create the update method here and for now we’re just going to try:
y++;
Each time the game loop runs, we’ll move the character down the screen. Remember, y coordinates are measured from the top so 0 is the top of the screen.  Of course we need to call the update method in CharacterSprite from the update method in GameView.

Press play again and now you’ll see that your image slowly traces down the screen. We’re not winning any game awards just yet but it’s a start!
Okay, to make things slightly more interesting, I’m just going to drop some ‘bouncy ball’ code here. This will make our graphic bounce around the screen off the edges, like those old Windows screensavers. You know, the strangely hypnotic ones.
public void update() (x & lt; 0))
xVelocity = xVelocity * -1;

if ((y & gt; screenHeight - image.getHeight())
You will also need to define these variables:
private int xVelocity = 10;
private int yVelocity = 5;
private int screenWidth = Resources.getSystem().getDisplayMetrics().widthPixels;
private int screenHeight = Resources.getSystem().getDisplayMetrics().heightPixels;
Optimization
There is plenty more to delve into here, from handling player input, to scaling images, to managing having lots of characters all moving around the screen at once. Right now, the character is bouncing but if you look very closely there is slight stuttering. It’s not terrible but the fact that you can see it with the naked eye is something of a warning sign. The speed also varies a lot on the emulator compared to a physical device. Now imagine what happens when you have tons going on on the screen at once!
There are a few solutions to this problem. What I want to do to start with, is to create a private integer in MainThread and call that targetFPS. This will have the value of 60. I’m going to try and get my game to run at this speed and meanwhile, I’ll be checking to ensure it is. For that, I also want a private double called averageFPS.
I’m also going to update the run method in order to measure how long each game loop is taking and then to pause that game loop temporarily if it is ahead of the targetFPS. We’re then going to calculate how long it now took and then print that so we can see it in the log.
@Override
public void run()    
long startTime;   
long timeMillis;   
long waitTime;   
long totalTime = 0;   
int frameCount = 0;   
long targetTime = 1000 / targetFPS;
   
while (running)        
startTime = System.nanoTime();       
canvas = null;
       
try            
canvas = this.surfaceHolder.lockCanvas();           
synchronized(surfaceHolder)                
this.gameView.update();               
this.gameView.draw(canvas);           
       
catch (Exception e)               
finally            
if (canvas != null)                           
try                    
surfaceHolder.unlockCanvasAndPost(canvas);               
               
catch (Exception e)
e.printStackTrace();
           
       

       
timeMillis = (System.nanoTime() - startTime) / 1000000;       
waitTime = targetTime - timeMillis;
       
try            
this.sleep(waitTime);       
catch (Exception e)
       
totalTime += System.nanoTime() - startTime;       
frameCount++;       
if (frameCount == targetFPS)                   
averageFPS = 1000 / ((totalTime / frameCount) / 1000000);           
frameCount = 0;           
totalTime = 0;           
System.out.println(averageFPS);       
   



Now our game is attempting to lock it’s FPS to 60 and you should find that it generally measures a fairly steady 58-62 FPS on a modern device. On the emulator though you might get a different result.

Try changing that 60 to 30 and see what happens. The game slows down and it should now read 30 in your logcat.
Closing Thoughts
There are some other things we can do to optimize performance too. There’s a great blog post on the subject here. Try to refrain from ever creating new instances of Paint or bitmaps inside the loop and do all initializing outside before the game begins.

If you’re planning on creating the next hit Android game then there are certainly easier and more efficient ways to go about it these days. But there are definitely still use-case scenarios for being able to draw onto a canvas and it’s a highly useful skill to add to your repertoire. I hope this guide has helped somewhat and wish you the best of luck in your upcoming coding ventures!
How to write your first Android game in Java

Last chance for 15% off the Ticwatch 2



Maybe the techie in you wants a smartwatch, but it can be hard to justify a $300+ layout when it’s got the same functionality as your smartphone. How about this for a compromise – The Ticwatch 2 Active Smartwatch. Functionality meets affordability.
This kickstarter success is a super sleek piece of tech, and has all the features that you would expect of a Smartwatch: tracking your steps and heart-rate, getting text notifications, gesture control, GPS tracking, etc. Perfect for your workout. It even has 4GB internal storage space for all your tunes.
Functionality meets affordability.
And like the top level Smartwatches, the TicWatch 2 can even be used to make and receive calls. So when you’re out on that jog you can ruin all your hard work by ordering a pizza for when you get home.
Sure it’s powerful and functional, but what the folks at Ticwatch really delight in is the ease of use. Here’s what a few of the reviewers said about it:
‘Mobvoi proves that smartwatches can – and should be – powerful and affordable at the same time,’ – CNN
‘Simple, clean design,’ – Engadget
‘The Ticwatch 2 is a breath of fresh air for smartwatches with its sleek design, slick interface, and low price,’ – Digital Trends
The Ticwatch 2 usually retails at $200, but for the next few days you can get the charcoal and snow models for just $169.99. A lot easier to justify in your budget.
This is your last chance to take up this offer before the price springs back, so to take advantage hit the button below.
check it out!
Is this deal not quite right for you? Head over to the AAPICKS HUB for more savings you’re going to love! For notifications of offers and price drops, sign up for our Deal Alerts newsletter.
We may get a small percent from purchases made through our posts. However, the AA Picks team only showcases verified, legitimate deals. It’s a nice way to help keep the lights on around here, and it decreases our reliance on pesky ads. If you have questions or concerns, please reach out at aapicks@androidauthority.com.
Last chance for 15% off the Ticwatch 2