My Custom BroadcastReceiver is not working above API level 16 - android

I'm doing my college project which was Parental Control app. In that I'm creating a Custom Receiver. I'm tested that app in jelly bean,kitkat,lollipop, marshmallow, naughat ,oreo. But it only works in jelly bean and kitkat. I'm tried reading all solutions in stackoverflow. Please give solution for me!
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.nizam.training.parentalcontrol">
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<application
android:fullBackupContent="false"
android:allowBackup="true"
android:icon="#mipmap/m"
android:label="#string/app_name"
android:logo="#mipmap/ico"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<service
android:name=".BlockService"
android:enabled="true"
android:exported="true"/>
<activity android:name=".AppSettingActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<activity
android:name=".BlockActivity"
android:theme="#style/Theme.AppCompat.Light.NoActionBar" />
<activity
android:name=".MainActivity"
android:theme="#style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LoginActivity"
android:label="Login"
android:theme="#style/MyTheme" />
<activity
android:name=".SignupActivity"
android:label="Create Pin"
android:theme="#style/MyTheme" />
<activity
android:name=".TaskList"
android:label="Tasks"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<receiver
android:name=".MyReceiver"
android:enabled="true"
android:exported="true"
android:permission=""
tools:ignore="ExportedReceiver">
<intent-filter>
<action android:name="StartupReceiver_Manual_Start" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
<receiver android:name=".CheckRunningApplicationReceiver" />
</application></manifest>
Calling broabcast in TaskListActivity.java
getApplicationContext.sendBroadcast(new Intent("StartupReceiver_Manual_Start"))
LogCat
http://mnktalktech.blogspot.com/2019/02/logcat-for-parentalcontrol.html

I found this; it might be part of the issue. Are you getting any errors?
GET_TASKS Permission Deprecated

Please try with this.
<receiver
android:name=".MyReceiver"
android:enabled="true"
android:exported="false"
>
<intent-filter>
<action android:name="StartupReceiver_Manual_Start"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
and let me know.

After spending a week in this issue I have found solution for this.
What I put before (which is not working)...
getApplicationContext.sendBroadcast(new Intent("StartupReceiver_Manual_Start"))
Now I just changed.
MyReceiver mr=new MyReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("StarctupReceiver_Manual_Start");
registerReceiver(mr,intentFilter);
getBaseContext().getApplicationContext().sendBroadcast(new Intent("StarctupReceiver_Manual_Start"));
I don't know why it is working but it works.If anyone know the reason please comment. Thanks for all who tried to solve this issue.

Related

My application icon doesn't appear when I debug or Run 'app' on android studio, what happened?

My application icon no longer appears on my android phone screen when I debug like it used to. I know this has something to do with the androidmanifest.xml file. I've looked up several solutions for me but those solutions resulted in my application being unable to even run in the first place.
What could be the problem here?
I have tried the solutions mentioned here:
Android Studio: App icon doesn't appear in the home screen or app list
Launcher icon missing in Android
This is my android manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="sg.edu.singaporetech.teamproject">
<uses-permission android:name="android.permission.INTERNET" /> <!-- allow usage of camera for Android -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> <!-- to run foreground service for steps -->
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<application
android:name=".StepsNotification"
android:allowBackup="true"
android:icon="#drawable/exersize"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".DispatchActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<activity android:name=".profile.editProfile"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".registration.RegisterActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".home.HomeActivity">
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.MAIN" />-->
<!--<category android:name="android.intent.category.LAUNCHER" />-->
<!--</intent-filter>-->
</activity>
<receiver android:name=".StepsBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter>
</receiver>
<service android:name=".StepsService"/>
</application>
</manifest>
I think the problem is in the line,
android:icon="#drawable/exersize"
In the application tag, app icon must he placed in the mipmap folder as it meant for the app icon only. Mipmap must have all scales of the icon.

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!

How to setup Android Firebase Notification in Manifest?

I'm trying to setup Firebase notifications. I did changes in app level and root level build.gradle. But still, its giving me error in Manifest for MyFirebaseMessagingService. Error is Unresolved Class.
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".s" />
<activity android:name=".im" />
<activity android:name=".Main2Activity" />
<activity android:name=".sactivity" />
<service
android:name=".MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<activity
android:name=".ScrollingActivity"
android:label="#string/title_activity_scrolling"
android:theme="#style/AppTheme.NoActionBar"></activity>
</application>
Looks like the Android Manifest file can't locate the MyFirebaseMessagingService class. I'd suggest you to put the fully qualified package name of the class. See example below:
<service android:name="com.android.notification.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
Oh! you haven't create any java class here, lets just get around it since |service| is instantiated to true on default.You should make android:enabled="false",i think this should work. see detail code below.
<service android:enabled="false" android:name="MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="com.fcm.MyFirebaseMessagingServices">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="com.fcm.MyFirebaseInstanceIdServices">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>

Samsung Note II won't issue OUTGOING_CALL Broadcast

I have an app I'm working on where I have a broadcast receiver for outgoing calls. It works fine on the emulator, but not my Galaxy Note 2. It appears that either the Outgoing Call broadcast is never issued, or it's being consumed before I can get a hold of it.
I've heard rumours that Samsung does this funny. Hope someone knows specifically what.
Android Manifest follows.
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<receiver android:name="OutgoingCallHandler" android:exported="true" android:enabled="true" >
<intent-filter android:priority="1">
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
<activity
android:name="MainActivity"
android:label="#string/title_activity_main"
android:theme="#android:style/Theme.NoDisplay" >
</activity>
<activity
android:name="SettingsActivity"
android:label="#string/title_activity_settings" >
<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.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

Eclipse showing No launcher Activity found

This is my android Manifest.xml.
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.co.halfninja.wallpaper.parallax">
<uses-sdk android:minSdkVersion="7" />
<uses-feature android:name="android.software.live_wallpaper" />
<application
android:label="#string/app_name"
android:icon="#drawable/icon">
<service
android:label="#string/app_name"
android:name=".ParallaxWallpaper"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.service.wallpaper" android:resource="#xml/wallpaper" />
</service>
<activity
android:label="#string/wallpaper_settings"
android:name=".ParallaxWallpaperSettings"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:exported="true">
</activity>
</application>
</manifest>
Still Eclipse showing the result
ParallaxWallpaper] No Launcher activity found!
ParallaxWallpaper] The launch will only sync the application package on the device!
ParallaxWallpaper] Performing sync
ParallaxWallpaper] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
Please let me Know where am i doing the mistake, and what would be the solution...???
Move the intent-filter tag from service to activity
These lines should be in Activity tag
<application
android:label="#string/app_name"
android:icon="#drawable/icon">
<activity
android:label="#string/wallpaper_settings"
android:name=".ParallaxWallpaperSettings"
android:theme="#android:style/Theme.Black.NoTitleBar" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:label="#string/app_name"
android:name=".ParallaxWallpaper"
android:permission="android.permission.BIND_WALLPAPER">
</service>
<meta-data android:name="android.service.wallpaper" android:resource="#xml/wallpaper" />
</application>
make activity as launcher you have made service as launcher. like that
<activity
android:label="#string/wallpaper_settings"
android:name=".ParallaxWallpaperSettings"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Categories

Resources