Android SIP: Service not running for incoming sip calls - android

I am developing a SIP application for VOIP calls. I have modified SIPDemo as per my UI requirements. When an incoming call is triggered, my app is registered to server domain and able to receive calls, (even in the case when the app is not running).
But when my app is destroyed/killed, incoming calls are not triggered.
I have made service start, i think its not running. I'm new to this and unable to figure out, Kindly suggest the help!
Manifest Declaration:
For Service:
<service
android:name=".CallDetectService"
android:process=".com.example.mysip.callservice"
android:enabled="true"
android:exported="false" >
</service>
For Receiver:
<receiver
android:name=".receiver.ServiceAtBootReceiver"
android:enabled="true"
android:exported="true"
android:label="StartMyServiceAtBootReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
Manifest Permissions:
<uses-permission android:name="android.permission.USE_SIP" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-feature
android:name="android.hardware.sip.voip"
android:required="true" />
<uses-feature
android:name="android.hardware.wifi"
android:required="true" />
<uses-feature
android:name="android.hardware.microphone"
android:required="true" />

all your manifest declarations are good,,, and as for keeping your app running that depends on how well your service is made... here is an answer that I hope it helps you:
AlarmManager or Service

Related

GCM notification is not receiving when app is killed( not force kill)

I am happily receiving notifications when app is in background and foreground but when app is killed, I am not receiving notifications in some phones (like Xiaomi model phones eg mi3, etc.)
GCM message 0:1434141725194227%03b66390f9fd7ecd
broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg= (has extras) }
Although I am getting notifications in other phones like nexus, samsung, others.
Did anyone also had similar problem?
Can someone explain me where I am wrong.
Here is my Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="<package_name>">
<permission android:name="<package_name>.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="<package_name>.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGED"/>
<action android:name="android.net.wifi.STATE_CHANGE"/>
<application
android:name="<package_name>.ApplicationSingleton"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name="<package_name>.ui.activity.ReferralActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="<package_name>.gcm.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="<package_name>" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="<package_name>"/>
</intent-filter>
</receiver>
<service android:name="<package_name>.gcm.GcmIntentService" />
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
Autostart probably the best MIUI feature that doesn’t come enabled by default, but should.
What does autostart do? It basically starts the apps you select when the phone starts, so you never miss any notifications or updates.
To enable autostart for your apps, follow the steps below:
Tap on the Security app from the app screen.
You will not find this if you enter from the Settings menu, you have to tap directly on the app icon.
Open Security App:
Once in the Security app, tap on Permissions.
Tap on Autostart
Toggle the apps you want to enable Autostart for
Reboot your phone.
Now you are all set up with autostart!

Starting application on boot completed

The following is the code I'm using for starting my Application when device is turned on.
public class BootReceiver extends BroadcastReceiver{
#Override
public void onReceive(Context context, Intent intent) {
Log.i("BootReceiver","intent received");
Intent myIntent = new Intent(context, ACT_Home.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myIntent);
}
}
and in the Manifest (as <Application> child):
<receiver android:name="host.alarmmanager.BootReceiver">
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
The permissions inside the Manifest are the following:
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature android:name="android.hardware.camera"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
This works fine on Android 3.2.2, but if I try the same application on Android 4.0.3 the broadcast receiver does not receive anything.
Also the first line inside the onReceive method is not execeuted.
Why this happens?
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
This you should use in android manifest
Try this, although your code seems fine! The following is working for me.
<!-- Receivers -->
<receiver android:enabled="true" android:name="host.alarmmanager.BootReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
Make sure you are not restarting your phone by selecting restart option from the power menu.
Android bizarrely has 2 different permissions.
1.Reboot
2.On boot complete
So,
first power off your phone and then after few seconds power on it again!
Hope it helps! (Y)

How to specify hardware requirement through code?

I have an android application which has a provision to controls calls ie, allow or block specific incoming & outgoing phone calls.Here is part of manifest file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xxxx.xxxxxx.xxxxxxx"
android:installLocation="internalOnly"
android:versionCode="1"
android:versionName="1.0" >
<uses-feature
android:name="android.hardware.telephony"
android:required="false" />
<uses-feature
android:name="android.hardware.location"
android:required="false" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application>
</activities>
</services>
<receiver android:name="xxxx.xxxx.ReceiverOutGoingCall" >
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
<receiver android:name="xxxx.xxxx.ReceiverIncomingCall" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
</application>
</manifest>
This application does not show for some devices in Google play.After a long time search I understood that it is due to <uses-feature> hardware requirements. No i want to remove the required hardware features for phone calls from manifest and check them from code.
Some tablets which does not have a Phone Call functionality does not show my application.So i want to make my application available to these tablets which lacks the required hardware.How can i achieve this?
Thanks in Advance
Some permissions automatically impy feature requirements.
This is what the API Guides says:
"For any of the permissions below, you can disable filtering based on the implied feature by explicitly declaring the implied feature explicitly, in a element, with an android:required="false" attribute."
Your permissions impliy the features android.hardware.wifi, android.hardware.location.network, android.hardware.location.gps, android.hardware.location and android.hardware.telephony.
You set only two of them to android:required="false". So you might try to set the other permissions to not required, too.
Unfortunately, there isn't a way to add permissions after the application is installed. Perhaps you can release 2 APKs. One for mobile devices and one for tablets.
Try this code to check if phone functionality is available :
public static boolean isTablet(Context context) {
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
return manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE;
}

Register device on GCM: onRegistered isn't called

I'm using GCM on my application, but when I try to register my device the onRegistered method on GCMIntentService isn't called.
I installed the GCM demo application on my device and it works:
http://developer.android.com/guide/google/gcm/demo.html
In this app the device is registered and I can send messages to it. I tried to use GCM in my own app using the same GCMIntentService. I adapted the manifest too, but when I try to register this is what appears in my log:
09-25 10:00:10.195: V/GCMRegistrar(591): Registering app com.pfc.dps of senders 38322290XXXXX
And nothing else, I get no response. These are my manifest permissions:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pfc.dps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.GET_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.USE_CREDENTIALS"></uses-permission>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_SYNC_STATS" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Creates a custom permission so only this app can receive its messages. -->
<permission
android:name="com.pfc.dps.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission
android:name="com.pfc.dps.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive data message. -->
<uses-permission
android:name="com.google.android.c2dm.permission.RECEIVE" />
I created a new project in Google APIs console to check if it worked that way, but I get the same result using any of the Sender IDs.
Does anybody know why is that?
Thank you!
After the "Registering app *your_package* of senders *sender_id*"
You should receive a onReceive event which will call your GCMIntentService to wake your app up.
If you do not have that, please check you have missed the receiver or forgotten to change the category for your own package.
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="***your_package***" />
</intent-filter>
</receiver>

Permission Denial: receiving Intent { act=com.google.android.c2dm.intent.REGISTRATION

I'm trying to implement push notifications in my app, but it seems that my C2DMReceiver is not working. I tried every solution I could find. Here is what I have:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="10" />
<permission android:name="com.my.app.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="com.my.app.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<activity>....</activity>
<service android:name=".C2DMReceiver"/>
<receiver
android:name="com.google.android.c2dm.C2DMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.my.app"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.my.app"/>
</intent-filter>
</receiver>
In my onCreate method I use:
C2DMessaging.register(this, "mymail#gmail.com");
String id = C2DMessaging.getRegistrationId(this);
And id is always empty.
Looking at the LogCat, I can see Permission Denial: receiving Intent { act=com.google.android.c2dm.intent.REGISTRATION So, what should I do?Thanks)
Change your android:name in your receiver tag from com.google.android.c2dm.C2DMBroadcastReceiver to com.my.app.YourReceiverClassName, and make sure your sender e-mail and server side login e-mail are the same.
The android:name in your receiver has to specify the path to your class that implements the receiver. I am sure that your C2DMBroadcastReceiver class is not in the com.google.android.c2dm package, as I see below your are using a com.my.app package.
Create a C2DMBroadcastReceiver class in, for example, com.my.app.receiver and specify the receiver's adroid:name as:
<receiver
android:name="com.my.app.receiver.C2DMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
......
</receiver>

Categories

Resources