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 3681090
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:39:11+00:00 2026-05-19T03:39:11+00:00

Firstly, I am new to both android and Java. I have two classes, my

  • 0

Firstly, I am new to both android and Java.

I have two classes, my main.class and Note.class.

I am calling the notification method from my Note.class in my main.class when i press a button.

The issue is with this line from the Note.class :

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

When the method is called it force closes. I believe the problem to be with the “this” in PendingIntent.getActivity(this, 0, notificationIntent, 0);, but I am unsure what to change it to.

The notification code works fine if it’s in the main class.

I would be very grateful for any guidance.

Edit:
Main class : http://pastebin.com/05Yx0a48

Note.class :

package com.adamblanchard.remindme.com.adamblanchard;

import com.adamblanchard.remindme.R;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;



public class Note extends Activity {

public CharSequence note = "not changed";
int HELLO_ID = 1;

/** Called when the activity is first created. */

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    setTitle("Remind Me!");


}

//Notification Method

public void callNotification() {
    // TODO Auto-generated method stub


    String ns = Context.NOTIFICATION_SERVICE;
    final NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

    int icon = R.drawable.launcher;
    CharSequence tickerText = "Remind Me!";
    long when = System.currentTimeMillis();

    final Notification notification = new Notification(icon, tickerText, when);

notification.flags |= Notification.FLAG_AUTO_CANCEL;

final Context context = getApplicationContext();
CharSequence contentTitle = "Remind Me!";
CharSequence contentText = note;

Intent notificationIntent = new Intent(context, AndroidNotifications.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);





        mNotificationManager.notify(HELLO_ID, notification);

        HELLO_ID++;
}

 }

Debug Output :

Thread [<1> main] (Suspended (exception IllegalStateException))
Note(Activity).getSystemService(String) line: 3536
Note.callNotification() line: 37
remindme$1$1.onClick(DialogInterface, int) line: 72
AlertDialog(AlertController$ButtonHandler).handleMessage(Message) line: 159
AlertController$ButtonHandler(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 3647
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object…) line: 507
ZygoteInit$MethodAndArgsCaller.run() line: 839
ZygoteInit.main(String[]) line: 597
NativeStart.main(String[]) line: not available [native method]

This is the debug output I get, plus a force close popup on the device.

Edit2:

Manifest xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.adamblanchard.remindme"
  android:versionCode="3"
  android:versionName="0.7">
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher72">

<activity android:name=".com.adamblanchard.remindme" 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=".Note">
<intent-filter>
<action android:name="Note" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>


<uses-sdk android:minSdkVersion="1"></uses-sdk>
</manifest> 

Stack traces (Are these what you mean?):

Thread [<1> main] (Suspended (exception ActivityNotFoundException)) 
Instrumentation.checkStartActivityResult(int, Object) line: 1404    
Instrumentation.execStartActivity(Context, IBinder, IBinder, Activity, Intent, int) line: 1378  
remindme(Activity).startActivityForResult(Intent, int) line: 2827   
remindme(Activity).startActivity(Intent) line: 2933 
remindme$1$1.onClick(DialogInterface, int) line: 82 
AlertDialog(AlertController$ButtonHandler).handleMessage(Message) line: 159 
AlertController$ButtonHandler(Handler).dispatchMessage(Message) line: 99    
Looper.loop() line: 123 
ActivityThread.main(String[]) line: 3647    
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
Method.invoke(Object, Object...) line: 507  
ZygoteInit$MethodAndArgsCaller.run() line: 839  
ZygoteInit.main(String[]) line: 597 
NativeStart.main(String[]) line: not available [native method]  

or:

01-15 00:56:18.167: WARN/dalvikvm(14887): threadid=1: thread exiting with uncaught exception (group=0x40015560)
01-15 00:56:18.217: ERROR/AndroidRuntime(14887): FATAL EXCEPTION: main
01-15 00:56:18.217: ERROR/AndroidRuntime(14887): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.adamblanchard.remindme/com.adamblanchard.remindme.com.adamblanchard.Note}; have you declared this activity in your AndroidManifest.xml?
01-15 00:56:18.217: ERROR/AndroidRuntime(14887):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
01-15 00:56:18.217: ERROR/AndroidRuntime(14887):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
01-15 00:56:18.217: ERROR/AndroidRuntime(14887):     at android.app.Activity.startActivityForResult(Activity.java:2827)
01-15 00:56:18.217: ERROR/AndroidRuntime(14887):     at android.app.Activity.startActivity(Activity.java:2933)
01-15 00:56:18.217: ERROR/AndroidRuntime(14887):     at com.adamblanchard.remindme.com.adamblanchard.remindme$1$1.onClick(remindme.java:82)
01-15 00:56:18.217: ERROR/AndroidRuntime(14887):     at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159)
01-15 00:56:18.217: ERROR/AndroidRuntime(14887):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-15 00:56:18.217: ERROR/AndroidRuntime(14887):     at android.os.Looper.loop(Looper.java:123)
01-15 00:56:18.217: ERROR/AndroidRuntime(14887):     at android.app.ActivityThread.main(ActivityThread.java:3647)
01-15 00:56:18.217: ERROR/AndroidRuntime(14887):     at java.lang.reflect.Method.invokeNative(Native Method)
01-15 00:56:18.217: ERROR/AndroidRuntime(14887):     at java.lang.reflect.Method.invoke(Method.java:507)
01-15 00:56:18.217: ERROR/AndroidRuntime(14887):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-15 00:56:18.217: ERROR/AndroidRuntime(14887):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-15 00:56:18.217: ERROR/AndroidRuntime(14887):     at dalvik.system.NativeStart.main(Native Method)
01-15 00:56:18.237: WARN/ActivityManager(156):   Force finishing activity com.adamblanchard.remindme/.com.adamblanchard.remindme
01-15 00:56:18.747: WARN/ActivityManager(156): Activity pause timeout for HistoryRecord{40a15868 com.adamblanchard.remindme/.com.adamblanchard.remindme}
01-15 00:56:18.777: DEBUG/Launcher(10740): -- loadPreferences()
01-15 00:56:19.177: INFO/ActivityManager(156): No longer want com.facebook.katana (pid 14395): hidden #16
01-15 00:56:29.177: WARN/ActivityManager(156): Activity destroy timeout for HistoryRecord{40a15868 com.adamblanchard.remindme/.com.adamblanchard.remindme}
  • 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-05-19T03:39:11+00:00Added an answer on May 19, 2026 at 3:39 am

    OK! I fixed it!

    In the manifest.xml I needed to use the full name for the activity, ie:

    <activity android:name=".com.adamblanchard.Note"></activity>
    

    I have been messing around with the code, so other things may have contributed, but as soon as I changed this it worked.

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

Sidebar

Related Questions

Firstly I am new to android and Java so this is a beginners question.
Firstly, Im new to android but have years of various other programming experience on
see fiddle Firstly i am new to jquery. i have to make one cell
Its prudent that I firstly say I'm new to both Rhino Mocks and to
Firstly, I'm new to Android (so I apologize if this question is ignorant) but
Im very new to WP7 Development and i have a few questions. Firstly i
Since I am new to iOS development I have a few Questions. Firstly I
I am very new to Ruby, and programming in general. Firstly, I have the
For example, I have a class that has two strings, one of which must
Firstly I am very new to JAVA, so I apoligise if I am not

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.