Deeplinking your app

Hi Friends,

Most of you might be aware about what is deeplink is..but for people who don’t know about it….

In the context of the World Wide Web, deep linking is the use of a hyperlink that links to a specific, generally searchable or indexed, piece of web content on a website (e.g., “http://example.com/path/page”), rather than the website’s home page (e.g., “http://example.com/”).

Google has suggested way to achieve the deeplink of your app from the search result.To make this happen, you might need to add intent filters to the activity in your manifest file.

Below code snippet is form Google developer page. seems pretty easy to use.

The following XML snippet shows how you might specify an intent filter in your manifest for deep linking. The URIs “example://gizmos” and“http://www.example.com/gizmos” both resolve to this activity.

<activity
    android:name="com.example.android.GizmosActivity"
    android:label="@string/title_gizmos" >
    <intent-filter android:label="@string/filter_title_viewgizmos">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
 <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
        <data android:scheme="http"
              android:host="www.example.com"
              android:pathPrefix="/gizmos" />
        <!-- note that the leading "/" is required for pathPrefix-->
        <!-- Accepts URIs that begin with "example://gizmos” -->
        <data android:scheme="example"
              android:host="gizmos" />

    </intent-filter>
</activity>

What happens if you want the same activity to handle different deeplink Url. Simple add more intent filters. But it made my manifest look huge and if you are working on big enterprise app, probably you might need to add lot of intent filters. I was looking for a library which does all these hardwork , easy to extend and yet make the manifest look simple. Fortunately, there is a saver. airbnb has a fantastic library which helps me to achieve my goal. easy to use, code looks simple and neat. Thanks to airbnb DeepLinkDispatch. refer the github link for more info.

The most important thing i was looking on how ease to add multiple deeplink url’s

Single Deeplinks

@DeepLink("foo://example.com/deepLink/{id}")
public class MainActivity extends Activity {
  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    if (intent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false)) {
      Bundle parameters = intent.getExtras();
      String idString = parameters.getString("id");
      // Do something with the ID...
    }
    ...
  }
}

Multiple Deeplinks

@DeepLink({"foo://example.com/deepLink/{id}", 
"foo://example.com/anotherDeepLink"})
public class MainActivity extends Activity {
  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    if (intent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false)) {
      Bundle parameters = intent.getExtras();
      String idString = parameters.getString("id");
      // Do something with the ID...
    }
    ...
  }
}

Query parameter

Query parameters are parsed and passed along automatically, and are retrievable like any other parameter. For example, we could retrieve the query parameter passed along in the URI example://example.com/deepLink?qp=123:

@DeepLink("foo://example.com/deepLink")
public class MainActivity extends Activity {
  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    if (intent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false)) {
      Bundle parameters = intent.getExtras();
      if (parameters != null && parameters.getString("qp") != null) {
        String queryParameter = parameters.getString("qp");
        // Do something with the query parameter...
      }
    }
  }
}

Refer the github for more information. Thanks airbnb. Happy coding 🙂

 

 

 

 

 

Android Auto is now Standalone app

Guys, today updated the android auto and surprised to see its now a standalone app. No need to buy a new car or a expensive car head unit to support android auto. Welcome to Android world.

device-2016-11-08-103901.png

Update or Create Project to support Android N(7.1)

Info reg your project update or creating a new project to support Android N devices.

Create New Project:

  1. Click File > New Project. and follow the steps until you reach the Target Android Devices page.
  2. On this page, select the Phone and Tablet check box.
  3. Under Phone and Tablet option, in the Minimum SDK option list, select API 25: Android 7.1 Preview.

Update existing Project:

open build.gradle files to update your project to support Android N

android {
  compileSdkVersion 25
  buildToolsVersion '25.0.0'
  ...

  defaultConfig {
     targetSdkVersion 25
     ...
  }
  ...
}

More detail info refer Developer Android set up Android N7.1

Happy coding 🙂

Android N7.1 Dev beta is OUT

Hi Guys,

As you were eagerly waiting , Android 7.1 Dev beta version is available for download.You wont get updates automatically from system updates. To get it, you need to enrolled your device for the beta version…its simple to enrol.

  • Go to Google Android beta link. g.co/androidbeta or www.android.com/beta 
  • It will prompt to login to your google account. On successful login, browser will detect for the device model and you can see a Enroll button.
  • Just click it and accept T&C.
  • Go to Systems > About > Software updates….
  • you will be welcomed with Android beta update release…
  • Update size is 1260 MB !!!

Voilla!!… Enjoy and cross check your App using Android 7.1 N

About

Hello World! That’s how I ventured into programming. I still remember my first C program done in my college computer lab and a big bright smile on my face. Never a whiz kid or want to be. Nev…

Source: About

Parcelable Vs Serializable

In Android  as you are aware, we cannot just pass object to activities. Object must be implement either serializable or parcelable Interface for passing objects to activites.

Serializable:

  • Java standard interface
  • Easy to implement
  • uses lot of temporary variable and its uses quite lot of garbage collection.

Parcelable:

  • Android specific. It turns out that the Android team came to the conclusion that the serialization in Java is far too slow to satisfy Android’s interprocess-communication requirements. So the team built the Parcelable solution. The Parcelable approach requires that you explicitly serialize the members of your class, but in the end, you get a much faster serialization of your object.
  • do need to add some custom implementation. so some might feel its hard to implement. We will talk about it later.

I have come across a good article which talks in detail about the parcelable Vs Serializable.

Refer the link: http://www.developerphil.com/parcelable-vs-serializable/

reg the topic of parcelable hard to implement, you can very well use Android parcelable code generator plugin to make your life easy. refer the screenshot below.

 

Happy coding 🙂