Keep Getting ActivityNotFoundException - android

As the title says I keep getting this error and don't know what I'm missing. I've cleaned the project several times. Here is my code:
startActivity(new Intent(this, UsrPrefs.class));
In the manifest:
<application
android:label="#string/app_name" >
<activity
android:name=".IcyArmActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="#string/app_name"
android:name=".UserPreferences"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.PREFS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
OHHHHHHHHHHHHHHHHHHHH!!!!! Thanks you guys. I thought the UsrPrefs.class was the name of the class so that is what I was using. I see the connection now. DOH!!!!

It's because you defined a class as an activity with one name and starting the other activity which is not registered with that name in the manifest.xml
Replace this:
<activity
android:label="#string/app_name"
android:name=".UserPreferences"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.PREFS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
with
<activity
android:label="#string/app_name"
android:name=".UsrPrefs"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.PREFS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

In your menifest the name of activity is UserPreferences.So edit like this
startActivity(new Intent(this, UserPreferences.class));

Use
startActivity(new Intent(IcyArmActivity.this, UserPreferences.class));
for starting new Activity from main Activity because you have declared UsrPrefs as UserPreferences in manifest
OR
you can declare UsrPrefs as new Activity in manifest as :
<activity android:name=".UsrPrefs" />

Related

Can't find launch activity

I removed these 2 lines from my android manifest file. Then I found them in internet and paste it to manifest file. And now my app can't find them. When I run my app says that there is no launcher activity and that may be I want to launch default activity.What can I do?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.amadey.myapplication3" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</intent-filter>
</activity>
<activity
android:name=".HomeScreen">
</activity>
</application>
</manifest>
You have a doubly-nested intent-filter element in your manifest:
<intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</intent-filter>
It needs to look like this:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Because an intent filter was surrounded with another intent filter, just like this:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

No Launcher Activity Found even though there is [duplicate]

This question already has answers here:
No Launcher activity found
(2 answers)
Closed 9 years ago.
This is a copy of my AndroidManifest.xml
Any help as to why the launcher is not being recognized? I tried running the code without applying DEFAULT to any other activity but it's still not working.
enter code here
<application
<activity
android:name="project.shirsho.Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="project.shirsho.MENU" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="project.shirsho.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="project.shirsho.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="project.shirsho.Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="project.shirsho.Textplay"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.TEXTPLAY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
You need to specify the MAIN and LAUNCHER in the the intent filter for the activity you want to start on launch by :
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
if you want that Splach Activity as your launcher , your manifest must be :
<application>
<activity
android:name="project.shirsho.Menu"
android:label="#string/app_name" >
</activity>
<activity
android:name="project.shirsho.MainActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name="project.shirsho.Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="project.shirsho.Textplay"
android:label="#string/app_name" >
</activity>
</application>
I believe that you are trying to make "project.shirsho.Menu" as the launcher activity, then it should be like:
<activity
android:name="project.shirsho.Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
change,
<intent-filter>
<action android:name="project.shirsho.MENU" />
to
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Hope this helps! :)
This is how your application part should look like. If you use eclipse to develop in it will help you create this (androidManifest.xml)
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".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=".SplashActivity"
android:label="#string/app_name" >
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

Every activity can use "android.intent.action.MAIN"?

aid with this example at Return back to MainActivity from another activity
I copy that codes as follow,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Activity1"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.ACTIVITY001" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Activity2"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.ACTIVITY002" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Activity3"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.ACTIVITY003" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
So many statements: action android:name="android.intent.action.MAIN"; if I would use their class path to instead of them, they can also do the job. what's different from these two ways?
setClass() is a explicit declaration, setAction() is a implicit declaration. It will find your target action im manifest.xml.
If the intent-filter with “android.intent.action.MAIN”, there would more entryance of your application, also you can found more icon in launcher.
its wrong
<action android:name="ACTIVITYNAME FOR INTENT" />
<category android:name=""/> // android.intent.action.DEFAULT or android.intent.action.MAIN
android.intent.action.MAIN is given to the activity wich is going to launch at first and
android.intent.action.OTHER to the rest of the activities getting called by other activities
Your application will refer to the manifest to fetch the activity for first launch , havin MAIN in it

My App Installs Two Applications - Android

Whenever I try to run my App, it installs two app in the emulator/device. I only want to Install my Main Activity, but the Splash Activity installs also. I know the problem is in the Manifest. Can anyone help me please? Here is my code:
<activity
android:name="com.android.upcurrents.launcher.SplashActivity"
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="com.android.upcurrents.MainActivity"
android:label="#string/app_name" />
You need to have only one activity to be declared as the launcher. So, remove the intent-filter from within the SplashActivity's tag, and add it to your MainActivity. The Launcher intent-filter should be present in only one of the activities in your manifest file.
It installs based on the intent filter you have provided.
Remove the following intent filter from SplashActivity and then put it in Main Activity
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
try this:
<activity
android:name="com.android.upcurrents.launcher.SplashActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.android.upcurrents.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>
I had this same problem but I fixed it with the making sure you only have one activity with:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
In my code I had two activities with that intent-filter, which caused two applications to be installed on my device.
We have the same problem but i fixed it this way
before my code below in manifest
<application
android:debuggable="true"
android:allowBackup="true">
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.noupdate.apptest_noupdate.MainActivity"
android:icon="#drawable/ic_launcher"
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>
Notice that in the SplashActivity inside the intent is this code
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
i only deleted the category
<category android:name="android.intent.category.LAUNCHER" />
So after i deleted the intent-filter category in splash it didn't install two app icon but only one for main the code will be like this notice that the intent-filter category is deleted
<application
android:debuggable="true"
android:allowBackup="true">
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="com.noupdate.apptest_noupdate.MainActivity"
android:icon="#drawable/ic_launcher"
android:theme="#android:style/Theme.NoTitleBar"
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>
it really helps

Help on Tab Layout example

New bee to Android, I need help on creating tabs.
I am following the example stated in http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
When I run the application, I am not seeing any tabs but only Songs tab.
I am not able to figure out how to resolve this.
Below code is added under AndriodManifest.xml
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloTabWidget"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
<activity android:name=".AlbumsActivity">
<intent-filter>
<action android:name="com.example.TabWidget.AlbumsActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".ArtistsActivity">
<intent-filter>
<action android:name="com.example.TabWidget.AlbumsActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".SongsActivity">
<intent-filter>
<action android:name="com.example.TabWidget.AlbumsActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
Make it look something like this:
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloTabWidget"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AlbumsActivity"/>
<activity android:name=".ArtistsActivity"/>
<activity android:name=".SongsActivity"/>
</application>
This part:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
is for the entry part of your app.
here is a very simple example for tab-layout:
Andorid Tab-Layout with icons

Categories

Resources