Resolve Duplicate Permission Problem in Android Package

Standard

Android application has unique identifier called package name to prevent duplicate installation. The standard convention name for Android package name is reversed web URL.

In development process, developers may need to separate application into some versions for testing purpose. For example, we need beta version to be tested before it’s released on the marketplace. We can separate them using different flavors definition in gradle script.

But it can be problem when we use the package name in the manifest file. So we may need to adjust the manifest too.

For example, if we use GCM (Google Cloud Messaging) to enable push notification we need to add permission with unique name (so it has to be the package name). So for different package name it need different permission or there will be problem with duplicate permission. Here we need to define another permission with specified package name and remove the previous permission definition when merging the manifest.

These are the sample code of different manifest file for different package name in different flavor.
Main AndroidManifest.xml

<permission
android:name="com.packagename.app.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.packagename.app.permission.C2D_MESSAGE" />

Beta AndroidManifest.xml

<permission
android:name="com.packagename.app.permission.C2D_MESSAGE"
android:protectionLevel="signature"
tools:node="remove" />
<uses-permission
android:name="com.packagename.app.permission.C2D_MESSAGE"
tools:node="remove" />

<permission
android:name=”com.betapackage.app.permission.C2D_MESSAGE”
android:protectionLevel=”signature” />
<uses-permission android:name=”com.betapackage.app.permission.C2D_MESSAGE” />

Introduction to Android MVP Pattern

Standard

MVP or Model-View-Presenter is a pattern that was derived from MVC. It’s now gaining importance in growing Android development since it has many advantages against the basic pattern.

So what’s MVP? It’s a Android development pattern that allows separate the presentation layer from the logic, so we can make this presentation layer more usable by various fragments that has same behavior.

So what does that mean? Continue reading

Model View Controller Concept

Standard

Concept

MVC is one of the most used patterns that used by web developers to develop their web. Not only because it’s easy to understand, it’s easy to implement once it’s fundamental component is created.

The concept was made to separate bussiness logic and view logic to avoid confusion between these components.

Model

Model is everything that is related to bussiness logic layer such as data and the rules that manages data.

View

View presents data to user. The key concept of view is template. Provided with many sets of data, view can presents data to user with purpose to make user understand these data.
Continue reading

Android Developing Tips: Using RecyclerView as Adapter-based View

Standard

As android engineer, we must already used ListView a lot if we want to show multiple items that has same template.

But there are some problems that can’t be solved by only using ListView:
1. Normally, we can only handle whole item click.
2. It’s hard to use different layout in ListView item without using ViewHolder pattern.
3. It’s become harder to handle some action within the item layout because of reason 1.

But that’s the reason why RecyclerView comes.
Continue reading

Android Developing Tips: Using AppCompat Theme

Standard

Google have launched latest Material design that brings evolution in user experience in various technologies including mobile industries, specifically Android. But this theme is still new and only Lollipop devices can support this so we can’t implement this theme directly using Material theme provided by Google.

So, how do we implement this on pre-Lollipop devices? Yes, there are various solutions. But the simple one is AppCompat v21.
Continue reading