This question already has answers here:
...have you declared this activity in your AndroidManifest.xml
(3 answers)
Closed 7 years ago.
Hi I have tried to add a class to my tabbed fragment and it is throwing an error, I thought at first that I was being stupid because I had not added the activity to the manifest but after I did it didn't work. How do you add an activity top the manifest and is the below error throwing this exception
ON: main
Process: com.androidbelieve.drawerwithswipetabs, PID: 14861
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidbelieve.drawerwithswipetabs/com.androidbelieve.drawerwithswipetabs.BradClass}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1793)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1515)
at android.app.Activity.startActivityForResult(Activity.java:4026)
at android.app.Activity.startActivityForResult(Activity.java:3973)
at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:829)
at android.support.v4.app.Fragment.startActivity(Fragment.java:897)
at com.androidbelieve.drawerwithswipetabs.LeagueOne$1.onItemClick(LeagueOne.java:41)
at android.widget.AdapterView.performItemClick(AdapterView.java:339)
at android.widget.AbsListView.performItemClick(AbsListView.java:1544)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3721)
at android.widget.AbsListView$3.run(AbsListView.java:5660)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6837)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
This is how I wrote my activity
<?xml version="1.0" encoding="utf-8"?>
<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">
<activity
android:name=".LeagueOne"
android:label="leagues"></activity>
<activity
android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
android:label="leagues"></activity>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Change your manifest to:
<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"/>
<activity
android:name=".LeagueOne"
android:label="leagues"/>
<activity
android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
android:label="leagues">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Your manifest.xml has some wrong.
<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">
</activity>
<activity
android:name=".LeagueOne"
android:label="leagues"></activity>
<activity
android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
android:label="leagues">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
If you want to use MainActivity as luncher,you can move intent-filter to MainActivity block.
Change your manifest to the given below, you put activity under activity thats the main problem all activity should be declared separate.
<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>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LeagueOne"
android:label="leagues"></activity>
<activity
android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
android:label="leagues"></activity>
</application>
Add Activity in Manifest this way:
<activity
android:name="com.androidbelieve.drawerwithswipetabs.BradClass"
android:label="leagues">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Related
Pleas Can anyone explain whats the problem in this?
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.crud.datapegawai, PID: 4989
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.crud.datapegawai/com.crud.datapegawai.AddEdit}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2065)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1727)
at android.app.Activity.startActivityForResult(Activity.java:5320)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:675)
at android.app.Activity.startActivityForResult(Activity.java:5278)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:662)
at android.app.Activity.startActivity(Activity.java:5664)
at android.app.Activity.startActivity(Activity.java:5617)
at com.crud.datapegawai.MainActivity$1.onClick(MainActivity.java:46)
at android.view.View.performClick(View.java:7448)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28305)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.DataPegawai">
-->
<activity android:name=".list_row" />
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.DataPegawai.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
From the log :
{com.crud.datapegawai/com.crud.datapegawai.AddEdit}; have you declared this activity in your AndroidManifest.xml
It means that there is an activity that you are using, but it was not declared in the android manifest. Every time you create an activity, you also need to declare this activity in the android manifest file. As you can see in your android manifest:
<activity android:name=".list_row" />
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.DataPegawai.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
There is a <activity> declaration. So in order to fix your problem, you need to declare com.crud.datapegawai.AddEdit in your manifest file. Something like this:
<activity android:name=".list_row" />
<activity android:name="com.crud.datapegawai.AddEdit" />
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.DataPegawai.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
For more details -> https://developer.android.com/guide/topics/manifest/manifest-intro
I want to make two splash screens for my android app. Only the second splash screen is visible whereas the first one isn't. Is what am trying to do possible? Here is my manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</activity>
<activity
android:name=".SplashActivity1"/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity
android:name=".SplashActivity2">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
and here is my code for first splash screen
.........
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Intent i = new Intent(SplashActivity1.this,
SplashActivity2.class);
startActivity(i);
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
and second Splash Screen
..................
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Intent i = new Intent(SplashActivity2.this, MainActivity.class);
startActivity(i);
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
Remove the intent filter from splashscreen 2 activity like in below code. other things are ok.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"/>
<activity
android:name=".SplashActivity1">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SplashActivity2">
</activity>
</application>
</manifest>
android:name="android.intent.category.LAUNCHER" should be give to only one Activity, which you want to call when app launches.
remove that from other Activities.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".SplashActivity1">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SplashActivity2"/>
<activity android:name=".MainActivity"/>
</application>
I highly recommend you first learn How to deal with Intent_filter.
Try with this: Make Main activity as default one and splash screen as Main launcher
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</activity>
<activity
android:name=".SplashActivity1"/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity
android:name=".SplashActivity2">
</activity>
</application>
When I start the application, it force close.
This is the LogCat:
java.lang.RuntimeException: Unable to instantiate application com.blocktrekacademy.officialblocktrek.Authentication: java.lang.ClassCastException: com.blocktrekacademy.officialblocktrek.Authentication cannot be cast to android.app.Application
[UPDATED] : This is my AndroidManifest.xml:
...
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".Authentication"
android:label="#string/title_activity_authentication"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is my Authentication.java
package com.blocktrekacademy.officialblocktrek;
import ...
public class Authentication extends AppCompatActivity {
...
First, remove android:name=".Authentication" property in <application> tag.
Your Authentication class is an Activity, not an Application. So, you have to declare it as such:
<application>
...
<activity android:name=".Authentication"
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
That intent-filter declares the Activity as the "main" activity, so it will be launched when your app starts.
Ok
I have manifest
<application
android:name=".App"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".ui.authorization.AuthActivity"
android:noHistory="true">
</activity>
<activity android:name=".ui.callsigns.SelectCallsignActivity"
android:launchMode="singleTop">
</activity>
<activity android:name=".ui.order.waitorder.WaitOrderActivity"
android:launchMode="singleTop">
</activity>
<activity android:name=".ui.balance.BalanceActivity"
android:noHistory="true"
/>
<activity android:name=".ui.splash.SplashActivity"
android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.order.gotorder.GoogleMapsActivity"/>
<activity android:name=".ui.order.gotorder.OrderDetailsActivity"
android:launchMode="singleTask"/>
<service android:name=".location.ServiceForLocation"/>
<service android:name=".network.newsocket.NewSocketService"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key"/>
<meta-data
android:name="io.fabric.ApiKey"
android:value="db0dc6f3ae8099a148926812fca7bd6cc29b4f4b"/>
</application>
...
Next start WaitOrderActivity
Intent intent = new Intent(getBaseContext(), WaitOrderActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
startActivity(intent);
Next from callback but in WaitOrderActivity I start OrderDetailsActivity
After all I call again startActivity(WaitOrderActivity) or OrderDetailsActivity.this.finish, anyway I will be in WaitOrderActivity again.
Trouble: in second time I see by logs what OrderDetailsActivity started, but I doesn't see that on the screen. I still see WaitOrderActivity. Why?
Android-Installing to device using eclipse install two instance of same app at once-error
and it runs when just after installed using the eclipse but when I touch the once of the icon its not starting it shows me the android common error syaing unexpectedly stopped!! please help me??
This is the manifest I'm using(activities)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hunter99x"
android:icon="#drawable/icon"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".main" android:configChanges="orientation|keyboardHidden" android:theme="#android:style/Theme.NoTitleBar"
android:label="#string/app_name" android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".origine" android:configChanges="orientation|keyboardHidden" android:theme="#android:style/Theme.NoTitleBar"
android:label="#string/app_name" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.origine" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity `enter code here`android:name=".Gameover" android:configChanges="orientation|keyboardHidden" android:theme="#android:style/Theme.NoTitleBar"
android:label="#string/app_name" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LandingScreen" android:configChanges="orientation|keyboardHidden" android:theme="#android:style/Theme.NoTitleBar"
android:label="#string/app_name" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.VIBRATE"/>
</manifest>
I think the issue is because you have repeated
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
this for 2 activities. Try removing this and declare just 1 acivity as your main. Tjis may solve your issue.
Try this code inside the activities and check if it works:
#Override
public void onBackPressed() {
finish();
System.exit(0);
}