2015年12月3日星期四

Push and install APK to different on PC connected devices

There's one classical problem for multi-devices that connect onto PC when we develop Android. You cannot push or install apk by command-line when more than one on it. Fine you can use two steps to do this:

1. Find devices:
    # adb devices -list

2. Select  one or more serial-numbers in your head.

3. Run:
   #  adb -s serial-number install -r  ../asdfasdf/hello.apk

That works but only for one device.

I've packed this command in to a batch and we can do with more than one devices.

Just run:  
   # installapk --all ../asdfasdf/hello.apk 
or
  # installapk serial-number serial-number serial-number serial-number ../asdfasdf/hello.apk 


Try and fork it.

P.S There's also a program to uninstall application from devices.
The command-line to uninstall app is easy like install by instead typing path of apk by package name:

# uninstallapp --all com.helloworld
or
# uninstallapp 23445345sdf sdffsdg com.helloworld

Try



2015年11月30日星期一

Should I move API level to 14

It is an interesting question.  Some % is still in the list of current version fragments.

Is it a real time to switch normal development to API 14 (android 4.0) ?


2015年11月28日星期六

Permissions type: what "must" be done and "can" be done.

If we develop with SDK >= android 6.x (target 2.3 or above) then we need permission check before application starts. It is so nice for user to let them know what the application needs, however for developer is f"x", because the codes need refactoring. There're some "know-how" to do this, even with some 3rd libraries can simplify the functions like https://github.com/hotchemi/PermissionsDispatcher .


I used this library in my projects for permission check for android 6.x.  However there's two parts of permissions which we can be granted. First one are normal ones that only should be declared in mainfest like before  (PROTECTION_NORMAL). The other part of it is the ones that not only be written in mainfest but also in your Java codes to test. Like with PermissionDispatcher you must give user system build-in popup to grant next route.


Automatically granted permissions :

android.permission.ACCESS_LOCATION_EXTRA_COMMANDS
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_NOTIFICATION_POLICY
android.permission.ACCESS_WIFI_STATE
android.permission.ACCESS_WIMAX_STATE
android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN
android.permission.BROADCAST_STICKY
android.permission.CHANGE_NETWORK_STATE
android.permission.CHANGE_WIFI_MULTICAST_STATE
android.permission.CHANGE_WIFI_STATE
android.permission.CHANGE_WIMAX_STATE
android.permission.DISABLE_KEYGUARD
android.permission.EXPAND_STATUS_BAR
android.permission.FLASHLIGHT
android.permission.GET_ACCOUNTS
android.permission.GET_PACKAGE_SIZE
android.permission.INTERNET
android.permission.KILL_BACKGROUND_PROCESSES
android.permission.MODIFY_AUDIO_SETTINGS
android.permission.NFC
android.permission.READ_SYNC_SETTINGS
android.permission.READ_SYNC_STATS
android.permission.RECEIVE_BOOT_COMPLETED
android.permission.REORDER_TASKS
android.permission.REQUEST_INSTALL_PACKAGES
android.permission.SET_TIME_ZONE
android.permission.SET_WALLPAPER
android.permission.SET_WALLPAPER_HINTS
android.permission.SUBSCRIBED_FEEDS_READ
android.permission.TRANSMIT_IR
android.permission.USE_FINGERPRINT
android.permission.VIBRATE
android.permission.WAKE_LOCK
android.permission.WRITE_SYNC_SETTINGS
com.android.alarm.permission.SET_ALARM
com.android.launcher.permission.INSTALL_SHORTCUT
com.android.launcher.permission.UNINSTALL_SHORTCUT

Just simply declare those permissions in AndroidManifest.xml and it will work just fine. No need to check for the permission listed above since it couldn't be revoked.

The permissions must be checked:



2015年11月20日星期五

Debug with wifi for android dev

  1. Connect device via USB and make sure debugging is working.
  2. adb tcpip 5555
  3. adb connect <DEVICE_IP_ADDRESS>:5555
  4. Disconnect USB and proceed with wireless debugging.
  5. adb -s <DEVICE_IP_ADDRESS>:5555 usb to switch back when done.

2015年11月17日星期二

IT Books 3.0 released

New version includes Google Login, Google Drive to save books,  Material Design on detail-view.

The new Google Login by new Google SigIn API  which provides easy way to connect on Google. A lot confused codes are removed when login and new thinking of App-Flow is created:

1. App start without account.
2. Some features depending on account will be first hidden or unavailable.
3. App connects to account.
4. Features will be opened.


Google Drive is a very nice place to save data background permanently.  With integration of Drive SDK Android  we can implement  backup very easily.  The SDK controls whole upload and download process as user doesn't take any care on network transactions. The only ones to do is success-handling and error-handling to info UI.


To the detail-view the CoordinatorLayout is used to replace my own implement. The standard behavior with FAB and progress-toast cooperate downloading process dynamically.  Checkout a simple sample of  CoordinatorLayout here https://github.com/chrisbanes/cheesesquare

IT Books 3.0


P.S App has a new icon now :)