Intent and Intent Filters

 

A intent is an abstract description of an action to be performed. Also known as a messaging component that is used to request certain action from another component.

Intents have basic fundamental use cases:

  1. To start an activity: Used to start new instance of an activity by passing intent to it.
    ie. startActivity(new Intent(<CONTEXT_PACKAGE>, <CLASS>)).
    Similarly, if we want to receive a result from the starting activity then we use startActivityForResult(<INTENT>, <RESULT_CODE>).
  2. To start a service: Start a service to perform one time service by passing intent to startService(<INTENT>).
  3. To deliver a broadcast: Deliver broadcast to other apps by passing intent on functions such as sendBroadcast(<INTENT>). There are other ways to send broadcasts as well which will help differentiate what type of broadcast is being delivered. Learn more here.

Intent Types

There are two types of intents Continue reading

Advertisements

Four Building Blocks of Android

Lets talk about the four fundamental building blocks from which all the android applications are built. These building blocks are implemented as Java classes.

Android Component

Here is a diagrammatic representation of android application fundamental which explores android components and other fundamentals by Romain Chaippinelli.

application fundamental

 

 

 

 

 

 

Lets understand the four building blocks Continue reading

Dalvik Virtual Machine

We might think that as android is written in java it should also run on Java Virtual Machine using Java Compiler to compile its code. However, this is different in android ie. android uses Dalvik Virtual Machine to execute its code.

Why?

Dalvik Virtual Machine was build to make applications run in environment with resource constrains. By resource constrains what do we mean here is, comparatively mobile devices run under particularly low memory while desktop devices or laptops are high end devices with lesser constrains like this. Hence, Dalvik VM was specially designed to run on resource-constrained environment.

Extra Info: Dalvik byte codes Continue reading

Introduction to Android

Android is an operating system which was build for mobile devices and tablets. It is a software stack comprising not only operating system but also middleware and key applications.

The Platform

Android provides low level system software to high level end user application software. Android includes Linux kernal based OS, rich UI, multiple build in software, Telephony services, multimedia frameworks etcs. One of the best part about android platform is regardless of how strong a build in application might be you can always build similar powerful applications with access to all the resources on the device. Since android is an open source platform you can also get application level codes and start experimenting with it.

The Layer of Android Architecture

Linux Kernel: This provides a Continue reading

Install Android Virtual Device (GenyMotion)

Let’s dive into installing genymotion as a virtual device for you android applications.

Download and install virtual box (Optional)

Download VirtualBox + follow instructions to install.

SignUp for GenyMotion and download it’s installer

Sign up for an account  here.

Download the appropriate installer with (if you have skipped first step) or without virtualbox.

Run the GenyMotion Application

Select Virtual device you want to install.  Continue reading

Create Notification in Android

Notifications

A notification is a message you can display to the user outside of your application’s normal UI. When you tell the system to issue a notification, it first appears as an icon in the notification area. To see the details of the notification, the user opens the notification drawer. Both the notification area and the notification drawer are system-controlled areas that the user can view at any time.

Building Notification

Screenshot_20160308-130922

 

Continue reading

Alarm Manager

 

Whatever we code in android are made to be executed at that moment. But what if we want to trigger an event or task or an action in a time in future; may be after 15 mins , and hour or a day. To help ease this process the class AlarmManager is provided to us.

Lets get started and learn more about alarms.

Alarm Manager

 

Alarms:

What is an alarm? Alarms are the mechanism to schedule an intent in specific time in future.

Why do we need an alarm? We need an alarm to perform an action in future even if the application is not running.

Have we ever noticed that even if we exit the bluetooth connection application; it’s visibility timeout will be disabled at the mentioned time? Another obvious example is our clock.

Alarms can we very useful if you want to develop an app that allows certain notifications or triggers in future and perform respective functions.

Alarm Manager:

Quickly we’ll dive into the basics of alarm creation and take a look at the APIs provided for alarms.

  • Get an access to system’s alarm services:
    • getSystemService(ALARM_SERVICE)
  • Creating alarms
    • one-shot alarm
      • void set(int type, long triggerAtMillis, PendingIntent operation)
    • repeating alarm
      • void setRepeating(int type, long triggerAtMillis, long intervalMillis, PendingIntent operation)
    • repeating alarm in exact trigger time
      • void setInexactRepeating(int type, long triggerAtMillis, long intervalMillis, PendingIntent operation)

Continue reading