Last Updated: October 20, 2016

Tips & tricks android developer should know - part 3

Description: In this post I'm gonna demonstrate some useful tips which we could come handy in our app development life cycle

Also check out Part 1 and Part 2.

So let 's get started.


1. Grant all permissions at once in Marshmallow and above.  

As we know marshmallow compatible apps require permissions. So we normally show permission dialog to the user asking to grant us. That's fine. But every time clicking that 'allow' feels annoying for developers.

So the idea is to allow all the permissions at once without every time clicking the allow button.

Below  shell script will help to make it happen flawlessly.
#!/bin/sh

#add your package_name
PACKAGE=com.app.code2concept

#create array with all the permission you need to enabled    
PKG_ARRAY='android.permission.CALL_PHONE
        android.permission.GET_ACCOUNTS
        android.permission.READ_SMS
        android.permission.READ_CONTACTS
        android.permission.ACCESS_FINE_LOCATION
        android.permission.CAMERA
        android.permission.WRITE_EXTERNAL_STORAGE'

#lets exceute our command
for permissions in $PKG_ARRAY; 
do
 echo $permissions + ' granted'
 adb shell pm grant $PACKAGE $permissions
done

echo 'Bingo its done'
OUTPUT:
$ sh grant_all_permissions.sh
android.permission.CALL_PHONE +  granted
android.permission.GET_ACCOUNTS +  granted
android.permission.READ_SMS +  granted
android.permission.READ_CONTACTS +  granted
android.permission.ACCESS_FINE_LOCATION +  granted
android.permission.CAMERA +  granted
android.permission.WRITE_EXTERNAL_STORAGE +  granted
Bingo its done'

Before


After





2. Battery Historian

Battery historian translate the battery stats into visualization form thereby helping us to figure out whats the cause and how we can optimized our battery usage.

Pre-requisite:
1. 'adb' is configured
2. Devices is detectable using 'adb devices' command
3. Python(2.7)  is install and path is set.

Step 1: Reset the battery stats to fetch fresh info using below
adb shell dumpsys batterystats --reset

Note: Disconnect phone and explore the app for few minutes and connect again

Step 2: Capture 'batterystats' using below command
adb shell dumpsys batterystats > batterystats.txt

Note: The command creates a file name 'batterystats.txt' into the current directory

Step 3: Clone or download the Github repo of 'Battery Historian' from Here. You will find a python script at path '../battery-historian/scripts/historian.py'

Note: You can keep both 'historian.py' and 'batterystats.txt' in the same folder for ease

Step 4: Finally let execute the python script against our 'batterstats.txt' as input as show below
python historian.py batterystats.txt > batterystats.html
This will create 'battertstats.html' fig.1 which we can use to analyse the battery usage as shown HERE.

Historian
fig.1

26 comments :

  1. Really it was an awesome article… very interesting to read…

    hotmail signup process

    ReplyDelete
    Replies
    1. Great Article android based projects

      Java Training in Chennai Project Center in Chennai Java Training in Chennai projects for cse The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training Project Centers in Chennai

      Delete
  2. All that is gold doesn't necessarily have to glitter. Android has been touted as being one of the next big platforms that would knock iPhone of its throne. However, this doesn't seem to be the situation for Android. gerald winata gozali

    ReplyDelete
  3. To discover explicit things or aides for the repair of your portable living arrangement, simply look for your topic on the web. Iphone reparatur

    ReplyDelete
  4. Hi Very Nice Blog I Have Read Your Post it is very Informative and Useful Thanks For Posting and Sharing with us & Your Writing Style is very Nice
    Handy Reparatur

    ReplyDelete
  5. This is very interesting. thanks for that. we need more sites like this. i commend you on your great content and excellent topic choices. mobile app development

    ReplyDelete
  6. thank you for sharing this information with us I am glad to be here and read this information is really very helpful for me

    Skytorrent proxy List
    Worldwidetorrent proxy
    Kickasstorrent proxy
    torrenthoud proxy

    ReplyDelete
  7. I think this is an informative post and it is very useful and knowledgeable. Really its Great Article . A Marketplace local Delivery driver App for woocommerce, Dokan, WCFM, WC vendor etc.

    WCFM driver APP

    ReplyDelete
  8. Very useful Post. I found so many interesting stuff in your Blog especially its discussion. Hire Android developer to build a robust and scalable app suited to your business requirements at the best price.

    hire android developer

    ReplyDelete
  9. Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share. Best Coding Android Wallpapers

    ReplyDelete
  10. Only strive to mention one's content can be as incredible. This clarity with your post is superb! Thanks a lot, hundreds of along with you should go on the pleasurable get the job done. IoT hidden menu

    ReplyDelete
  11. Great things you’ve always shared with us. Just keep writing this kind of posts.The time which was wasted in traveling for tuition now it can be used for studies.Thanks https://casas-de-apuestas.mx/caliente/mobile-app/

    ReplyDelete
  12. I am happy to find this post Very useful for me, as it contains lot of information. I Always prefer to read The Quality and glad I found this thing in you post. Thanks betcris app

    ReplyDelete
  13. I am happy to find this post Very useful for me, as it contains lot of information. I Always prefer to read The Quality and glad I found this thing in you post. Thanks codere app

    ReplyDelete
  14. It will save you TIME! We all value our time and have busy life and full schedules. Mobile Alabama iphone repair shop near me

    ReplyDelete
  15. I think this is an informative post and it is very useful and knowledgeable. Hire WordPress Developer for stunning websites for Affordable web designing and development services.

    hire wordpress developer
    dedicated wordpress developer

    ReplyDelete
  16. I really loved reading your blog. It was very well authored and easy to undertand. Unlike additional blogs I have read which are really not tht good. I also found your posts very interesting. In fact after reading, I had to go show it to my friend and he ejoyed it as well! las mejores casas de apuestas en mexico

    ReplyDelete
  17. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value. Im glad to have found this post as its such an interesting one! I am always on the lookout for quality posts and articles so i suppose im lucky to have found this! I hope you will be adding more in the future... casino caliente app

    ReplyDelete
  18. I like your post. It is good to see you verbalize from the heart and clarity on this important subject can be easily observed... https://my.desktopnexus.com/calientesports.mx/#ProfileComments

    ReplyDelete
  19. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. casas de apuestas deportivas mexico

    ReplyDelete
  20. imToken download wallet imtoken for Android is an easy and secure digital trusted wallet by millions. It supports BTC, ETH, EOS, TRX, CKB, BCH, LTC, DOT, KSM, FIL and many other crypto assets. imtoken下载

    ReplyDelete
  21. This comment has been removed by the author.

    ReplyDelete
  22. Even free Android apps can have a big impact on monitoring your finances. Basically, any tool can have a positive impact on your finances and teaching you how to make the most out of your financial resources. A great way to make sure that you're always going to have access to this help is to have the tools on your phone. Well, if you have an Android phone, the best free Android apps on this list can help you get the most out of your financial resources. subway surfers mod menu

    ReplyDelete
  23. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. Grouphowto

    ReplyDelete
  24. Nice blog, I will keep visiting this blog very often. rebranding

    ReplyDelete
  25. I learn some new stuff from it too, thanks for sharing your information.

    Would you like to create a Dating App like Azar? We have an expert team of people who work on a unity platform and we have experienced as we have worked on various unity game projects. contact us.

    ReplyDelete

Your comments are valuable for us !!!