Profile

Cover photo
Kiran Rao
Lives in Bangalore, India
208 followers|139,180 views
AboutPostsPhotosVideos

Stream

Kiran Rao

Shared publicly  - 
 
1. Convert an Android application module to an Android library module
2. Forget that R.id.xyz and other R values are NOT constants in library modules
3. Run into compile error that clearly says "Constant value required" at

switch(menutItem.getItemId()){
  case R.id.menu_settings:
    //some super-awesome code here
}

4. Somehow completely ignore this error. Instead, notice that the import for ActionBarActivity has not resolved correctly.
5. Spend hours solving the wrong problem - trying to get that ActionBarActivity import to resolve.
6. KickSelf

P.S.: The fix was to replace the switch case with if-else:

int itemId = menuItem.getItemId();
if(R.id.menu_settings == itemId) {
  //Some super-awesome code here
}

I'm beginning to think it is a best practice to never use R.id.xyz constants in switch cases. Always prefer is-else where such values are involved. You'll save yourself some frustration should you ever need to convert those modules into libraries.
4
1
Frank Harper's profile photo
Add a comment...

Kiran Rao

Shared publicly  - 
 
Just realized that you cannot use Butterknife in library projects. I understand the reasoning behind the decision.

That said, we have a few screens that we use in multiple apps and it really makes sense to pull them out into a library. We have decided to stick with our code organization , place our common screens in the library project and use findViewById in there.

The take-away: Do not change your code organization/architecture for the sole purpose of accommodating a library - unless the library is specifically meant for such purposes (example - Dagger). Butterknife is a convenience library - a nice-to-have. But not a must-have, at the cost of segregation of code into libraries.

P.S: If you are using Butterknife solely to replace findViewById calls, the data binding library makes butterknife redundant.
I am having problem with ButterKnife injections on library projects. Whenever i try any view injection such as: @InjectView(R.id.content_frame) protected FrameLayout contentFrame; I get a compile...
1
Paresh Mayani's profile photoKiran Rao's profile photo
2 comments
 
+Paresh Mayani Yep - Jake has explained it in more detail in the linked github issue. IMO it is quite reasonable and I understand why he does not want to support it.
Add a comment...

Kiran Rao

Shared publicly  - 
 
After observing my parents use laptops and smartphones for some time now, I have to conclude that technology has steep learning curve - especially for people of their generation.

Things we take for granted make no sense to them. Many of the metaphors are alien, explaining security is a big effort. Android's permission model is just too much for them to digest. I had a tough time explaining why not to reuse passwords and prefer OAuth/OpenID logins where applicable.

And my parents are "urban", fluent in English etc. We really need to step up if we want to make technology meaningful for these people. And to the millions from India's rural hinterland who are beginning to use technology to make their lives better. 
2
Add a comment...

Kiran Rao

Shared publicly  - 
 
Casually browsing through AOSP/Gerrit is sometimes so interesting. Here I came across an experimental commit. It looks like ART will be implementing lambdas by boxing them into an Object.

Chances are this may never go into production but it is amazing to see the ART team experimenting in the open. Gives us an insight into how devs approach challenging problems.
2
Add a comment...

Kiran Rao

Shared publicly  - 
 
The announcement about open sourcing Swift programming language was a pleasant surprise! #wwdc2015  
3
Add a comment...

Kiran Rao

Shared publicly  - 
 
Very interesting insights into what is needed for moonshots to be relevant in the real world. The take-away is this: Look for ways to fail fast and learn from the failure. Earlier you fail, the better
1
Add a comment...

Kiran Rao

Shared publicly  - 
 
Wait when did Play Store start opening the newly installed app directly when you click on the "installed" notification? Earlier it used to open play store and then you had to click on "Open" to go to the app.

What a welcome change!
2
Add a comment...

Kiran Rao

Shared publicly  - 
 
Really disappointed to see no mention of new forms of payments for app purchases at #io2015  . It is a huge shame because there are so many people who want to buy apps but cannot use Google Wallet.

This is one of those scenarios where having the functionality scores over ease-of-use. Give people the option to go through the payment gateway etc even if it means they have to do it every time they buy an app. That's still better than not being able to buy at all.

Developer loses revenues. User loses the chance to use the app. Google loses on both counts. Lose-lose-lose.
1
Add a comment...
Have him in circles
208 people
Jigar Oza's profile photo
Alejandro Rodriguez Salamanca's profile photo
Djamel Gasbakid's profile photo
Mounir Nahar's profile photo
Shivam Chopra's profile photo
Sergio Carabantes's profile photo
navaneetharan navi's profile photo
The Ultimate Android Library's profile photo
Joe Jiko's profile photo

Kiran Rao

Shared publicly  - 
 
Today I learned that there are certain attributes in AndroidManifest.xml that expect a string but you cannot provide that string using a resource.

Examples include permissions and action names in intent-filters. Take this for instance:

<activity android:name=".MyActivity">
    <intent-filter>
        <action android:name="@string/my_custom_action"></action>
    </intent-filter>
</activity>

This does not work but it is not a compile time error either. The IntentFilter is still registered with the action being the literal "@string/my_custom_action" rather than the resolved value from your strings.xml. You will only come to know at runtime when your Activity refuses to respond to the intent.

And to think that I realized this over 2 YEARS after I wrote a blog post advocating this very thing!

This is probably a good target for a lint check although I really cringe at the prospect of repeating that String at multiple places (in Manifest, while creating an Intent with that action, inside my Activity where I need to check what the intent action was ... ...)
The content of this post may seem ... well .. trivial at first, but I have tripped over these so many times that I decided to write it up - at least to keep me reminded of it, if not for any other reason! If you have written anything more than a HelloWorld app in Android, chances are you have ...
2
Kiran Rao's profile photo
Add a comment...

Kiran Rao

Shared publicly  - 
 
It doesn't matter how smart your phone is, if your network is dumb ~Bruce Lawson, Opera

https://youtu.be/BHO70H9tvqo
1
Add a comment...

Kiran Rao

Shared publicly  - 
 
Well this is interesting! Found this in platform/art on AOSP:
"Add experimental lambda opcodes for invoke/create-lambda"

https://android-review.googlesource.com/#/c/147957/
3
1
Gabor Orosz's profile photo
Add a comment...

Kiran Rao

Shared publicly  - 
 
Seems like I was wrong about Java8 support in Android with Jack. It is being planned but is still in very early stages. No wonder there was no mention at I/O.

However, I'm glad that it is being seriously thought about.
2
Add a comment...
People
Have him in circles
208 people
Jigar Oza's profile photo
Alejandro Rodriguez Salamanca's profile photo
Djamel Gasbakid's profile photo
Mounir Nahar's profile photo
Shivam Chopra's profile photo
Sergio Carabantes's profile photo
navaneetharan navi's profile photo
The Ultimate Android Library's profile photo
Joe Jiko's profile photo
Places
Map of the places this user has livedMap of the places this user has livedMap of the places this user has lived
Currently
Bangalore, India
Links
Story
Tagline
Techie. Bangalorean. Ever curious about new and emerging technologies.
Work
Occupation
Software Engineer
Basic Information
Gender
Male