Starting a new activity

Put your problem here if it does not fit any of the other categories.

Starting a new activity

Postby shiteiru » Thu Dec 18, 2008 6:18 pm

Hello everyone...

i really hope that someone can help me, cause this problem freaks me out.

And thats it:

I am not able to start a new activity.
Here's the code:


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         private void categories() {
  2.  
  3.         Intent i = new Intent().setClassName("de.mal", "Categories");
  4.  
  5.         startActivity(i);
  6.  
  7.         }
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Manifest.xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.    <activity android:name="Categories">
  3.  
  4.             <intent-filter>
  5.  
  6.                 <action android:name="android.intent.action.VIEW" />
  7.  
  8.                 <category android:name="android.intent.category.DEFAULT" />
  9.  
  10.             </intent-filter>
  11.  
  12.         </activity>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


should open Categories.class file...but it doesn't.
Instead the log gives me this error: android.content.ActivityNotFoundException: Unable to find explicit activity class {de.mal/Categories}; have you declared this activity in your AndroidManifest.xml?

Any solutions?
shiteiru
Junior Developer
Junior Developer
 
Posts: 23
Joined: Tue May 20, 2008 7:16 pm

Top

Postby Quetzalcoatl » Thu Dec 18, 2008 8:34 pm

What is "de.mal"? :?


Code: Select all
Intent myIntent = new Intent(this, VIEWNAME.class);
         startActivity(myIntent);
Image
Quetzalcoatl
Senior Developer
Senior Developer
 
Posts: 129
Joined: Sat Oct 18, 2008 8:21 pm
Location: near Manchester, UK

Postby bornmw » Fri Dec 26, 2008 12:50 am

Quetzalcoatl wrote:What is "de.mal"? :?


Hmmm let me guess.... a package name?
bornmw
Freshman
Freshman
 
Posts: 5
Joined: Thu Dec 25, 2008 9:23 pm

Re: Starting a new activity

Postby bornmw » Fri Dec 26, 2008 12:59 am

shiteiru wrote:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         private void categories() {
  2.         Intent i = new Intent().setClassName("de.mal", "Categories");
  3.         startActivity(i);
  4.         }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4



I know it is stupid, but class name has to include package name.
Like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Intent().setClassName("de.mal", "de.mal.Categories")
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
bornmw
Freshman
Freshman
 
Posts: 5
Joined: Thu Dec 25, 2008 9:23 pm

Postby defdwight » Fri Jan 02, 2009 11:41 pm

I believe your syntax is incorrect. Try this code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Intent i = new Intent();
  2.  
  3.                         i.setClassName("de.mal", "de.mal.Categories");
  4.  
  5.                         startActivity(i);
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
defdwight
Freshman
Freshman
 
Posts: 6
Joined: Fri Jan 02, 2009 9:29 pm
Location: FL

Postby MrSnowflake » Sat Jan 03, 2009 2:20 pm

try Intent i = new Intent(de.mal.class);
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Postby bornmw » Sat Jan 03, 2009 2:33 pm

MrSnowflake wrote:try Intent i = new Intent(de.mal.class);


Wow, cannot resolve constructor.
bornmw
Freshman
Freshman
 
Posts: 5
Joined: Thu Dec 25, 2008 9:23 pm

Postby MrSnowflake » Sat Jan 03, 2009 2:50 pm

MrSnowflake wrote:try Intent i = new Intent(de.mal.class);
Ok, I forgot the context, so it should be:
Intent i = new Intent(this, de.mal.class);

more general
Intent i = new Intent(this, ClassName.class);
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Zeba Momin » Mon Dec 14, 2009 7:42 am

hii...
I've been using the following function to start a new activity

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void startNewActivity(Class<?> classTo) {
  2.  
  3.                 Intent mainIntent = new Intent(GUIEngine.this, classTo);
  4.  
  5.                 GUIEngine.this.startActivity(mainIntent);
  6.  
  7.         }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


where GUIEngine is my the main activity of my application.

This works absolutely fine to start a new activity but once a new activity is started it starts again after sumtime!!!
Why is dis happening?
Can sumone plzz help me wid dis?
Thank you...
Zeba Momin
Developer
Developer
 
Posts: 49
Joined: Thu Sep 17, 2009 6:53 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 17 guests