Samsung Note II won't issue OUTGOING_CALL Broadcast - android

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"/>

Related

My Custom BroadcastReceiver is not working above API level 16

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.

Service in binded Jar doesn't come up without "RECEIVE_BOOT_COMPLETED"

I have an App that uses a Service that I've added by a Bindable Jar.
Current state:
this Jar has an own Manifest (see below), when I don't touch anything on this Manifest everything works as it should.
Problem:
This Jar lets on Deployment to Device always its launer AppIcon on Device.
So my App leaves finaly two launcher icons, the one desired and the other from the Jar.
My Approach was to delete follow Part from Manifest:
android:theme="#style/AppTheme">
<activity
android:name=".ScanDemoActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Doing this the App Crashed on BootUp with Error: BootReceiver not found ...
Deleting the next few Lines:
<receiver android:name="com.company.scandemo.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</receiver>
caused started correctly on bootUp, but the Service didn't come up on BOOT_COMPLETED, when I start the App via Launcher icon everything worked.
Wished Behaviour:
I want the Main App to leave only one launch Icon and startup correctly on Boot
Here is the Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.scandemo"
android:versionCode="1"
android:versionName="2.2" >
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".ScanDemoActivity"
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="com.company.scandemo.FloatingService" />
<receiver android:name="com.company.scandemo.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</receiver>
</application>
</manifest>

BroadcastReceiver not called when registering from manifest

This is how my Manifest looks like:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lcukerd.earphonereminder">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<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">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="ConnectivityActionReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGE" />
</intent-filter>
</receiver>
</application>
</manifest>
My Receiver works fine when registering from activity but I want to register from manifest so that it can run even when the app is closed. What is the issue? Why is it not working?
Since Android Oreo, receivers must be registered in runtime using
context.registerReceiver(receiver, intentFilter);
to receive implicit intents
You can still receive explicit intents and some special implicit actions, as boot_completed or locale_changed for example
More information look below link
https://developer.android.com/about/versions/oreo/background.html#broadcasts
Try Using .ConnectivityActionReceiver instead of ConnectivityActionReceiver. when you Call ConnectivityActionReceiver The Receiver won't be Registered Since No Class is Found
<receiver
android:name=".ConnectivityActionReceiver"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="100">
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGE" />
</intent-filter>
</receiver>
Refer This Question to know More

Why GcmReceiver stop working when screen is off?

my problem is that my gcm works well and i am receiving notifications, but when the screen of my cellphone is off my GcmReceiver stop working and i do not receive notifications more
Any idea of why this is happening ? Thanks in advance!
this is my manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="schan.main"
>
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="17"/>
<permission android:name="schan.main.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="schan.main.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:persistent="true"
android:theme="#style/Theme.Schan" >
<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>
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="schan.main" />
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
</receiver>
<service
android:name="schan.main.MyGcmListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</service>
<service
android:name="schan.main.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service
android:name="schan.main.RegistrationIntentService"
android:exported="false">
</service>
<activity
android:name=".LoginActivity"
android:icon="#mipmap/ic_launcher"
android:label="#string/login"
android:parentActivityName=".MainActivity"
android:theme="#style/Theme.Schan" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="schan.main.MainActivity" />
</activity>
<activity
android:name=".SigupActivity"
android:label="#string/joinus"
android:parentActivityName=".MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="schan.main.MainActivity" />
</activity>
<activity
android:name=".Alert"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:label="#string/title_activity_alert_dialog" >
</activity>
</application>
Update
i found my real problem, is this one how can i put this configuration on my huawei cellphone?
First, you need 'Wakeful broadcast receiver' It help for the common pattern of implementing a BroadcastReceiver that receives a device wakeup event and then passes the work off to a Service, while ensuring that the device does not go back to sleep during the transition. This class takes care of creating and managing a partial wake lock for you; you must request the WAKE_LOCK permission to use it.
Second, you need to use 'delay_while_idle', it indicates that the messages not be sent immediately if the device is idle. The server will wait for the device to become active, and then only the last message for each collapse_key value will be sent. The default value is false.

can broadcast receveir work even when my app is closed

I am building a simple sms app , i want to open my app automaticaly when ever a new sms is received? is it even possible?
i am using broadcast receiver for this
what changes should i made in manifest?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.message"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MessageActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<receiver android:name=".SmsReceiver" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</activity>
<activity android:name=".Reply" >
</activity>
</application>
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
</manifest>
you should move the receiver outside from the activity like this:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MessageActivity"
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=".Reply" >
</activity>
<receiver android:name=".SmsReceiver" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
Under Android 3.0 and later, your broadcast is not guaranteed to be received unless the user has opened your application. The application does not have to remain opened, just to have been started once. This is caused by a flag (FLAG_EXCLUDE_STOPPED_PACKAGES) which is now part of most system broadcasts, which says the broadcast should not start a stopped application.
This was already answered in How to make android launch an application on received specific sms to keep it short: it is possible with BroadcastReceiver.

Categories

Resources