intent-filter is not allowed? - android

I'm getting an "Element intent-filter is not allowed here" error. The instructions were to simply cut and paste the intent filter from WeatherActivity to MainMenuActivity since WeatherActivity was created first but it doesn't like it when I do it. What am I doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.introandroidapp">
<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.IntroAndroidApp">
<activity
android:name=".MyDrawing"
android:exported="false" />
<activity
android:name=".MainMenuActivity"
android:exported="false" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity
android:name=".WeatherActivity"
android:exported="true">
</activity>
</application>
</manifest>

<intent-filter> should be inside activity tag. If you want to mark MainMenuActivity as main, try something like this:
<activity
android:name=".MainMenuActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Don't forget that the main activity should have exported="true".

Related

How can i show my splash screen first without making in Mainacitivity

I made a splash screen class name Splash.class . I didnt make in mainacitivity so how i can I show this at first screen (Opening screen or first screen)
Manifest
<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.LoginApp">
<activity
android:name=".second"
android:exported="true"></activity>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
In order to launch the splash screen first, you have to specify the type of intent by using <intent-filter>. So, adding the below attributes to the activity in your AndroidManifest.xml file will make it launch first:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
In the end, your manifest will look something like this:
<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.LoginApp">
<activity
android:name=".second"
android:exported="true"></activity>
<activity
android:name=".MainActivity"
android:exported="true" />
<activity
android:name=".Splash"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</application>
</manifest>
change your manifest like this
<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.LoginApp">
<activity
android:name=".second"
android:exported="true"></activity>
<activity
android:name="com.your.package.Splash" //put yout class here
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
First time your android will run activity with category LAUNCHER, so change your activity class in category.LAUNCHER with your class (Splash.java)

"Error running app: Default Activity not Found"

I'm programming an app with sqlite+JSON, but suddenly I couldn't Run it anymore, and it popped this message, here's my AndroidManifest.xml , Idk if there's something wrong with it, my main activity is called DatosActivity, I wish you could help me.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hitan.practica2_u3">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="com.example.hitan.practica2_u3.DatosActivity"
android:theme="#style/AppTheme.NoActionBar"></activity>
</application>
</manifest>
You should add category.LAUNCHER & action.MAIN .
<activity
android:name="com.example.hitan.practica2_u3.DatosActivity"
android:theme="#style/AppTheme.NoActionBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This error is coming because you have not added the default screen which should execute first. So try adding following code snippet, and your problem will be solved:
<activity
android:name="com.example.hitan.practica2_u3.DatosActivity"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Hope it helps.
Please Add Intent Filter Tag in Manifest To Make It Default while Launching.
Add this intent filter inside your activity tag
<activity
android:name="com.example.hitan.practica2_u3.DatosActivity"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Why I am getting error with my activity in android?

I declare both of my activity class in AndroidManifest.xml file them when I run my application it stop unfortunately with this error message:-
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidtutorialpoint.androidobservablescrollview/com.androidtutorialpoint.androidobservablescrollview.ParallaxToolbarScrollViewActivity}; have you declared this activity in your AndroidManifest.xml?
This is my manifest file:-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.doctormobileapps.androidobservablescrollview">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
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=".ParallaxToolbarScrollViewActivity"
android:label="#string/title_activity_parallaxtoolbarscrollview"
android:theme="#style/AppTheme.Toolbar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.androidtutorialpoint.androidobservablescrollview" />
</intent-filter>
</activity>
</application>
</manifest>
My Activity class names are:-
MainActivity
ParallaxToolbarScrollViewActivity
Clean your build and rebuild the project. If you are using instance run android studio feature then disable this for avoid this problem
You placed it in the wrong location it should be inside the application tag. All your <activity... /> tags should be placed under the <application.. /> tag.
Hope this helps!
Remove
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.androidtutorialpoint.androidobservablescrollview" />
</intent-filter>
otherwise change your package name insted of
com.androidtutorialpoint.androidobservablescrollview
Remove intent-filter tag from your second activity.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.doctormobileapps.androidobservablescrollview">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
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=".ParallaxToolbarScrollViewActivity"
android:label="#string/title_activity_parallaxtoolbarscrollview"
android:theme="#style/AppTheme.Toolbar">
</activity>
</application>
</manifest>
Put intent filter to single activity which you want to start first. If launching activity is MainActivity, then remove intent filter from ParallaxToolbarScrollViewActivity. Or recheck the category line **
"com.androidtutorialpoint.androidobservablescrollview"
**
<activity
android:name=".ParallaxToolbarScrollViewActivity"
android:label="#string/title_activity_parallaxtoolbarscrollview"
android:theme="#style/AppTheme.Toolbar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.androidtutorialpoint.androidobservablescrollview" />
</intent-filter>
</activity>

application not listed in notification access Setting (Android)

my app is not listed in notification access setting screen...
i added this permission BIND_NOTIFICATION_LISTENER_SERVICE in manifest.xml
opening notification access setting screen by calling this intent startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
anyone implemented thanks...
I had this problem as well and I made the mistake of putting the service tag outside the application tag like this:
<?xml version="1.0" encoding="utf-8"?>
<service android:name=".TELNotificationListening"
android:label="#string/service_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light.NoActionBar" >
<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>
</application>
I fixed this problem by putting the service tag inside the application tag like this:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light.NoActionBar" >
<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>
<service android:name=".TELNotificationListening"
android:label="#string/service_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
</application>
You need to create a class that extends NotificationListenerService in my case I named it TELNotificationListening. You put the name of your class in android:name="" in the service tag.
In order to extend NotificationListenerService your minimum SDK has to be set to 21.
Once you extend NotificationListenerService you can then override it's method!

show 2 apps when debugging in android

When I debug and install app in device, it's show 2 apps install in device (one open with Splashscreen & another open without Splashscreen ) . Guide me, what I'm doing wrong.
here is my manifest file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.soft.prmk.alle"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:hardwareAccelerated="true"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SplashScreen"
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>
</manifest>
You have two Launcher Activities: MainActivity and SplashScreen. Remove one of those. Try this:
<?xml version="1.0" encoding="utf-8"?>
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:hardwareAccelerated="true"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".SplashScreen"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
</activity>
</application>
You have two LAUNCHER thats the issue
<category android:name="android.intent.category.LAUNCHER" />
Make it DEFAULT in MainActivity.
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
You have 2 launcher activities, remove intent-filter from one. I think SplashScreen should be launcher activity so remove from MainActivity
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Categories

Resources