The action bar is a window feature that identifies the application and user location, and provides user actions and navigation modes. 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. In this unit we will discuss about the action bar and notification usage in Android.
Menus are a common user interface component in many types of applications. To provide a familiar and consistent user experience, you should use the Menu APIs to present user actions and other options in your activities.
Menus are a common user interface component in many types of applications. To provide a familiar and consistent user experience, you should use the Menu APIs to present user actions and other options in your activities.
Those who want to be familiar with Android, can easily go through this document. It will help them to learn basics. It is also useful for those who are preparing for cracking android interviews as this document is short and precise.
One of the most important parts of any application's design and development is the graphical user interface (GUI) and screen layout design. Android applications are popular because of their visual design, animated graphics, and easy- or fun-to-use interfaces. We will explore the Java classes that provide the core foundation for all of these front-end capabilities in this chapter.
Android app's user interface is everything that the user can see and interact with. Android provides a variety of pre-build UI components such as structured layout objects and UI controls that allow you to build the graphical user interface for your app. In this unit we discuss about the standard practice of designing the User Interface. Android also provides other UI modules for special interfaces such as dialogs, notifications, and menus.
A comprehensive guide on developing responsive and common react filter componentKaty Slemon
A blog that will help you develop a responsive and common React Filter Component for both desktop and mobile views to maintain consistency across the UI.
The Android framework APIs provides a set 2D drawing APIs that allow you to render your own custom graphics onto a canvas or to modify existing Views to customize their look and feel. When drawing 2D graphics, you'll typically do so in one of two ways Draw your graphics or animations into a View object from your layout or Draw your graphics directly to a Canvas. In this unit we are going to explore about how to draw graphics directly into a canvas.
The general direction in which something tends to move.
A general tendency or inclination. Current style. The Internet is a global revolution in communication – as long as You use letters from the Western alphabet.
People want their own domains in their own languages.
Those who want to be familiar with Android, can easily go through this document. It will help them to learn basics. It is also useful for those who are preparing for cracking android interviews as this document is short and precise.
One of the most important parts of any application's design and development is the graphical user interface (GUI) and screen layout design. Android applications are popular because of their visual design, animated graphics, and easy- or fun-to-use interfaces. We will explore the Java classes that provide the core foundation for all of these front-end capabilities in this chapter.
Android app's user interface is everything that the user can see and interact with. Android provides a variety of pre-build UI components such as structured layout objects and UI controls that allow you to build the graphical user interface for your app. In this unit we discuss about the standard practice of designing the User Interface. Android also provides other UI modules for special interfaces such as dialogs, notifications, and menus.
A comprehensive guide on developing responsive and common react filter componentKaty Slemon
A blog that will help you develop a responsive and common React Filter Component for both desktop and mobile views to maintain consistency across the UI.
The Android framework APIs provides a set 2D drawing APIs that allow you to render your own custom graphics onto a canvas or to modify existing Views to customize their look and feel. When drawing 2D graphics, you'll typically do so in one of two ways Draw your graphics or animations into a View object from your layout or Draw your graphics directly to a Canvas. In this unit we are going to explore about how to draw graphics directly into a canvas.
The general direction in which something tends to move.
A general tendency or inclination. Current style. The Internet is a global revolution in communication – as long as You use letters from the Western alphabet.
People want their own domains in their own languages.
Android - How To Create Push Notifications With Custom View?
Today, most Android applications are integrated with the option to send push notifications. Developers and app publishers consider this capability as one of the most important actions in maintaining the relationship with their users and the ability to motivate them into performing certain actions within the app. However, in most applications the display of push notification message is quite basic - a miniature version of the app icon, a title (most of the time it will be the app name), with a short description below it.
Push notification message can be much more interesting! One of the better examples for it, is the way in which Groupon send their push messages - big and seductive picture, with important details such as price and the amount of discount. They also display action buttons!
In this tutorial we will learn how to create a rich push notification message.
Integrating Push Notifications in your app
If your app doesn’t yet support in basic push notification, please refer to PushApps short tutorial:
https://wiki.pushapps.mobi/display/PUSHAPPS/Android+Getting+Started
This tutorial assumes you have completed the basic push notifications integration, and you are able to receive notifications to your device. We will take you step by step from this phase and show you how to code and design the notification.
Push Notification received event
After you register the device to PushApps with your private keys, we would like to “take control” over the push notification received event. We would like to perform certain actions and display our custom view. With PushApps it’s easy:
1. In you Application class (if you don’t have one, please create it) register to PushApps with your Google API Project Number and PushApps Token.
@Override
public void onCreate() {
super.onCreate();
// first we initialize the push manager, you can also initialize the
// PushManager in your main activity.
PushManager.init(getBaseContext(), GOOGLE_API_PROJECT_NUMBER, PUSHAPPS_APP_TOKEN);
PushManager.getInstance(getApplicationContext())
.setShouldStartIntentAsNewTask(false);
// these methods are both optional and used for the notification
// customization
PushManager.getInstance(getApplicationContext()).setShouldStackNotifications(true);
}
2. We want PushApps to notify us when a new push notification received to the device. For that, we need to implement the PushAppsMessageInterface.
@Override
public void onCreate() {
super.onCreate();
// first we initialize the push manager, you can also initialize the
// PushManager in your main activity.
PushManager.init(getBaseContext(), GOOGLE_API_PROJECT_NUMBER, PUSHAPPS_APP_TOKEN);
PushManager.getInstance(getApplicationContext()).setShouldStartIntentAsNewTask(false);
// these methods are both optional and us
The Content helps those who wish to program mobile applications using android platform. The content has been used to conduct mobile application boot camps using android platform on different regions in Tanzania
Use of TextField, Label, Sliders and Switch buttons
Handling ActionSheet and Alerts
Application Delegates
Handling ActionSheet and Alerts
Application Delegates
UIApplication Delegates
View Controllers
Life Cycle of Application & Methods
ARC
iPhone App Development Training Programme (contd.)
The app we'll build in this tutorial is going to let users get connected to their Google account, download their calendars, and create a new event with a description and a date/time. The new event will be posted to a calendar that the user selects.
Basic4ppc is a programming language designed for mobile applications development.
With Basic4ppc you can develop programs directly on the Pocket PC / Window Mobile or on the desktop
PHP is a server-side scripting language designed for web development, but also used as a general-purpose programming language. Most of the websites are using PHP in their dynamic content
1. Chapter 16
Action Bar and Notifications
By
Dr. Ramkumar Lakshminarayanan
Introduction
The action bar is a window feature that identifies the application and user location,
and provides user actions and navigation modes. 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. In this unit we will discuss
about the action bar and notification usage in Android.
Action Bar
Action bar is used in most activities that need to prominently present user actions or
global navigation, because the action bar offers users a consistent interface across
applications and the system gracefully adapts the action bar's appearance for different screen
configurations. You can control the behaviors and visibility of the action bar with
the ActionBar APIs, which were added in Android 3.0 (API level 11).
The primary goals of the action bar are to:
Provide a dedicated space for identifying the application brand and user location.
This is accomplished with the app icon or logo on the left side and the activity title. You
might choose to remove the activity title, however, if the current view is identified by a
navigation label, such as the currently selected tab.
Provide consistent navigation and view refinement across different applications.
The action bar provides built-in tab navigation for switching between fragments. It also
offers a drop-down list you can use as an alternative navigation mode or to refine the current
view (such as to sort a list by different criteria).
Make key actions for the activity (such as "search", "create", "share", etc.) prominent
and accessible to the user in a predictable way.
You can provide instant access to key user actions by placing items from the options
menu directly in the action bar, as "action items." Action items can also provide an "action
view," which provides an embedded widget for even more immediate action behaviors. Menu
items that are not promoted to an action item are available in the overflow menu, revealed by
either the device Menu button (when available) or by an "overflow menu" button in the action
bar (when the device does not include a Menu button).
2. Figure 16.1 Action Bar
Example Action Bar
is a menu bar that is positioned at the top of the screen and is used as a replacement
for the title bar. Google is really pushing developers to use ActionBars and move away from
using the hardware menu button. To enable ActionBar in your application you will have to
include things like android:targetSdkVersion=”11″ or greater as part of your aspect in the
Androidmanifest.xml.
The code in AndroidManifest.xml is as follows:
Ensure the following codes are changed in your AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mjs.actionbar"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo" >
<activity
android:name="com.mjs.actionbar.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo" >
3. Now for the MainActivity. The only thing that should be new is in the onCreate
method.
package com.mjs.actionbar;
import android.os.Bundle;
import android.app.ActionBar;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// gets the activity's default ActionBar
ActionBar actionBar = getActionBar();
actionBar.show();
// set the app icon as an action to go home
// we are home so we don't need it
// actionBar.setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
// same as using a normal menu
switch(item.getItemId()) {
case R.id.item_refresh:
makeToast("Refreshing...");
break;
case R.id.item_save:
makeToast("Saving...");
break;
}
return true;
}
public void makeToast(String message) {
Toast.makeText(this,message, Toast.LENGTH_SHORT).show();
}
}
4. The code of resmenuactivity_main.xml will be as follows:
This is just a normal menu xml. The only thing that might be new is the last line of
each item. This line just says, if there is enough room, the title will be shown.
Figure 16.2 Action Bar
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/item_refresh"
android:title="Refresh"
android:showAsAction="ifRoom|withText" />
<item
android:id="@+id/item_save"
android:title="Save"
android:showAsAction="ifRoom|withText" />
</menu>
5. When the user selects an action item, your activity receives a call
to onOptionsItemSelected(), passing the ID supplied by the android:id attribute—the same
callback received for all items in the options menu.
It's important that you always define android:title for each menu item—even if you
don't declare that the title appear with the action item—for three reasons:
If there's not enough room in the action bar for the action item, the menu item appears
in the overflow menu and only the title appears.
Screen readers for sight-impaired users read the menu item's title.
If the action item appears with only the icon, a user can long-press the item to reveal a
tool-tip that displays the action item's title.
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.
Notification Display Elements
Notifications in the notification drawer can appear in one of two visual styles,
depending on the version and the state of the drawer:
Normal view
The standard view of the notifications in the notification drawer.
Figure 16.2 Notifications in Normal View
The callouts in the Figure 16.2 refer to the following:
1. Content title
2. Large icon
3. Content text
4. Content info
5. Small icon
6. 6. Time that the notification was issued. You can set an explicit value with setWhen();
if you don't it defaults to the time that the system received the notification.
Big view
A large view that's visible when the notification is expanded. Big view is part of the
expanded notification feature available as of Android 4.1.
Figure 16.3 Big View Notifications
Notice that the big view shares most of its visual elements with the normal view. The
only difference is callout number 7, the details area. Each big view style sets this area in a
different way. The available styles are:
Big picture style
The details area contains a bitmap up to 256 dp tall in its detail section.
Big text style
Displays a large text block in the details section.
Inbox style
Displays lines of text in the details section.
All of the big view styles also have the following content options that aren't available
in normal view:
Big content title
Allows you to override the normal view's content title with a title that appears only in
the expanded view.
7. Summary text
Allows you to add a line of text below the details area.
Example – Notifications
Android allows to put notification into the titlebar of your application. The user can
expand the notification bar and by selecting the notification the user can trigger another
activity. Notifications in Android are represented by the Notification class. To create
notifications you use theNotificationManager class which can be received from the Context,
e.g. an activity or a Service, via the getSystemService() method.
The Notification.Builder provides an builder interface to create an Notification object.
You use a PendingIntent to specify the action which should be performed once the user select
the notification. Notification.Builder allows to add up two three buttons with definable
actions to the notification. For the icon we have used the default icon ic_launcher available in
res/drawable.
NotificationManager notificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
// Prepare intent which is triggered if the
// notification is selected
Intent intent = new Intent(this, NotificationReceiver.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
// Build notification
// Actions are just fake
Notification noti = new Notification.Builder(this)
.setContentTitle("New mail from " + "test@gmail.com")
.setContentText("Subject").setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pIntent)
.addAction(R.drawable.ic_launcher, "Call", pIntent)
.addAction(R.drawable.ic_launcher, "More", pIntent)
.addAction(R.drawable.ic_launcher, "And more", pIntent).build();
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Hide the notification after its selected
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, noti);
8. Figure 16.4 Notification
Android 4.1 supports expandable notifications. In addition to normal notification view
it is now possible to define a big view which gets shown when notification is expanded.
There are three styles to be used with the big view: big picture style, big text style, Inbox
style. The following code demonstrates the usage of theBigTextStyle() which allows to use
up to 256 dp.
The user can dismiss all notification or if you set your notification to auto-cancel it is
also removed once the user selects it. You can also call the cancel() for a specific notification
ID on the NotificationManager. ThecancelAll() method call removes all of the notifications
you previously issued.
Create a new Project com.mjs.notificationmanager with the activity class called
MainActivity. This activity should use the activity_main.xml layout file.
String longText = "...";
Notification noti = new Notification.Builder(this).
.....
.setStyle(new Notification.BigTextStyle().bigText(longText))
9. Create the following result.xml layout file.
Create a new activity called NotificationReceiverActivity with the following coding.
Don't forget to register the activity in the AndroidManifest.xml.
In order to create NotificationReceiverActivity.java copy the MainActivity.java and
Save as a Copy with the respective name and add the following code.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:onClick="createNotification"
android:text="Create Notification" >
</Button>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is the result activity opened from the
notification" >
</TextView>
</LinearLayout>
<activity
android:name="com.mjs.notificationmanager.NotificationReceiverActivity">
</activity>
package com.mjs.notificationmanager;
import android.os.Bundle;
import android.app.Activity;
public class NotificationReceiverActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.result);
}
}
10. Change the MainActivity.java to the following code:
package com.mjs.notificationmanager;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void createNotification(View view) {
// Prepare intent which is triggered if the
// notification is selected
Intent intent = new Intent(this, NotificationReceiverActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(this,0, intent, 0);
// Build notification
// Actions are just fake
Notification noti = new Notification.Builder(this)
.setContentTitle("New mail from " + "test@gmail.com")
.setContentText("Subject").setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pIntent)
.addAction(R.drawable.ic_launcher, "Call", pIntent)
.addAction(R.drawable.ic_launcher, "More", pIntent)
.addAction(R.drawable.ic_launcher, "And more", pIntent).build();
NotificationManager notificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
// Hide the notification after its selected
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, noti);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
11. Run your application and press the button. A new notification is created. If you select
it your second activity will be displayed.
Summary
In this unit we have discussed about Action Bar and Notifications. Android support
various design practices to create an enhanced user interface. Beginning with Android 3.0
(API level 11), the action bar appears at the top of an activity's window when the activity
uses the system's Holo theme (or one of its descendant themes), which is the default.
Notifications, as an important part of the Android UI, have their own design guidelines. We
have discussed and designed application based on the Action Bar and Notifications.