Stream

#BuildBetterApps
Best of

Said Tahsin Dane

Shared publicly  - 
 
Developing for Direct Boot

For some apps that schedule alarms and receive messages, delivering timely notifications is critical. With Android N, we’re introducing the option for apps to run before the user unlocks the device after a reboot, so your users will never miss that important alarm clock in the morning.

In the recently released Android N Developer Preview 2, we’ve changed the names of some methods and Intents related to Direct Boot to better reflect their actual behavior. For example: Context.createDeviceEncryptedStorageContext() is now Context.createDeviceProtectedStorageContext() and PackageManager.MATCH_ENCRYPTION_AWARE is now PackageManager.MATCH_DIRECT_BOOT_AWARE.

Check out our blog post (http://goo.gl/8Z7QWd) to learn more and remember to #BuildBetterApps!
7 comments on original post
1
Add a comment...

Juarez Junior

Shared publicly  - 
 
How to Camera2 - @Android Dev Patterns

+Google Developer #BuildBetterApps
1

Somasundaram Mahesh

Shared publicly  - 
 
A app which works offline lives in every phone. #BuildBetterApps #AndroidDev
1
Add a comment...

Suckup.de - IT-Blog

Shared publicly  - 
 
RT @AndroidDev: Pro-tip from @dontmesswithjo: The best app architecture is one that is designed for offline. Srsly. http://bit.ly/1TBOogw #BuildBetterApps
1
Add a comment...

GDG Geneva

Shared publicly  - 
 
Pro-tip from @dontmesswithjo: SharedPreferences for simple storage makes your life SO MUCH EASIER https://goo.gl/eAj3Hw #BuildBetterApps · Medium. Embedded image. SharedPreferences is your answer to simple storage — Google Developers. Most apps have some sort of user state that they'd like to ...
1
Add a comment...

Google Developers

Shared publicly  - 
 
+Timothy Jordan is in London gathering some great resources to help you #BuildBetterApps and webpages. Join him in this all new holiday-edition of #DevShow!
https://goo.gl/OdNT4e
61
10
Money Press News Business Finance Personal's profile photoGabriel Morales's profile photoroberto benedito Ismael's profile photoWin Lwin Tun's profile photo
3 comments
 
Thanks and Happy Holidays!
Add a comment...

Android Developers

Shared publicly  - 
 
MediaBrowserServiceCompat and the modern media playback app
Pro-tip by +Ian Lake

Media playback apps benefit greatly from being tightly integrated into the system and devices such as Android Auto and Android Wear, but these don’t need to one off integrations. Using MediaBrowserServiceCompat you can take advantage of a single communication protocol between your media playback service and your UI, Android Auto, and Android Wear.

Check out our blog post (https://goo.gl/e8udCG) for all the details on how it all works and how you can use it to #BuildBetterApps
A common protocol between your service and your UI, Android Auto, and Android Wear
132
35
liam mason's profile photoJimmy Leonardo's profile photoVymack Ollero's profile photoJoe Rowe's profile photo
2 comments
 
FWIW, the documentation for MediaBrowserServiceCompat and related classes isn't out quite yet - it works just like the non-Compat versions so feel free to use that documentation in the short term or look at the source and Javadoc in your <android-sdk>/extras/android/m2repository/com/android/support/support-v4/23.2.0 directory.
Add a comment...

Android Developers

Shared publicly  - 
 
Unique Identifiers: There’s a better way with Instance ID
Pro-tip by +Joanna Smith

There are plenty of reasons you’d want to track your app on a device. But unless you’re a wireless carrier, I’m willing to bet that what you really want is to track installations. Because if you’re focusing on the device, you’re doing it wrong. After all, if I factory-reset my tablet and give it to my sister as a hand-me-down, and then she also installs your app, that is a different user story.

One example of being device-focused is using MAC addresses, since they are globally unique and persist across factory resets. But they clearly aren’t great for user identification (see my super-nice sister gift above) and now you’ll find that on Android 6.0, there is no programmatic access to either Wi-Fi or Bluetooth addresses.

And now, I’d like to direct your attention to the Instance ID (https://goo.gl/GheDzP), which provides a unique identifier for each instance of your app, enabling you to identify and track your app instances around the world. Which solves the problem of all those super-nice sisters out there.

But the Instance ID API can also generate security tokens that can authorize third parties to access server-side resources, like sending messages with Google Cloud Messaging. With the help of the Instance ID service (https://goo.gl/LyLlYp), it can verify the authenticity of apps distributed through Google Play, so that your server can trust this Android client. And the Instance ID service can even tell you if the app device is active, which will help your app make decisions about whether to re-engage with users. If the device hasn’t been used in a month, maybe you don’t want to bother with that push message.

If you prefer to manage your unique identifiers in your own way, might I recommend a GUID (globally unique ID)? They are simple to make, if you use the UUID Android API (http://goo.gl/jeEaWy) and call randomUUID(). You’ll need to store it yourself, in internal storage, to protect the GUID across applications.

One of these two options will probably solve the majority of your needs, but there are a few special cases. So I have more recommendations for you!
+For user profiling and ads, use Advertising ID (https://goo.gl/Z1pmhY).
+For content protection, check out the Widevine/DRM Plugin (https://goo.gl/cvT0W2).
+For abuse prevention, go with the SafetyNet API (https://goo.gl/SxxRyG).
+And if you are actually trying to do telephony, then do not let me get in the way of your IMEI. You do you.

#BuildBetterApps
320
154
Brian Pow's profile photoGiovanni Laquidara's profile photoebrahim samadi's profile photomanideep lanka's profile photo
10 comments
Add a comment...

Android Developers

Shared publicly  - 
 
Activity Revival and the case of the Rotating Device
Pro-tip by +Joanna Smith

Where’s the data?? If you want to make sure your Activity state will survive a config change, you’ll need to do a bit of work. (Not too much, though.)

Check the blog post (https://goo.gl/LwUKIg) for more information than you ever believed you’d need, and use it to
#BuildBetterApps
163
58
Andrzej Dmitrenko's profile photoCasey Dhaliwal's profile photoJonathan Nobrega's profile photoจิราวัฒน์ ตันพิรุฬห์'s profile photo
6 comments
 
+Roman Medvid android:id or View.setId() — what matters is that it's there before config change and after.
+Csaba Antal Golubov I know that feel, same story with clipToPadding/clipChildren attributes here.
Add a comment...

Android Developers

Shared publicly  - 
 
Making Apps Accessible

Accessible apps are key to making your Android app work for all users. This video offers a short checklist of must-have accessibility features, that are also a breeze to implement.

#BuildBetterApps

https://goo.gl/zBqIIK
134
29
Ajayi Oluwafikayo's profile photoPaulo Hipolito's profile photoSadie Warburg's profile photoJORGE CALVO's profile photo
4 comments
 
Nice video. Thanks for the knowledge sharing. I am strongly looking forward to see all the 100 Android Development Pattern videos. When will all the videos be available in the YouTube channel?
Add a comment...

Jonas Ragaišis
moderator

Android  - 
 
2 sezonas, 10 trumpų serijų
Android development patterns #BuildBetterApps
1
Add a comment...

Juarez Junior

Shared publicly  - 
 
Layouts, Attributes, and you with +Joanna Smith and +Ian Lake

#BuildBetterApps @googledevs @AndroidDev #Android
1

Somasundaram Mahesh

Shared publicly  - 
 
The whole findviewbyid is replaced with this {pic} #BuildBetterApps 
1
Add a comment...

Google Developers

Shared publicly  - 
 
In this #DevShow interview, +Timothy Jordan talks with Purnima Kochikar (Director of Apps and Games / Business Development on Google Play) at the International Women's Day Summit at Google, about how Google Play can help influence developers to #BuildBetterApps. https://goo.gl/YsaUb6
64
12
Alva Brown's profile photoCharly Prudent's profile photoTejaswin Gargeya Macharla's profile photoGDG Bangalore's profile photo
6 comments
 
Can you ask around for help with y dream have pictures cross sisth do it firemanand firewomen fordec25.needhelp pictures onfabric cross width iam handicap got seizure all my life idid workbat bethdsa care hime houseking for long time.need help with sewing threads .need help with sewing supply.ihope you help.debbie barlogio9939gouldst oakland ca946032344

Add a comment...

Android Developers

Shared publicly  - 
 
Use android:theme and ThemeOverlay to theme specific Views and their descendents
Pro-tip by +Ian Lake

If you’ve ever used the style attribute on a View, you know it can be useful to encapsulate shared styling into a reusable definition. But while styles are local to that view alone, android:theme allows you to override attributes in the Context’s theme for a View and all of its child Views as well. Applying a theme to individual Views was introduced in Android 5.0 Lollipop and AppCompat v22.1.0 (and higher) makes this available to all Views on API 11 and higher.

This is where ThemeOverlays such as ThemeOverlay.AppCompat come in. They are themes built specifically to overlay the base AppCompat theme, changing only certain elements as needed. The ones included by default include:

ThemeOverlay.AppCompat: This is an effectively empty theme that can serve as the basis for any custom ThemeOverlay. Note that it does copy AppCompat attributes such as colorPrimary to the framework android:colorPrimary on API 21+ so don’t forget about it!

ThemeOverlay.AppCompat.Light: A ThemeOverlay that changes background colors, text colors, and highlight colors so that match a Light theme (i.e., light background with dark text)

ThemeOverlay.AppCompat.Dark: A ThemeOverlay that, as you might imagine, changes coloring and text to match a Dark theme (i.e., a dark background with light text)

ThemeOverlay.AppCompat.ActionBar and ThemeOverlay.AppCompat.Dark.ActionBar: ThemeOverlays specific to the ActionBar/Toolbar that also change colorControlNormal to android:textColorPrimary and sets the correct SearchView styling as is expected for those components. These should be used only when you override actionBarTheme in your theme or when set on your Toolbar via android:theme.

So if you’re using a light theme but have a portion of your UI with a dark background, you don’t need to set custom text colors on each view. Just use ThemeOverlay.AppCompat.Dark:

<FrameLayout
    android:background=”@color/dark_background”
    android:theme="@style/ThemeOverlay.AppCompat.Dark”>
  <TextView />
</FrameLayout>

But what if you want to change just one specific attribute, say, colorAccent? That’s a case where ThemeOverlay.AppCompat makes sense. First, add a theme (say, to a themes.xml file in your values folder):

<style name=“CustomAccentOverlay” parent=”ThemeOverlay.AppCompat”>
   <item name="colorAccent">@color/custom_accent</item>
</style>

Then apply it to your View by adding android:theme=”CustomAccentOverlay”. This can be used to override any attribute, allowing you to customize things at a View level where appropriate, giving you one more tool you may need to #BuildBetterApps  
249
111
Michał Białas's profile photoWilliam Guan's profile photoEugene Smykov's profile photoAndranik Azizbekyan's profile photo
36 comments
 
+Soroush Hat - fontFamily isn't a theme attribute (I.e., something you can set at a global level). Instead, that is a style attribute: something that applies to just TextViews (and their subclasses like Button) so you'd need to apply that with the style attribute, not android:theme

See https://chris.banes.me/2014/11/12/theme-vs-style/ for more on themes vs styles
Add a comment...

Android Developers

Shared publicly  - 
 
Better share targets with Direct Share

If sharing is caring, and you care about your users, then clearly you care about Direct Share. (http://goo.gl/6DBcK3) With Marshmallow, Direct Share means that you can define a specific share target so that instead of a share action launching your app, it can instead launch the specific conversation in your app, with the funny meme ready to go in the message text field. That’s basically a two-click share experience, which basically means your users love you. Basically.

So watch the video, check out the sample (http://goo.gl/0LQnVW), and/or read the blog post (https://goo.gl/w1p8c2), but always continue to #BuildBetterApps.
145
43
Haji Arif's profile photoJennifer Lopez's profile photoจิราวัฒน์ ตันพิรุฬห์'s profile photoLogic Heart's profile photo
4 comments
 
This has got to be one of the most underutilized APIs from last years... Not even your own teams use this, so why should others even bother...? (same question as with the recent bottom tabs issue on Material Design)
Add a comment...

Android Developers

Shared publicly  - 
 
Navigation Drawer, DrawerLayout, and NavigationView

Learn how to implement a navigation drawer using DrawerLayout and NavigationView. NavigationView is especially helpful, since it gives you material design styling for free and allows you to populate your navigation drawer based on an XML menu resource.

#BuildBetterApps
243
80
Rodolfo Faquin Della Justina's profile photoPekas Garcia's profile photoVenu Bothsa's profile photoJunaid Rajnal's profile photo
5 comments
 
I wonder why Youtube App for Android changed from NavigationDrawer to Tabs. Sharing insights might help developers. I read somewhere that tabs had more user engagement than navigation drawer.
Add a comment...

Android Developers

Shared publicly  - 
 
Testing App Standby

App Standby is happening. To apps like yours, all across the world. So it helps to know what that means for your app. And that means, dear developer, that you need to test your app. The docs tell you everything you need to know about the new idle modes in Marshmallow. (http://goo.gl/JadYpo) But I’m happy to call out the important bits, for everyone who loves a 2-minute summary.

So watch the video, and read the blog post (https://goo.gl/8sCdVE), and continue to #BuildBetterApps.
163
34
Rodney Galloway's profile photoAdam Hunchak's profile photoRoberto Crisanti's profile photoBagas Rahman's profile photo
5 comments
 
Hey guys are going to be a good time but I think that 3rd party in the morning 
Add a comment...

Android Developers

Shared publicly  - 
 
How to name-drop JobScheduler like a pro
Pro-tip by +Joanna Smith

If you have some heavy work to do, and it doesn’t need to be done RIGHT NOW OMG NOW NOW, then I’m going to kindly ask you to use JobScheduler (http://goo.gl/1mVGiv). Because it’ll get your job done, while using other jobs to intelligently schedule the work to minimize use of the radio, which is a clear battery win. So just do it. Please.

JobScheduler was introduced in Lollipop, and is pretty cool because it doesn’t perform work solely based on time, but rather based on conditions. You can define those conditions when you are creating the job, through the JobInfo object (http://goo.gl/UNma9K). For example, you can use setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED) for jobs that you want to execute when the user is on WiFi. Or you can use setPersisted(true) for jobs that you want to persist across a potential reboot. Or you can read the documentation to see how to play with other criteria you might care about, from back-off policies to time limits for scheduling the job. (Basically, this is where the magic happens, so spend some time getting this right.)

To build that JobInfo object, though, you need two things every time (the criteria are the bonus bits): a job number - to help you distinguish which job this is - and a JobService (http://goo.gl/svz1hR). Your JobService is actually going to be a Service that extends the JobService class. Which means you need to implement a few methods:

+onStartJob() is called by the system when it is time for your job to execute. This is where the one tricky part about JobScheduler exists. Your JobService runs on the main thread. That’s right, the main thread. So use onStartJob() to either perform simple work, or to kick off a background service for complicated work. If you kick off another service, you’ll need to return true, but if you’re done with everything, go ahead and return false.

+onStopJob() is called by the system if the job is cancelled before being finished. Perhaps because the conditions are no longer being met, like the device has been unplugged. So use this for safety checks and clean up. And then return true if you’d like the system to reschedule the job, or false if it doesn’t matter and the job will be dropped.

+_jobFinished() is not a method you override, and the system won’t call it. That’s because you need to be the one to call this method once your service or thread has finished working on the job. This is how to system knows to release your wakelock. If you forget, your app is going to look pretty guilty in the battery stats lineup. jobFinished() takes two parameters: the current job, so that it knows which one we are talking about, and a boolean indicating whether you’d like to reschedule the job. Perhaps your work failed for some reason. This will kick off the JobScheduler’s exponential backoff logic for you (or else the logic you specified in JobInfo).

As with any service, you’ll need to add this to your AndroidManifest.xml. What’s different, though, is that you need to add a permission that will allow this service to be a JobService.
<service
       android:name=".TotallyRealJobService"
       android:permission=“android.permission.BIND_JOB_SERVICE" >
</service>

Finally, you schedule a job using JobScheduler (http://goo.gl/JPdgcO), which you can get from the system. Then, call schedule() using that super perfect JobInfo object that you created, and you are good to go.

Not so scary, is that? There are a lot of pieces, to be sure, and you’ll need to think carefully about when and what should trigger your job. But it’s actually pretty easy to work with. And that means you can now bring it up in conversation without fearing that you’ll suddenly seem uninformed. You go, you! (But, specifically, go #BuildBetterApps .)
154
47
Brian Pow's profile photoJIN DING Pan's profile photoAndrii Trybynenko's profile photoJosé Naves Moura Neto's profile photo
13 comments
Gero G.
+
1
2
1
 
Another permission I have to explain just to save battery? Google, that's how you encourage using this! 
Add a comment...