OnReceive method of my Broadcast Receivers not working in Marshmallow - broadcastreceiver

I am searching for about 5 hours for a solution to receive my custom broadcast that is sent from a service. All things were good before testing app on android 6.0.
I know that user-permissions have changed. My manifest.xml file includes:
<application>
<receiver android:name="my_receiver" />
</application>
<permission android:name="name"
android:label="my_permission"
android:protectionLevel="signature">
<uses-permission android:name="name"/>
But onReceive method is not called?

first you have to mention the action inside the receiver on which you want to call the receiver. in higher sdk version broadcast not work directly you have to register broadcast in main activity.

Related

Incoming call notification

We are developing an app with angular/ionic in which we use capacitor jitsi plugin for video calls. What we are now trying to do is to receive notifications (via firebase) like in whatsapp with the incoming call screen and two buttons to accept and decline. Any idea on how to do that?
Thanks
If you got the choice to change the notification service, instead or directly using firebase, you could use Onesignal which extends firebase and they already have a service named VOIP notifications which should kinda do your needs and here is the link:
https://documentation.onesignal.com/docs/voip-notifications
In case your are restricted with firebase or need to know how this could be done, bellow will be the way to achieve it..
As for android:
First as logic part, you need to add some code in the native layer since hybrid apps usually can't interact from JavaScript side to native side in case app was not launched, so in order to wake the application on a specific event like notification received or any other actions that phone system can hold..
Second, as technical part, you need to add broadcast receivers and the receivers role stand to interact as native code with system. example in the link below:
https://www.digitalocean.com/community/tutorials/android-broadcastreceiver-example-tutorial
also another video about foreground and background broadcast receiver service in the link below:
https://www.youtube.com/watch?v=rlzfcqDlovg
video code output in git:
https://github.com/borntocoderepos/callrecorder
in the Youtube video example, the user is launching a toast message on phone call if app was opened or closed (background or foreground) so you can launch your app with intent with passing data and capture the data on app start as Deep Links as capacitor (https://capacitorjs.com/docs/guides/deep-links) or Cordova (https://ionicframework.com/docs/native/deeplinks)..
And instead of listening to network or phone calls, you can listen to Notifications and for sure you need to do searches about your topic and or the notification service that you'll choose.
Now for the video and the tutorial not sure of the quality of code so make sure to do more researches about the way its done from different places (could be outdated code or bad code quality or even not complete service and will discuss about this point below).
In android there is policy about using background and foreground services so once you start a service you need to end it after your done so make sure after you receive the notification and launch your app to stop the listening since it would cost power usage and perhaps could be stopped by Playstore as harmful app.
Now considering IOS it should be the same concept so make searches about this topic, but for IOS, the listeners policy as I remember , the receivers should not be waked up for more than 15 mins, so also keep this in mind and make sure you stop the receivers directly after launching your Hybrid app.
Broadcast equivalent receiver for IOS:
http://www.andrewcbancroft.com/2014/10/08/fundamentals-of-nsnotificationcenter-in-swift/

BluetoothLeScanner: could not find callback wrapper

While developing the app I got this problem.
Some Android devices cannot find the Bluetooth connection (Not all of them)
And it shows this error.
D/BluetoothLeScanner(27109): Start Scan with callback
I/BluetoothAdapter(27109): STATE_ON
I/BluetoothAdapter(27109): STATE_ON
D/BluetoothLeScanner(27109): could not find callback wrapper
I have tried to add Fine Location permission, but there is no luck.
<uses-permission android:name="Manifest.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="Manifest.permission.ACCESS_COARSE_LOCATION" />

OpenIAB Unity consume failure for amazon store

I am testing OpenIAB to upgrade from amazon IAP v1 to v2 in Unity. I am using the latest OpenIAB unity plugin.
I am able to query and purchase an IAP but then the call to OpenIAB.consumePurchase returns a failure callback. I am testing with App Tester on amazon.
I get the error below "original json invalid" after calling OpenIAB.consumeProduct(..)
Original json is invalid:
{"itemType":"inapp","orderId":"","packageName":"","sku":"productexample","purchaseTime":0,"purchaseState":0,"developerPayload":"","token":"q1YqVrJSSi_OKynKLEhNzC4uyc9OzSvOTS3Ozc8vKMnMzzNU0lFKAaoxNDEzMzY3NzM2NjY1AoqVAsVyjD18zCMKClx9M4r83V3ySossdUtzygrzc4uC080KK_1dvHMTM8zNcrxCbYFaSpSsDGoB","originalJson":"","signature":"","appstoreName":"com.amazon.apps","receipt":”"}
I am having multiple other issues like I don't get back orderId or receiptID from queryInventorySuccess callback for the purchase that is already made. I see the valid productId but no orderId even though I see the receiptId on App Tester. What is the difference between Token, ReceiptId and OrderId?
Also what is the difference in using the below in manifest for android:name in receiver. Could there be a problem here?
<receiver android:name="com.amazon.inapp.purchasing.ResponseReceiver">
<intent-filter>
<action
android:name="com.amazon.inapp.purchasing.NOTIFY"
android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY"/>
</intent-filter>
</receiver>
compared to using
<receiver android:name="com.amazon.device.iap.ResponseReceiver">
<intent-filter>
<action
android:name="com.amazon.inapp.purchasing.NOTIFY"
android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY"/>
</intent-filter>
</receiver>
If I use the first version in android manifest, then the app just crashes on start
Just purely for the record Htcls,
Since about 2015 Unity3D now has
in-app purchase built-in, as a integrated feature of Unity.
It is incredibly easy to use, compared to any previous approach for IAP/IAB.
https://docs.unity3d.com/Manual/UnityIAP.html
https://unity3d.com/learn/tutorials/topics/analytics/integrating-unity-iap-your-game
It is completely free and completely built-in to Unity.
This has been one of the most significant changes to App industry in some years.
Previously, achieving IAP/IAB (Apple/Google) was a HUGE effort on game titles. (The Prime31 plugins were popular for this.) Often it was more of a chore than making the actual game. It can now be achieved relatively simply WITH NO PLUGINS AT ALL inside Unity.
At this point it would be extremely unusual to use any other approach for IAP/IAB. It is an incredible advance and huge time saver that it is now built-in to Unity.
Regarding
Amazon...
store coverage, follow the thread here
http://forum.unity3d.com/threads/unity-iap-store-guides-amazon-apple-google-play-windows.372647/
https://docs.google.com/document/d/1QxHRo7DdjwNIUAm0Gb4J3EW3k1vODJ8dGdZZfJwetYk
Unity staffer "nicholasr" and others are actively answering all questions on the topic.
Consider this extremely simple code base which shows how the built-in IAP/IAB works
http://forum.unity3d.com/threads/unity-iap-store-guides-amazon-apple-google-play-windows.372647/page-3#post-2565610

Installing app on 2014 model / app doesn't appear

I'm using SDK 5.1 and have tested a javascript app on the emulator. Now I'm struggling to install the app on my 2014 model.
I followed the samsung guide for 2014 models (http://www.samsungdforum.com/Guide/art00121/index.html).
I've logged in with the "develop" account, typed in the ip and clicked "start user app sync". Then I get a popup "User Apps sync requested - OK"
My problem is, that (even after several minutes) the app doesn't appear in the app-section of my tv.
I've checked my access.log of the apache and have found code 200 for the widgetlist.xml and the zip-file:
GET /widgetlist.xml?timestamp=1420139182690 HTTP/1.1' 200 307
GET /Widget/MyApp_0.100_Europe_20150101.zip HTTP/1.1' 200 460823
So, the tv should have received the files, but doesn't install the app.
Here is my widgetlist.xml:
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<rsp stat='ok'>
<list>
<widget id='MyApp'>
<title>Test</title>
<compression size='460823' type='zip'/>
<description>Test</description>
<download>http://xxx.xxx.xxx.xxx/Widget/MyApp_0.100_Europe_20150101.zip</download>
</widget>
</list>
</rsp>
Here my widget.xml:
<?xml version="1.0"encoding="UTF-8"?>
<widget>
<ThumbIcon>icon/ThumbIcon.png</ThumbIcon>
<BigThumbIcon>icon/BigThumbIcon.png</BigThumbIcon>
<ListIcon>icon/ListIcon.png</ListIcon>
<BigListIcon>icon/BigListIcon.png</BigListIcon>
<category>Information</category>
<autoUpdate>n</autoUpdate>
<cpname></cpname>
<cpauthjs></cpauthjs>
<login>y</login>
<ver>0.100</ver>
<mgrver>1.000</mgrver>
<fullwidget>y</fullwidget>
<srcctl>y</srcctl>
<ticker>n</ticker>
<childlock>n</childlock>
<audiomute>n</audiomute>
<videomute>n</videomute>
<dcont>y</dcont>
<network>y</network>
<widgetname>MyApp</widgetname>
<description></description>
<width>960</width>
<height>540</height>
<author>
<name></name>
<email></email>
<link></link>
<organization></organization>
</author>
</widget>
Do you have any idea, what the problem could be? Is there any log on the tv, which could be accessed to get more information?
Thanks for your help!
Try zipping it up and putting it on the USB stick. Open SmartHub and insert the drive. You should see your app in the hub. If all goes well.
In my case, it was a problem in the index.html?!? After changing the order of the included files in the (.css before .js) it's now working.
Interesting for me, that this causes a problem during sync between web server and tv
Same thing happened to me when my completely tested app on other Samsung platforms(Samsung TV 2012,2013,2014) Failed to load on Samsung Blu-Ray player which have similar steps of loading app on TV.
After enormous test and trials i finally figured out that there was one particular jquery library jquery-latest.js which was stopping the app from being uploading to Blu-Ray player. So i re factored the app to another jquery library...and now app is working fine

Android4.0 Service kicked out

Here is my code for starting a service.
public class MyStartupIntentReceiver extends BroadcastReceiver
{
public void onReceive(Context context, Intent intent)
{
Intent callService = new Intent();
callService.setAction("com.xxxx.yyyy.services.StartServiceActivity");
context.startService(callService);
}
}
In manifest file i'm defining broadcast receiver like following.
<receiver android:name=".MyStartupIntentReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"
/>
</intent-filter>
</receiver>
Im declaring the service like following in manifest file
<service android:name=".services.CallService">
<intent-filter>
<action
android:name="com.xxxx.yyyy.services.StartServiceActivity" />
</intent-filter>
</service>
Once user launched my application im starting service from my activity
serviceIntent = new Intent(SplashScreen.this, StartServiceActivity.class);
getApplicationContext().startService(serviceIntent);
Issue is service is working fine with android2.3.5 SDK devices. but not with 4.0 devices. Anything wrong with my code. Please help me to solve.
I find a article from the Internet, hope that it can help u:
Broadcast Regression Confirmed
In a previous post, I cited evidence that the BOOT_COMPLETED broadcast will not work out of the box on Android 3.1 until the user uses your app.
It’s actually somewhat bigger than that.
In the issue that I filed seeking clarification, Ms. Hackborn indicated:
Starting with 3.1 when applications are installed they are in a “stopped” state so they will not be able to run until the user explicitly launches them. Pressing Force Stop will return them to this state.
As a result, when applications are first installed, they are totally ignored by the system until and unless the user manually launches something: clicking on a launcher activity or adding an app widget, most likely.
Developers who had been relying upon getting some sort of system broadcast without user intervention will need to adjust their apps for Android 3.1.
As I wrote in the previous post:
I expect that most apps will be OK. For example, if your boot receiver is there to establish an AlarmManager schedule, you also needed to establish that schedule when the app is first run, so the user does not have to reboot their phone just to set up your alarms. That pattern doesnot change – it’s just that if the user happens to reboot the phone, it will not set up your alarms, until the user runs one of your activities.
UPDATE: To clarify the above quote, once the user runs the app for the first time (and does not Force Stop it), everything behaves as before — a reboot will cause BOOT_COMPLETED broadcasts to be received and so on. However, if the user installs the app, until and unless they run the app manually, no broadcasts will be received. And if the user force-stops the app, until and unless they run the app manually, no broadcasts will be received.
This change is not terribly shocking, as it ratchets up the security another notch by limiting ways malware can run without user knowledge. While it does not offer perfect security — the malware can still install its own copy of an Angry Birds launcher icon and hope users screw up — it is an improvement.