Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9260463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:53:55+00:00 2026-06-18T12:53:55+00:00

I have just started experimenting on android. I am reading book Beginning Android 4

  • 0

I have just started experimenting on android. I am reading book Beginning Android 4 application development by Wrox pulication. There is a code for showing notifications. The problem is the code I have written(not copied) is very little modified. So, I am able to show notification on status/notification bar but on clicking the notification the notificaion class is not being invoked. Here is the code for android_mainfest first.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="legacy_systems.notificationproject"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="9" />
<uses-permission android:name="android.permission.VIBRATE"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="legacy_systems.notificationproject.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>
    <activity 
        android:name="Notification"
        android:label="Details of the Notification" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.DEFAULT" />                    
        </intent-filter>
    </activity>
</application>

</manifest>

Now, the code for MainActivity
package legacy_systems.notificationproject;

import android.os.Bundle;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.view.View;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {
int notificationID = 1;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@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;
}

public void onClick(View V)
{
    getNotification();
}

protected void getNotification()
{
    Intent i = new Intent(this, Notification.class);
    i.putExtra("notificationID", notificationID);
    PendingIntent pn = PendingIntent.getActivity(this, 0, i, 0);
    NotificationManager nm= (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    Notification n = new Notification(R.drawable.ic_launcher,
                                      "Reminder! Meeting starts in 5 Minute",
                                      System.currentTimeMillis());
    CharSequence from = "System Alarm";
    CharSequence message = "Meeting with customer in next 2 minute";
    n.setLatestEventInfo(this, from, message, pn);
    n.vibrate = new long[]{ 100,250,50,500};
    nm.notify(notificationID, n);       
}

}

And, the code for Notification.java is
package legacy_systems.notificationproject;

import android.app.Activity;
import android.os.Bundle;
import android.app.NotificationManager;
import android.util.Log;

public class Notification extends Activity{
String tag;

public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    Log.d(tag,"In here");

    setContentView(R.layout.notification);

    NotificationManager nm = (NotificationManager)getSystemService(VIBRATOR_SERVICE);
    nm.cancel(getIntent().getExtras().getInt("notificationID"));
}
}

And activity_main.xml is,

<xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<Button
    android:id="@+id/btn"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:text="@string/getnot"
    android:onClick="onClick"
 />

</RelativeLayout>    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:53:57+00:00Added an answer on June 18, 2026 at 12:53 pm

    You would be well-advised to not name your own classes the same name as system-defined classes. You are attempting to open android.app.Notification as an activity, which will not work and should be resulting in warnings in LogCat.

    Please rename your Notification activity to something else, such as Easdluaerdf, so as to make it unique, adjusting your manifest and PendingIntent to match, and you should have better luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a beginner and have just started experimenting with the modeling tool in
I have just started to learn how to code iOS apps. I have made
I have just started my HTTPREQUEST application and I am trying to set up
I have just started experimenting with matplotlib, since I often come across instances where
I'm using a PowerPC 750 and have just started experimenting with the external interrupt.
I've only just started looking at Dapper.net and have just been experimenting with some
I have just started experimenting with Serproxy and Arduino to get some serial data
I just started experimenting with java today (have experience with javascript and PHP) and
I have recently just started learning how to develop android applications. I am am
I have just started reading Spring In Action - Third edition and am stuck

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.